Skip to content

Commit 59b5145

Browse files
committed
tests: new page test added, minor fixes for ptrack tests
1 parent 0d08027 commit 59b5145

File tree

3 files changed

+87
-5
lines changed

3 files changed

+87
-5
lines changed

tests/page.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,3 +321,85 @@ def test_page_multiple_segments(self):
321321

322322
# Clean after yourself
323323
self.del_test_dir(module_name, fname)
324+
325+
# @unittest.skip("skip")
326+
def test_page_delete(self):
327+
"""Make node, create tablespace with table, take full backup,
328+
alter tablespace location, take page backup, restore database."""
329+
fname = self.id().split('.')[3]
330+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
331+
node = self.make_simple_node(
332+
base_dir="{0}/{1}/node".format(module_name, fname),
333+
set_replication=True, initdb_params=['--data-checksums'],
334+
pg_options={
335+
'wal_level': 'replica',
336+
'max_wal_senders': '2',
337+
'checkpoint_timeout': '30s',
338+
'autovacuum': 'off'
339+
}
340+
)
341+
342+
self.init_pb(backup_dir)
343+
self.add_instance(backup_dir, 'node', node)
344+
self.set_archiving(backup_dir, 'node', node)
345+
node.start()
346+
347+
self.create_tblspace_in_node(node, 'somedata')
348+
# FULL backup
349+
self.backup_node(backup_dir, 'node', node, options=["--stream"])
350+
351+
node.safe_psql(
352+
"postgres",
353+
"create table t_heap tablespace somedata as select i as id,"
354+
" md5(i::text) as text, md5(i::text)::tsvector as tsvector"
355+
" from generate_series(0,100) i"
356+
)
357+
358+
node.safe_psql(
359+
"postgres",
360+
"delete from t_heap"
361+
)
362+
363+
node.safe_psql(
364+
"postgres",
365+
"vacuum t_heap"
366+
)
367+
368+
# PAGE BACKUP
369+
self.backup_node(
370+
backup_dir, 'node', node,
371+
backup_type='page',
372+
options=["--stream"]
373+
)
374+
if self.paranoia:
375+
pgdata = self.pgdata_content(node.data_dir)
376+
377+
# RESTORE
378+
node_restored = self.make_simple_node(
379+
base_dir="{0}/{1}/node_restored".format(module_name, fname)
380+
)
381+
node_restored.cleanup()
382+
383+
self.restore_node(
384+
backup_dir, 'node', node_restored,
385+
options=[
386+
"-j", "4",
387+
"-T", "{0}={1}".format(
388+
self.get_tblspace_path(node, 'somedata'),
389+
self.get_tblspace_path(node_restored, 'somedata')
390+
)
391+
]
392+
)
393+
394+
# GET RESTORED PGDATA AND COMPARE
395+
if self.paranoia:
396+
pgdata_restored = self.pgdata_content(node_restored.data_dir)
397+
self.compare_pgdata(pgdata, pgdata_restored)
398+
399+
# START RESTORED NODE
400+
node_restored.append_conf(
401+
'postgresql.auto.conf', 'port = {0}'.format(node_restored.port))
402+
node_restored.start()
403+
404+
# Clean after yourself
405+
self.del_test_dir(module_name, fname)

tests/ptrack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def test_ptrack_vacuum_full(self):
277277
node_restored.start()
278278

279279
# Clean after yourself
280-
# self.del_test_dir(module_name, fname)
280+
self.del_test_dir(module_name, fname)
281281

282282
# @unittest.skip("skip")
283283
def test_ptrack_vacuum_truncate(self):

tests/ptrack_clean.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def test_ptrack_clean(self):
7878
node.safe_psql('postgres', 'vacuum t_heap')
7979

8080
# Take PAGE backup to clean every ptrack
81-
self.backup_node(backup_dir, 'node', node, backup_type='page', options=['-j100'])
81+
self.backup_node(backup_dir, 'node', node, backup_type='page', options=['-j10'])
8282
node.safe_psql('postgres', 'checkpoint')
8383

8484
for i in idx_ptrack:
@@ -131,7 +131,7 @@ def test_ptrack_clean_replica(self):
131131
i, idx_ptrack[i]['relation'], idx_ptrack[i]['type'], idx_ptrack[i]['column']))
132132

133133
# Take FULL backup to clean every ptrack
134-
self.backup_node(backup_dir, 'replica', replica, options=['-j100', '--stream',
134+
self.backup_node(backup_dir, 'replica', replica, options=['-j10', '--stream',
135135
'--master-host=localhost', '--master-db=postgres', '--master-port={0}'.format(master.port)])
136136
master.safe_psql('postgres', 'checkpoint')
137137

@@ -150,7 +150,7 @@ def test_ptrack_clean_replica(self):
150150
master.safe_psql('postgres', 'vacuum t_heap')
151151

152152
# Take PTRACK backup to clean every ptrack
153-
backup_id = self.backup_node(backup_dir, 'replica', replica, backup_type='ptrack', options=['-j100', '--stream',
153+
backup_id = self.backup_node(backup_dir, 'replica', replica, backup_type='ptrack', options=['-j10', '--stream',
154154
'--master-host=localhost', '--master-db=postgres', '--master-port={0}'.format(master.port)])
155155
master.safe_psql('postgres', 'checkpoint')
156156

@@ -171,7 +171,7 @@ def test_ptrack_clean_replica(self):
171171
master.safe_psql('postgres', 'checkpoint')
172172

173173
# Take PAGE backup to clean every ptrack
174-
self.backup_node(backup_dir, 'replica', replica, backup_type='page', options=['-j100',
174+
self.backup_node(backup_dir, 'replica', replica, backup_type='page', options=['-j10',
175175
'--master-host=localhost', '--master-db=postgres', '--master-port={0}'.format(master.port)])
176176
master.safe_psql('postgres', 'checkpoint')
177177

0 commit comments

Comments
 (0)