Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 151145d

Browse files
committed
tests: compatibility test added
1 parent 85bc40a commit 151145d

File tree

2 files changed

+211
-6
lines changed

2 files changed

+211
-6
lines changed

tests/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def load_tests(loader, tests, pattern):
2121
# suite.addTests(loader.loadTestsFromModule(cfs_validate_backup))
2222
# suite.addTests(loader.loadTestsFromModule(logging))
2323
suite.addTests(loader.loadTestsFromModule(compression))
24+
suite.addTests(loader.loadTestsFromModule(compatibility))
2425
suite.addTests(loader.loadTestsFromModule(delete_test))
2526
suite.addTests(loader.loadTestsFromModule(delta))
2627
suite.addTests(loader.loadTestsFromModule(exclude))

tests/compatibility.py

+210-6
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
1111

1212
# @unittest.expectedFailure
1313
# @unittest.skip("skip")
14-
def test_show_previous_version_catalog(self):
14+
def test_backward_compatibility_page(self):
1515
"""Description in jira issue PGPRO-434"""
1616
fname = self.id().split('.')[3]
1717
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -21,7 +21,7 @@ def test_show_previous_version_catalog(self):
2121
initdb_params=['--data-checksums'],
2222
pg_options={
2323
'max_wal_senders': '2',
24-
'checkpoint_timeout': '30s'}
24+
'autovacuum': 'off'}
2525
)
2626
self.init_pb(backup_dir, old_binary=True)
2727
self.show_pb(backup_dir)
@@ -59,13 +59,14 @@ def test_show_previous_version_catalog(self):
5959
pgdata_restored = self.pgdata_content(node_restored.data_dir)
6060
self.compare_pgdata(pgdata, pgdata_restored)
6161

62-
# Incremental BACKUP with old binary
62+
# Page BACKUP with old binary
6363
pgbench = node.pgbench(
6464
stdout=subprocess.PIPE,
6565
stderr=subprocess.STDOUT,
66-
options=["-c", "4", "-T", "10"]
66+
options=["-c", "4", "-T", "20"]
6767
)
6868
pgbench.wait()
69+
pgbench.stdout.close()
6970

7071
self.backup_node(
7172
backup_dir, 'node', node, backup_type='page',
@@ -83,13 +84,14 @@ def test_show_previous_version_catalog(self):
8384
pgdata_restored = self.pgdata_content(node_restored.data_dir)
8485
self.compare_pgdata(pgdata, pgdata_restored)
8586

86-
# Incremental BACKUP with new binary
87+
# Page BACKUP with new binary
8788
pgbench = node.pgbench(
8889
stdout=subprocess.PIPE,
8990
stderr=subprocess.STDOUT,
90-
options=["-c", "4", "-T", "10"]
91+
options=["-c", "4", "-T", "20"]
9192
)
9293
pgbench.wait()
94+
pgbench.stdout.close()
9395

9496
self.backup_node(
9597
backup_dir, 'node', node, backup_type='page',
@@ -107,3 +109,205 @@ def test_show_previous_version_catalog(self):
107109
if self.paranoia:
108110
pgdata_restored = self.pgdata_content(node_restored.data_dir)
109111
self.compare_pgdata(pgdata, pgdata_restored)
112+
113+
# @unittest.expectedFailure
114+
# @unittest.skip("skip")
115+
def test_backward_compatibility_delta(self):
116+
"""Description in jira issue PGPRO-434"""
117+
fname = self.id().split('.')[3]
118+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
119+
node = self.make_simple_node(
120+
base_dir="{0}/{1}/node".format(module_name, fname),
121+
set_replication=True,
122+
initdb_params=['--data-checksums'],
123+
pg_options={
124+
'max_wal_senders': '2',
125+
'autovacuum': 'off'}
126+
)
127+
self.init_pb(backup_dir, old_binary=True)
128+
self.show_pb(backup_dir)
129+
130+
self.add_instance(backup_dir, 'node', node, old_binary=True)
131+
self.show_pb(backup_dir)
132+
133+
self.set_archiving(backup_dir, 'node', node, old_binary=True)
134+
node.slow_start()
135+
136+
node.pgbench_init(scale=10)
137+
138+
# FULL backup with old binary
139+
self.backup_node(
140+
backup_dir, 'node', node, old_binary=True)
141+
142+
if self.paranoia:
143+
pgdata = self.pgdata_content(node.data_dir)
144+
145+
self.show_pb(backup_dir)
146+
147+
self.validate_pb(backup_dir)
148+
149+
# RESTORE old FULL with new binary
150+
node_restored = self.make_simple_node(
151+
base_dir="{0}/{1}/node_restored".format(module_name, fname))
152+
153+
node_restored.cleanup()
154+
155+
self.restore_node(
156+
backup_dir, 'node', node_restored,
157+
options=["-j", "4", "--recovery-target-action=promote"])
158+
159+
if self.paranoia:
160+
pgdata_restored = self.pgdata_content(node_restored.data_dir)
161+
self.compare_pgdata(pgdata, pgdata_restored)
162+
163+
# Delta BACKUP with old binary
164+
pgbench = node.pgbench(
165+
stdout=subprocess.PIPE,
166+
stderr=subprocess.STDOUT,
167+
options=["-c", "4", "-T", "20"]
168+
)
169+
pgbench.wait()
170+
pgbench.stdout.close()
171+
172+
self.backup_node(
173+
backup_dir, 'node', node, backup_type='delta',
174+
old_binary=True)
175+
176+
if self.paranoia:
177+
pgdata = self.pgdata_content(node.data_dir)
178+
179+
node_restored.cleanup()
180+
self.restore_node(
181+
backup_dir, 'node', node_restored,
182+
options=["-j", "4", "--recovery-target-action=promote"])
183+
184+
if self.paranoia:
185+
pgdata_restored = self.pgdata_content(node_restored.data_dir)
186+
self.compare_pgdata(pgdata, pgdata_restored)
187+
188+
# Delta BACKUP with new binary
189+
pgbench = node.pgbench(
190+
stdout=subprocess.PIPE,
191+
stderr=subprocess.STDOUT,
192+
options=["-c", "4", "-T", "20"]
193+
)
194+
pgbench.wait()
195+
pgbench.stdout.close()
196+
197+
self.backup_node(
198+
backup_dir, 'node', node, backup_type='delta',
199+
options=['--log-level-file=verbose'])
200+
201+
if self.paranoia:
202+
pgdata = self.pgdata_content(node.data_dir)
203+
204+
node_restored.cleanup()
205+
206+
self.restore_node(
207+
backup_dir, 'node', node_restored,
208+
options=["-j", "4", "--recovery-target-action=promote"])
209+
210+
if self.paranoia:
211+
pgdata_restored = self.pgdata_content(node_restored.data_dir)
212+
self.compare_pgdata(pgdata, pgdata_restored)
213+
214+
# @unittest.expectedFailure
215+
# @unittest.skip("skip")
216+
def test_backward_compatibility_ptrack(self):
217+
"""Description in jira issue PGPRO-434"""
218+
fname = self.id().split('.')[3]
219+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
220+
node = self.make_simple_node(
221+
base_dir="{0}/{1}/node".format(module_name, fname),
222+
set_replication=True,
223+
initdb_params=['--data-checksums'],
224+
pg_options={
225+
'max_wal_senders': '2',
226+
'autovacuum': 'off'}
227+
)
228+
self.init_pb(backup_dir, old_binary=True)
229+
self.show_pb(backup_dir)
230+
231+
self.add_instance(backup_dir, 'node', node, old_binary=True)
232+
self.show_pb(backup_dir)
233+
234+
self.set_archiving(backup_dir, 'node', node, old_binary=True)
235+
node.slow_start()
236+
237+
node.pgbench_init(scale=10)
238+
239+
# FULL backup with old binary
240+
self.backup_node(
241+
backup_dir, 'node', node, old_binary=True)
242+
243+
if self.paranoia:
244+
pgdata = self.pgdata_content(node.data_dir)
245+
246+
self.show_pb(backup_dir)
247+
248+
self.validate_pb(backup_dir)
249+
250+
# RESTORE old FULL with new binary
251+
node_restored = self.make_simple_node(
252+
base_dir="{0}/{1}/node_restored".format(module_name, fname))
253+
254+
node_restored.cleanup()
255+
256+
self.restore_node(
257+
backup_dir, 'node', node_restored,
258+
options=["-j", "4", "--recovery-target-action=promote"])
259+
260+
if self.paranoia:
261+
pgdata_restored = self.pgdata_content(node_restored.data_dir)
262+
self.compare_pgdata(pgdata, pgdata_restored)
263+
264+
# Delta BACKUP with old binary
265+
pgbench = node.pgbench(
266+
stdout=subprocess.PIPE,
267+
stderr=subprocess.STDOUT,
268+
options=["-c", "4", "-T", "20"]
269+
)
270+
pgbench.wait()
271+
pgbench.stdout.close()
272+
273+
self.backup_node(
274+
backup_dir, 'node', node, backup_type='delta',
275+
old_binary=True)
276+
277+
if self.paranoia:
278+
pgdata = self.pgdata_content(node.data_dir)
279+
280+
node_restored.cleanup()
281+
self.restore_node(
282+
backup_dir, 'node', node_restored,
283+
options=["-j", "4", "--recovery-target-action=promote"])
284+
285+
if self.paranoia:
286+
pgdata_restored = self.pgdata_content(node_restored.data_dir)
287+
self.compare_pgdata(pgdata, pgdata_restored)
288+
289+
# Delta BACKUP with new binary
290+
pgbench = node.pgbench(
291+
stdout=subprocess.PIPE,
292+
stderr=subprocess.STDOUT,
293+
options=["-c", "4", "-T", "20"]
294+
)
295+
pgbench.wait()
296+
pgbench.stdout.close()
297+
298+
self.backup_node(
299+
backup_dir, 'node', node, backup_type='delta',
300+
options=['--log-level-file=verbose'])
301+
302+
if self.paranoia:
303+
pgdata = self.pgdata_content(node.data_dir)
304+
305+
node_restored.cleanup()
306+
307+
self.restore_node(
308+
backup_dir, 'node', node_restored,
309+
options=["-j", "4", "--recovery-target-action=promote"])
310+
311+
if self.paranoia:
312+
pgdata_restored = self.pgdata_content(node_restored.data_dir)
313+
self.compare_pgdata(pgdata, pgdata_restored)

0 commit comments

Comments
 (0)