mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-01-05 13:20:31 +02:00
tests: minor fixes
This commit is contained in:
parent
9edb2e3498
commit
0deff06912
@ -58,9 +58,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
node.cleanup()
|
||||
|
||||
# Restore Database
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=["--recovery-target-action=promote"])
|
||||
self.restore_node(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
self.assertEqual(
|
||||
@ -1590,11 +1588,9 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=[
|
||||
'--recovery-target-action=promote',
|
||||
'--archive-host=localhost',
|
||||
'--archive-port=22',
|
||||
'--archive-user={0}'.format(self.user)
|
||||
])
|
||||
'--archive-user={0}'.format(self.user)])
|
||||
|
||||
with open(recovery_conf, 'r') as f:
|
||||
recovery_content = f.read()
|
||||
|
@ -20,8 +20,8 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'autovacuum': 'off'}
|
||||
)
|
||||
'autovacuum': 'off'})
|
||||
|
||||
self.init_pb(backup_dir, old_binary=True)
|
||||
self.show_pb(backup_dir)
|
||||
|
||||
@ -51,8 +51,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
node_restored.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4", "--recovery-target-action=promote"])
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
@ -76,8 +75,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
node_restored.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4", "--recovery-target-action=promote"])
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
@ -101,8 +99,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
node_restored.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4", "--recovery-target-action=promote"])
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
@ -122,8 +119,8 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'autovacuum': 'off'}
|
||||
)
|
||||
'autovacuum': 'off'})
|
||||
|
||||
self.init_pb(backup_dir, old_binary=True)
|
||||
self.show_pb(backup_dir)
|
||||
|
||||
@ -153,8 +150,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
node_restored.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4", "--recovery-target-action=promote"])
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
@ -178,8 +174,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
node_restored.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4", "--recovery-target-action=promote"])
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
@ -203,8 +198,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
node_restored.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4", "--recovery-target-action=promote"])
|
||||
backup_dir, 'node', node_restored, options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
|
@ -465,9 +465,9 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
tblspc_path_new = self.get_tblspace_path(
|
||||
restored_node, 'somedata_restored')
|
||||
|
||||
self.restore_node(backup_dir, 'node', restored_node, options=[
|
||||
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new),
|
||||
"--recovery-target-action=promote"])
|
||||
self.restore_node(
|
||||
backup_dir, 'node', restored_node, options=[
|
||||
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new)])
|
||||
|
||||
# GET PHYSICAL CONTENT FROM NODE_RESTORED
|
||||
pgdata_restored = self.pgdata_content(restored_node.data_dir)
|
||||
@ -835,8 +835,8 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
"postgres",
|
||||
"create table t_heap tablespace somedata as select i as id,"
|
||||
" md5(i::text) as text, md5(i::text)::tsvector as tsvector"
|
||||
" from generate_series(0,100) i"
|
||||
)
|
||||
" from generate_series(0,100) i")
|
||||
|
||||
# FULL backup
|
||||
self.backup_node(backup_dir, 'node', node, options=["--stream"])
|
||||
|
||||
@ -844,8 +844,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
self.create_tblspace_in_node(node, 'somedata_new')
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"alter table t_heap set tablespace somedata_new"
|
||||
)
|
||||
"alter table t_heap set tablespace somedata_new")
|
||||
|
||||
# DELTA BACKUP
|
||||
result = node.safe_psql(
|
||||
@ -853,15 +852,14 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='delta',
|
||||
options=["--stream"]
|
||||
)
|
||||
options=["--stream"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
# RESTORE
|
||||
node_restored = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node_restored')
|
||||
)
|
||||
base_dir=os.path.join(module_name, fname, 'node_restored'))
|
||||
node_restored.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
@ -875,8 +873,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
"-T", "{0}={1}".format(
|
||||
self.get_tblspace_path(node, 'somedata_new'),
|
||||
self.get_tblspace_path(node_restored, 'somedata_new')
|
||||
),
|
||||
"--recovery-target-action=promote"
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
@ -1275,7 +1272,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
content = f.read()
|
||||
|
||||
self.assertIn(
|
||||
"VERBOSE: File: {0} blknum 1, empty page".format(file),
|
||||
'VERBOSE: File: "{0}" blknum 1, empty page'.format(file),
|
||||
content)
|
||||
self.assertNotIn(
|
||||
"Skipping blknum 1 in file: {0}".format(file),
|
||||
|
@ -642,9 +642,8 @@ class MergeTest(ProbackupTest, unittest.TestCase):
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'checkpoint_timeout': '300s',
|
||||
'autovacuum': 'off'
|
||||
}
|
||||
)
|
||||
'autovacuum': 'off'})
|
||||
|
||||
node_restored = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node_restored'))
|
||||
|
||||
@ -694,8 +693,7 @@ class MergeTest(ProbackupTest, unittest.TestCase):
|
||||
backup_dir, 'node', node_restored,
|
||||
options=[
|
||||
"-j", "4",
|
||||
"-T", "{0}={1}".format(old_tablespace, new_tablespace),
|
||||
"--recovery-target-action=promote"])
|
||||
"-T", "{0}={1}".format(old_tablespace, new_tablespace)])
|
||||
|
||||
# Physical comparison
|
||||
if self.paranoia:
|
||||
@ -735,9 +733,8 @@ class MergeTest(ProbackupTest, unittest.TestCase):
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'checkpoint_timeout': '300s',
|
||||
'autovacuum': 'off'
|
||||
}
|
||||
)
|
||||
'autovacuum': 'off'})
|
||||
|
||||
node_restored = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node_restored'))
|
||||
|
||||
@ -787,8 +784,7 @@ class MergeTest(ProbackupTest, unittest.TestCase):
|
||||
backup_dir, 'node', node_restored,
|
||||
options=[
|
||||
"-j", "4",
|
||||
"-T", "{0}={1}".format(old_tablespace, new_tablespace),
|
||||
"--recovery-target-action=promote"])
|
||||
"-T", "{0}={1}".format(old_tablespace, new_tablespace)])
|
||||
|
||||
# Physical comparison
|
||||
if self.paranoia:
|
||||
|
@ -28,9 +28,8 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'checkpoint_timeout': '300s',
|
||||
'autovacuum': 'off'
|
||||
}
|
||||
)
|
||||
'autovacuum': 'off'})
|
||||
|
||||
node_restored = self.make_simple_node(
|
||||
base_dir=os.path.join(module_name, fname, 'node_restored'))
|
||||
|
||||
@ -78,8 +77,7 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
backup_dir, 'node', node_restored,
|
||||
options=[
|
||||
"-j", "4",
|
||||
"-T", "{0}={1}".format(old_tablespace, new_tablespace),
|
||||
"--recovery-target-action=promote"])
|
||||
"-T", "{0}={1}".format(old_tablespace, new_tablespace)])
|
||||
|
||||
# Physical comparison
|
||||
if self.paranoia:
|
||||
@ -302,9 +300,7 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
'shared_buffers': '1GB',
|
||||
'maintenance_work_mem': '1GB',
|
||||
'autovacuum': 'off',
|
||||
'full_page_writes': 'off'
|
||||
}
|
||||
)
|
||||
'full_page_writes': 'off'})
|
||||
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
@ -343,7 +339,6 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
backup_dir, 'node', restored_node,
|
||||
options=[
|
||||
"-j", "4",
|
||||
"--recovery-target-action=promote",
|
||||
"-T", "{0}={1}".format(tblspc_path, tblspc_path_new)])
|
||||
|
||||
# GET PHYSICAL CONTENT FROM NODE_RESTORED
|
||||
@ -958,15 +953,14 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
"Output: {0} \n CMD: {1}".format(
|
||||
self.output, self.cmd))
|
||||
except ProbackupException as e:
|
||||
self.assertTrue(
|
||||
'INFO: Wait for LSN' in e.message and
|
||||
'in archived WAL segment' in e.message and
|
||||
'Could not read WAL record at' in e.message and
|
||||
'WAL file is from different database system: WAL file database system identifier is' in e.message and
|
||||
'pg_control database system identifier is' in e.message and
|
||||
'Possible WAL corruption. Error has occured during reading WAL segment' in e.message,
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
repr(e.message), self.cmd))
|
||||
self.assertIn('INFO: Wait for WAL segment', e.message)
|
||||
self.assertIn('to be archived', e.message)
|
||||
self.assertIn('Could not read WAL record at', e.message)
|
||||
self.assertIn('WAL file is from different database system: '
|
||||
'WAL file database system identifier is', e.message)
|
||||
self.assertIn('pg_control database system identifier is', e.message)
|
||||
self.assertIn('Possible WAL corruption. Error has occured '
|
||||
'during reading WAL segment', e.message)
|
||||
|
||||
self.assertEqual(
|
||||
'ERROR',
|
||||
|
@ -47,8 +47,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
self.assertIn(
|
||||
"INFO: Restore of backup {0} completed.".format(backup_id),
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=["-j", "4", "--recovery-target-action=promote"]),
|
||||
backup_dir, 'node', node, options=["-j", "4"]),
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
repr(self.output), self.cmd))
|
||||
|
||||
@ -98,8 +97,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
self.assertIn(
|
||||
"INFO: Restore of backup {0} completed.".format(backup_id),
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=["-j", "4", "--recovery-target-action=promote"]),
|
||||
backup_dir, 'node', node, options=["-j", "4"]),
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
repr(self.output), self.cmd))
|
||||
|
||||
@ -139,8 +137,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
self.assertIn(
|
||||
"INFO: Restore of backup {0} completed.".format(backup_id),
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=["-j", "4", "--recovery-target-action=promote"]),
|
||||
backup_dir, 'node', node, options=["-j", "4"]),
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
repr(self.output), self.cmd))
|
||||
|
||||
@ -162,8 +159,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=[
|
||||
"-j", "4", "--timeline={0}".format(target_tli),
|
||||
"--recovery-target-action=promote"]
|
||||
"-j", "4", "--timeline={0}".format(target_tli)]
|
||||
),
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
repr(self.output), self.cmd))
|
||||
@ -883,8 +879,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=[
|
||||
"-T", "%s=%s" % (tblspc_path, tblspc_path_new),
|
||||
"--recovery-target-action=promote"]
|
||||
"-T", "%s=%s" % (tblspc_path, tblspc_path_new)]
|
||||
),
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
repr(self.output), self.cmd))
|
||||
@ -915,8 +910,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=[
|
||||
"-T", "%s=%s" % (tblspc_path_new, tblspc_path_page),
|
||||
"--recovery-target-action=promote"]),
|
||||
"-T", "%s=%s" % (tblspc_path_new, tblspc_path_page)]),
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
repr(self.output), self.cmd))
|
||||
|
||||
@ -991,8 +985,7 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node,
|
||||
options=[
|
||||
"-T", "%s=%s" % (tblspc_path, tblspc_path_new),
|
||||
"--recovery-target-action=promote"]),
|
||||
"-T", "%s=%s" % (tblspc_path, tblspc_path_new)]),
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
repr(self.output), self.cmd))
|
||||
node.slow_start()
|
||||
@ -1804,25 +1797,23 @@ class RestoreTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
recovery_conf = os.path.join(node.data_dir, 'recovery.conf')
|
||||
|
||||
# restore page backup
|
||||
# restore delta backup
|
||||
node.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node, options=['--immediate'])
|
||||
|
||||
# For stream backup with immediate recovery target there is no need to
|
||||
# create recovery.conf. Is it wise?
|
||||
self.assertFalse(
|
||||
os.path.isfile(recovery_conf))
|
||||
self.assertTrue(
|
||||
os.path.isfile(recovery_conf),
|
||||
"File {0} do not exists".format(recovery_conf))
|
||||
|
||||
# restore page backup
|
||||
# restore delta backup
|
||||
node.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node, options=['--recovery-target=immediate'])
|
||||
|
||||
# For stream backup with immediate recovery target there is no need to
|
||||
# create recovery.conf. Is it wise?
|
||||
self.assertFalse(
|
||||
os.path.isfile(recovery_conf))
|
||||
self.assertTrue(
|
||||
os.path.isfile(recovery_conf),
|
||||
"File {0} do not exists".format(recovery_conf))
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
@ -60,8 +60,15 @@ class RetentionTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
for wal_name in os.listdir(os.path.join(backup_dir, 'wal', 'node')):
|
||||
if not wal_name.endswith(".backup"):
|
||||
self.assertTrue(wal_name[8:] >= min_wal)
|
||||
self.assertTrue(wal_name[8:] <= max_wal)
|
||||
|
||||
if self.archive_compress:
|
||||
wal_name = wal_name[-19:]
|
||||
wal_name = wal_name[:-3]
|
||||
else:
|
||||
wal_name = wal_name[-16:]
|
||||
|
||||
self.assertTrue(wal_name >= min_wal)
|
||||
self.assertTrue(wal_name <= max_wal)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
Loading…
Reference in New Issue
Block a user