Skip to content

Commit b1f9043

Browse files
committed
tests: update tests due to recovery target action been set to "pause"
1 parent 5f62980 commit b1f9043

File tree

7 files changed

+149
-45
lines changed

7 files changed

+149
-45
lines changed

tests/archive.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def test_pgpro434_1(self):
4444
options=["--log-level-file=verbose"])
4545
node.cleanup()
4646

47-
self.restore_node(backup_dir, 'node', node)
47+
self.restore_node(
48+
backup_dir, 'node', node,
49+
options=["--recovery-target-action=promote"])
4850
node.start()
4951
while node.safe_psql(
5052
"postgres",
@@ -62,7 +64,9 @@ def test_pgpro434_1(self):
6264
node.cleanup()
6365

6466
# Restore Database
65-
self.restore_node(backup_dir, 'node', node)
67+
self.restore_node(
68+
backup_dir, 'node', node,
69+
options=["--recovery-target-action=promote"])
6670
node.start()
6771
while node.safe_psql(
6872
"postgres",

tests/compression.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,15 @@ def test_compression_wrong_algorithm(self):
297297
self.maxDiff = None
298298
fname = self.id().split('.')[3]
299299
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
300-
node = self.make_simple_node(base_dir="{0}/{1}/node".format(module_name, fname),
300+
node = self.make_simple_node(
301+
base_dir="{0}/{1}/node".format(module_name, fname),
301302
set_replication=True,
302303
initdb_params=['--data-checksums'],
303-
pg_options={'wal_level': 'replica', 'max_wal_senders': '2', 'checkpoint_timeout': '30s', 'ptrack_enable': 'on'}
304+
pg_options={
305+
'wal_level': 'replica',
306+
'max_wal_senders': '2',
307+
'checkpoint_timeout': '30s',
308+
'ptrack_enable': 'on'}
304309
)
305310

306311
self.init_pb(backup_dir)
@@ -309,14 +314,21 @@ def test_compression_wrong_algorithm(self):
309314
node.start()
310315

311316
try:
312-
self.backup_node(backup_dir, 'node', node, backup_type='full', options=['--compress-algorithm=bla-blah'])
317+
self.backup_node(
318+
backup_dir, 'node', node,
319+
backup_type='full', options=['--compress-algorithm=bla-blah'])
313320
# we should die here because exception is what we expect to happen
314-
self.assertEqual(1, 0, "Expecting Error because restore destionation is not empty.\n Output: {0} \n CMD: {1}".format(
315-
repr(self.output), self.cmd))
321+
self.assertEqual(
322+
1, 0,
323+
"Expecting Error because compress-algorithm is invalid.\n "
324+
"Output: {0} \n CMD: {1}".format(
325+
repr(self.output), self.cmd))
316326
except ProbackupException as e:
317-
self.assertEqual(e.message,
327+
self.assertEqual(
328+
e.message,
318329
'ERROR: invalid compress algorithm value "bla-blah"\n',
319-
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
330+
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
331+
repr(e.message), self.cmd))
320332

321333
# Clean after yourself
322334
self.del_test_dir(module_name, fname)

tests/delta.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ def test_delta_multiple_segments(self):
487487
restored_node, 'somedata_restored')
488488

489489
self.restore_node(backup_dir, 'node', restored_node, options=[
490-
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new)])
490+
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new),
491+
"--recovery-target-action=promote"])
491492

492493
# GET PHYSICAL CONTENT FROM NODE_RESTORED
493494
pgdata_restored = self.pgdata_content(restored_node.data_dir)
@@ -911,7 +912,8 @@ def test_alter_table_set_tablespace_delta(self):
911912
"-T", "{0}={1}".format(
912913
self.get_tblspace_path(node, 'somedata_new'),
913914
self.get_tblspace_path(node_restored, 'somedata_new')
914-
)
915+
),
916+
"--recovery-target-action=promote"
915917
]
916918
)
917919

tests/expected/option_help.out

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,34 @@ pg_probackup - utility to manage backup/recovery of PostgreSQL database.
2929
pg_probackup backup -B backup-path -b backup-mode --instance=instance_name
3030
[-C] [--stream [-S slot-name]] [--backup-pg-log]
3131
[-j num-threads] [--archive-timeout=archive-timeout]
32+
[--progress]
33+
[--log-level-console=log-level-console]
34+
[--log-level-file=log-level-file]
35+
[--log-filename=log-filename]
36+
[--error-log-filename=error-log-filename]
37+
[--log-directory=log-directory]
38+
[--log-rotation-size=log-rotation-size]
39+
[--log-rotation-age=log-rotation-age]
40+
[--delete-expired] [--delete-wal]
41+
[--retention-redundancy=retention-redundancy]
42+
[--retention-window=retention-window]
3243
[--compress]
3344
[--compress-algorithm=compress-algorithm]
3445
[--compress-level=compress-level]
35-
[--progress] [--delete-expired]
3646
[-d dbname] [-h host] [-p port] [-U username]
47+
[-w --no-password] [-W --password]
3748
[--master-db=db_name] [--master-host=host_name]
3849
[--master-port=port] [--master-user=user_name]
3950
[--replica-timeout=timeout]
4051

52+
4153
pg_probackup restore -B backup-dir --instance=instance_name
4254
[-D pgdata-dir] [-i backup-id] [--progress]
4355
[--time=time|--xid=xid [--inclusive=boolean]]
4456
[--timeline=timeline] [-T OLDDIR=NEWDIR]
57+
[--immediate] [--recovery-target-name=target-name]
58+
[--recovery-target-action=pause|promote|shutdown]
59+
[--restore-as-replica]
4560

4661
pg_probackup validate -B backup-dir [--instance=instance_name]
4762
[-i backup-id] [--progress]

tests/page.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ def test_page_vacuum_truncate(self):
8484

8585
self.restore_node(
8686
backup_dir, 'node', node_restored,
87-
options=["-j", "4", "-T", "{0}={1}".format(
88-
old_tablespace, new_tablespace)]
87+
options=[
88+
"-j", "4",
89+
"-T", "{0}={1}".format(old_tablespace, new_tablespace),
90+
"--recovery-target-action=promote"]
8991
)
9092

9193
# Physical comparison
@@ -331,8 +333,12 @@ def test_page_multiple_segments(self):
331333
tblspc_path_new = self.get_tblspace_path(
332334
restored_node, 'somedata_restored')
333335

334-
self.restore_node(backup_dir, 'node', restored_node, options=[
335-
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new)])
336+
self.restore_node(
337+
backup_dir, 'node', restored_node,
338+
options=[
339+
"-j", "4",
340+
"--recovery-target-action=promote",
341+
"-T", "{0}={1}".format(tblspc_path, tblspc_path_new)])
336342

337343
# GET PHYSICAL CONTENT FROM NODE_RESTORED
338344
pgdata_restored = self.pgdata_content(restored_node.data_dir)

tests/ptrack.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ def test_ptrack_stream(self):
759759
self.restore_node(
760760
backup_dir, 'node', node,
761761
backup_id=full_backup_id,
762-
options=["-j", "4"]
762+
options=["-j", "4", "--recovery-target-action=promote"]
763763
),
764764
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
765765
repr(self.output), self.cmd)
@@ -778,7 +778,7 @@ def test_ptrack_stream(self):
778778
self.restore_node(
779779
backup_dir, 'node', node,
780780
backup_id=ptrack_backup_id,
781-
options=["-j", "4"]
781+
options=["-j", "4", "--recovery-target-action=promote"]
782782
),
783783
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
784784
repr(self.output), self.cmd)
@@ -861,7 +861,9 @@ def test_ptrack_archive(self):
861861
self.restore_node(
862862
backup_dir, 'node', node,
863863
backup_id=full_backup_id,
864-
options=["-j", "4", "--time={0}".format(full_target_time)]
864+
options=[
865+
"-j", "4", "--recovery-target-action=promote",
866+
"--time={0}".format(full_target_time)]
865867
),
866868
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
867869
repr(self.output), self.cmd)
@@ -880,7 +882,10 @@ def test_ptrack_archive(self):
880882
self.restore_node(
881883
backup_dir, 'node', node,
882884
backup_id=ptrack_backup_id,
883-
options=["-j", "4", "--time={0}".format(ptrack_target_time)]
885+
options=[
886+
"-j", "4",
887+
"--time={0}".format(ptrack_target_time),
888+
"--recovery-target-action=promote"]
884889
),
885890
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
886891
repr(self.output), self.cmd)
@@ -1320,7 +1325,8 @@ def test_alter_table_set_tablespace_ptrack(self):
13201325
"-T", "{0}={1}".format(
13211326
self.get_tblspace_path(node, 'somedata_new'),
13221327
self.get_tblspace_path(node_restored, 'somedata_new')
1323-
)
1328+
),
1329+
"--recovery-target-action=promote"
13241330
]
13251331
)
13261332

@@ -1549,7 +1555,8 @@ def test_ptrack_alter_tablespace(self):
15491555
tblspc_path_new = self.get_tblspace_path(
15501556
restored_node, 'somedata_restored')
15511557
self.restore_node(backup_dir, 'node', restored_node, options=[
1552-
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new)])
1558+
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new),
1559+
"--recovery-target-action=promote"])
15531560

15541561
# GET PHYSICAL CONTENT FROM RESTORED NODE and COMPARE PHYSICAL CONTENT
15551562
if self.paranoia:
@@ -1585,7 +1592,8 @@ def test_ptrack_alter_tablespace(self):
15851592

15861593
# Restore second ptrack backup and check table consistency
15871594
self.restore_node(backup_dir, 'node', restored_node, options=[
1588-
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new)])
1595+
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new),
1596+
"--recovery-target-action=promote"])
15891597

15901598
# GET PHYSICAL CONTENT FROM RESTORED NODE and COMPARE PHYSICAL CONTENT
15911599
if self.paranoia:
@@ -1682,7 +1690,8 @@ def test_ptrack_multiple_segments(self):
16821690
)
16831691

16841692
self.restore_node(backup_dir, 'node', restored_node, options=[
1685-
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new)])
1693+
"-j", "4", "-T", "{0}={1}".format(tblspc_path, tblspc_path_new),
1694+
"--recovery-target-action=promote"])
16861695

16871696
# GET PHYSICAL CONTENT FROM NODE_RESTORED
16881697
if self.paranoia:

0 commit comments

Comments
 (0)