本文整理汇总了Python中barman.infofile.WalFileInfo.orig_filename方法的典型用法代码示例。如果您正苦于以下问题:Python WalFileInfo.orig_filename方法的具体用法?Python WalFileInfo.orig_filename怎么用?Python WalFileInfo.orig_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类barman.infofile.WalFileInfo
的用法示例。
在下文中一共展示了WalFileInfo.orig_filename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_archive_batch
# 需要导入模块: from barman.infofile import WalFileInfo [as 别名]
# 或者: from barman.infofile.WalFileInfo import orig_filename [as 别名]
def test_archive_batch(self, archive_wal_mock, get_next_batch_mock,
fsync_mock, caplog):
"""
Test archive using batch limit
"""
# Setup the test
fxlogdb_mock = MagicMock()
backup_manager = MagicMock()
archiver = FileWalArchiver(backup_manager)
archiver.config.name = "test_server"
wal_info = WalFileInfo(name="test_wal_file")
wal_info.orig_filename = "test_wal_file"
wal_info2 = WalFileInfo(name="test_wal_file2")
wal_info2.orig_filename = "test_wal_file2"
# Test queue with batch limit 1 with a list of 2 files
batch = WalArchiverQueue([wal_info, wal_info2], batch_size=1)
assert batch.size == 2
assert batch.run_size == 1
get_next_batch_mock.return_value = batch
archiver.archive(fxlogdb_mock)
# check the log for messages
assert ("Found %s xlog segments from %s for %s."
" Archive a batch of %s segments in this run." %
(batch.size,
archiver.name,
archiver.config.name,
batch.run_size)) in caplog.text
assert ("Batch size reached (%s) - "
"Exit %s process for %s" %
(batch.batch_size,
archiver.name,
archiver.config.name)) in caplog.text
示例2: test_archive
# 需要导入模块: from barman.infofile import WalFileInfo [as 别名]
# 或者: from barman.infofile.WalFileInfo import orig_filename [as 别名]
def test_archive(self, datetime_mock, move_mock, archive_wal_mock,
get_next_batch_mock, unlink_mock, capsys):
"""
Test FileWalArchiver.archive method
"""
fxlogdb_mock = MagicMock()
backup_manager = MagicMock()
archiver = FileWalArchiver(backup_manager)
archiver.config.name = "test_server"
wal_info = WalFileInfo(name="test_wal_file")
wal_info.orig_filename = "test_wal_file"
batch = WalArchiverBatch([wal_info])
get_next_batch_mock.return_value = batch
archive_wal_mock.side_effect = DuplicateWalFile
archiver.archive(fxlogdb_mock)
out, err = capsys.readouterr()
assert ("\tError: %s is already present in server %s. "
"File moved to errors directory." %
(wal_info.name, archiver.config.name)) in out
archive_wal_mock.side_effect = MatchingDuplicateWalFile
archiver.archive(fxlogdb_mock)
unlink_mock.assert_called_with(wal_info.orig_filename)
# Test batch errors
datetime_mock.utcnow.strftime.return_value = 'test_time'
batch.errors = ['testfile_1', 'testfile_2']
archive_wal_mock.side_effect = DuplicateWalFile
archiver.archive(fxlogdb_mock)
out, err = capsys.readouterr()
assert ("Some unknown objects have been found while "
"processing xlog segments for %s. "
"Objects moved to errors directory:" %
archiver.config.name) in out
move_mock.assert_any_call(
'testfile_1',
os.path.join(archiver.config.errors_directory,
"%s.%s.unknown" % ('testfile_1', 'test_time')))
move_mock.assert_any_call(
'testfile_2',
os.path.join(archiver.config.errors_directory,
"%s.%s.unknown" % ('testfile_2', 'test_time')))