Skip to content

Commit 82101e0

Browse files
committed
tests: minor fixes
1 parent b4e707b commit 82101e0

7 files changed

+41
-25
lines changed

Diff for: tests/option_test.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,11 @@ def test_options_5(self):
127127
self.init_pb(backup_dir))
128128
self.add_instance(backup_dir, 'node', node)
129129

130-
node.start()
130+
node.slow_start()
131131

132132
# syntax error in pg_probackup.conf
133-
with open(os.path.join(backup_dir, "backups", "node", "pg_probackup.conf"), "a") as conf:
133+
conf_file = os.path.join(backup_dir, "backups", "node", "pg_probackup.conf")
134+
with open(conf_file, "a") as conf:
134135
conf.write(" = INFINITE\n")
135136
try:
136137
self.backup_node(backup_dir, 'node', node)
@@ -139,15 +140,15 @@ def test_options_5(self):
139140
repr(self.output), self.cmd))
140141
except ProbackupException as e:
141142
self.assertEqual(e.message,
142-
'ERROR: syntax error in " = INFINITE"\n',
143+
'ERROR: Syntax error in " = INFINITE"\n',
143144
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
144145

145146
self.clean_pb(backup_dir)
146147
self.init_pb(backup_dir)
147148
self.add_instance(backup_dir, 'node', node)
148149

149150
# invalid value in pg_probackup.conf
150-
with open(os.path.join(backup_dir, "backups", "node", "pg_probackup.conf"), "a") as conf:
151+
with open(conf_file, "a") as conf:
151152
conf.write("BACKUP_MODE=\n")
152153

153154
try:
@@ -157,15 +158,15 @@ def test_options_5(self):
157158
repr(self.output), self.cmd))
158159
except ProbackupException as e:
159160
self.assertEqual(e.message,
160-
'ERROR: invalid backup-mode ""\n',
161+
'ERROR: Invalid option "BACKUP_MODE" in file "{0}"\n'.format(conf_file),
161162
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
162163

163164
self.clean_pb(backup_dir)
164165
self.init_pb(backup_dir)
165166
self.add_instance(backup_dir, 'node', node)
166167

167168
# Command line parameters should override file values
168-
with open(os.path.join(backup_dir, "backups", "node", "pg_probackup.conf"), "a") as conf:
169+
with open(conf_file, "a") as conf:
169170
conf.write("retention-redundancy=1\n")
170171

171172
self.assertEqual(self.show_config(backup_dir, 'node')['retention-redundancy'], '1')
@@ -178,11 +179,11 @@ def test_options_5(self):
178179
repr(self.output), self.cmd))
179180
except ProbackupException as e:
180181
self.assertEqual(e.message,
181-
'ERROR: option system-identifier cannot be specified in command line\n',
182+
'ERROR: Option system-identifier cannot be specified in command line\n',
182183
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
183184

184185
# invalid value in pg_probackup.conf
185-
with open(os.path.join(backup_dir, "backups", "node", "pg_probackup.conf"), "a") as conf:
186+
with open(conf_file, "a") as conf:
186187
conf.write("SMOOTH_CHECKPOINT=FOO\n")
187188

188189
try:
@@ -192,16 +193,15 @@ def test_options_5(self):
192193
repr(self.output), self.cmd))
193194
except ProbackupException as e:
194195
self.assertEqual(e.message,
195-
"ERROR: option -C, --smooth-checkpoint should be a boolean: 'FOO'\n",
196+
'ERROR: Invalid option "SMOOTH_CHECKPOINT" in file "{0}"\n'.format(conf_file),
196197
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
197198

198199
self.clean_pb(backup_dir)
199200
self.init_pb(backup_dir)
200201
self.add_instance(backup_dir, 'node', node)
201202

202203
# invalid option in pg_probackup.conf
203-
pbconf_path = os.path.join(backup_dir, "backups", "node", "pg_probackup.conf")
204-
with open(pbconf_path, "a") as conf:
204+
with open(conf_file, "a") as conf:
205205
conf.write("TIMELINEID=1\n")
206206

207207
try:
@@ -211,7 +211,7 @@ def test_options_5(self):
211211
repr(self.output), self.cmd))
212212
except ProbackupException as e:
213213
self.assertEqual(e.message,
214-
'ERROR: invalid option "TIMELINEID" in file "{0}"\n'.format(pbconf_path),
214+
'ERROR: Invalid option "TIMELINEID" in file "{0}"\n'.format(conf_file),
215215
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(repr(e.message), self.cmd))
216216

217217
# Clean after yourself

Diff for: tests/ptrack_clean.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ def test_ptrack_clean_replica(self):
130130
pg_options={
131131
'ptrack_enable': 'on',
132132
'wal_level': 'replica',
133-
'max_wal_senders': '2'})
133+
'max_wal_senders': '2',
134+
'archive_timeout': '30s'})
135+
134136
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
135137
self.init_pb(backup_dir)
136138
self.add_instance(backup_dir, 'master', master)
@@ -237,7 +239,8 @@ def test_ptrack_clean_replica(self):
237239
options=[
238240
'-j10', '--master-host=localhost',
239241
'--master-db=postgres',
240-
'--master-port={0}'.format(master.port)])
242+
'--master-port={0}'.format(master.port),
243+
'--stream'])
241244
master.safe_psql('postgres', 'checkpoint')
242245

243246
for i in idx_ptrack:

Diff for: tests/ptrack_empty.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
class SimpleTest(ProbackupTest, unittest.TestCase):
1111

12-
# @unittest.skip("skip")
12+
@unittest.skip("skip")
1313
# @unittest.expectedFailure
14-
def test_ptrack_clean(self):
14+
def test_ptrack_empty(self):
1515
"""Take backups of every available types and check that PTRACK is clean"""
1616
fname = self.id().split('.')[3]
1717
node = self.make_simple_node(
@@ -87,9 +87,9 @@ def test_ptrack_clean(self):
8787
# Clean after yourself
8888
self.del_test_dir(module_name, fname)
8989

90-
# @unittest.skip("skip")
90+
@unittest.skip("skip")
9191
# @unittest.expectedFailure
92-
def test_ptrack_clean_replica(self):
92+
def test_ptrack_empty_replica(self):
9393
"""Take backups of every available types from master and check that PTRACK on replica is clean"""
9494
fname = self.id().split('.')[3]
9595
master = self.make_simple_node(

Diff for: tests/ptrack_vacuum_full.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ def test_ptrack_vacuum_full_replica(self):
9999
set_replication=True,
100100
initdb_params=['--data-checksums'],
101101
pg_options={
102-
'ptrack_enable': 'on', 'wal_level': 'replica',
103-
'max_wal_senders': '2', 'autovacuum': 'off',
104-
'checkpoint_timeout': '30s'}
102+
'ptrack_enable': 'on',
103+
'wal_level': 'replica',
104+
'max_wal_senders': '2',
105+
'autovacuum': 'off',
106+
'archive_timeout': '30s'}
105107
)
106108
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
107109
self.init_pb(backup_dir)
@@ -150,7 +152,8 @@ def test_ptrack_vacuum_full_replica(self):
150152
'-j10',
151153
'--master-host=localhost',
152154
'--master-db=postgres',
153-
'--master-port={0}'.format(master.port)
155+
'--master-port={0}'.format(master.port),
156+
'--stream'
154157
]
155158
)
156159
# TODO: check that all ptrack are nullified

Diff for: tests/ptrack_vacuum_truncate.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ def test_ptrack_vacuum_truncate_replica(self):
147147
'-j10',
148148
'--master-host=localhost',
149149
'--master-db=postgres',
150-
'--master-port={0}'.format(master.port)
150+
'--master-port={0}'.format(master.port),
151+
'--stream'
151152
]
152153
)
153154

Diff for: tests/show_test.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ def test_corrupt_control_file(self):
197197
fd.write("statuss = OK")
198198
fd.close()
199199

200-
self.assertIn('invalid option "statuss" in file'.format(file), self.show_pb(backup_dir, 'node', as_text=True))
200+
self.assertIn(
201+
'WARNING: Invalid option "statuss" in file'.format(file),
202+
self.show_pb(backup_dir, 'node', as_text=True))
201203

202204
# Clean after yourself
203-
self.del_test_dir(module_name, fname)
205+
# self.del_test_dir(module_name, fname)

Diff for: tests/validate_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -1519,10 +1519,17 @@ def test_pgpro561(self):
15191519
backup_dir, 'node1', node1,
15201520
backup_type='page', options=["--stream"])
15211521
self.restore_node(backup_dir, 'node1', data_dir=node2.data_dir)
1522+
15221523
node2.append_conf(
15231524
'postgresql.auto.conf', 'port = {0}'.format(node2.port))
1525+
node2.append_conf(
1526+
'postgresql.auto.conf', 'archive_mode = off')
15241527
node2.slow_start()
15251528

1529+
node2.append_conf(
1530+
'postgresql.auto.conf', 'archive_mode = on')
1531+
node2.restart()
1532+
15261533
timeline_node1 = node1.get_control_data()["Latest checkpoint's TimeLineID"]
15271534
timeline_node2 = node2.get_control_data()["Latest checkpoint's TimeLineID"]
15281535
self.assertEqual(

0 commit comments

Comments
 (0)