From 59b5145b1f7fc002a44c9f98c5ecf6afc32aa221 Mon Sep 17 00:00:00 2001 From: Grigory Smolkin Date: Tue, 6 Mar 2018 17:10:55 +0300 Subject: [PATCH] tests: new page test added, minor fixes for ptrack tests --- tests/page.py | 82 +++++++++++++++++++++++++++++++++++++++++++ tests/ptrack.py | 2 +- tests/ptrack_clean.py | 8 ++--- 3 files changed, 87 insertions(+), 5 deletions(-) diff --git a/tests/page.py b/tests/page.py index d4ff4dd1..44c87ea0 100644 --- a/tests/page.py +++ b/tests/page.py @@ -321,3 +321,85 @@ class PageBackupTest(ProbackupTest, unittest.TestCase): # Clean after yourself self.del_test_dir(module_name, fname) + + # @unittest.skip("skip") + def test_page_delete(self): + """Make node, create tablespace with table, take full backup, + alter tablespace location, take page backup, restore database.""" + fname = self.id().split('.')[3] + backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') + node = self.make_simple_node( + base_dir="{0}/{1}/node".format(module_name, fname), + set_replication=True, initdb_params=['--data-checksums'], + pg_options={ + 'wal_level': 'replica', + 'max_wal_senders': '2', + 'checkpoint_timeout': '30s', + 'autovacuum': 'off' + } + ) + + self.init_pb(backup_dir) + self.add_instance(backup_dir, 'node', node) + self.set_archiving(backup_dir, 'node', node) + node.start() + + self.create_tblspace_in_node(node, 'somedata') + # FULL backup + self.backup_node(backup_dir, 'node', node, options=["--stream"]) + + node.safe_psql( + "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" + ) + + node.safe_psql( + "postgres", + "delete from t_heap" + ) + + node.safe_psql( + "postgres", + "vacuum t_heap" + ) + + # PAGE BACKUP + self.backup_node( + backup_dir, 'node', node, + backup_type='page', + options=["--stream"] + ) + if self.paranoia: + pgdata = self.pgdata_content(node.data_dir) + + # RESTORE + node_restored = self.make_simple_node( + base_dir="{0}/{1}/node_restored".format(module_name, fname) + ) + node_restored.cleanup() + + self.restore_node( + backup_dir, 'node', node_restored, + options=[ + "-j", "4", + "-T", "{0}={1}".format( + self.get_tblspace_path(node, 'somedata'), + self.get_tblspace_path(node_restored, 'somedata') + ) + ] + ) + + # GET RESTORED PGDATA AND COMPARE + if self.paranoia: + pgdata_restored = self.pgdata_content(node_restored.data_dir) + self.compare_pgdata(pgdata, pgdata_restored) + + # START RESTORED NODE + node_restored.append_conf( + 'postgresql.auto.conf', 'port = {0}'.format(node_restored.port)) + node_restored.start() + + # Clean after yourself + self.del_test_dir(module_name, fname) diff --git a/tests/ptrack.py b/tests/ptrack.py index 593fd2fc..16f4ee17 100644 --- a/tests/ptrack.py +++ b/tests/ptrack.py @@ -277,7 +277,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase): node_restored.start() # Clean after yourself - # self.del_test_dir(module_name, fname) + self.del_test_dir(module_name, fname) # @unittest.skip("skip") def test_ptrack_vacuum_truncate(self): diff --git a/tests/ptrack_clean.py b/tests/ptrack_clean.py index 72d4c2a3..25b4ee19 100644 --- a/tests/ptrack_clean.py +++ b/tests/ptrack_clean.py @@ -78,7 +78,7 @@ class SimpleTest(ProbackupTest, unittest.TestCase): node.safe_psql('postgres', 'vacuum t_heap') # Take PAGE backup to clean every ptrack - self.backup_node(backup_dir, 'node', node, backup_type='page', options=['-j100']) + self.backup_node(backup_dir, 'node', node, backup_type='page', options=['-j10']) node.safe_psql('postgres', 'checkpoint') for i in idx_ptrack: @@ -131,7 +131,7 @@ class SimpleTest(ProbackupTest, unittest.TestCase): i, idx_ptrack[i]['relation'], idx_ptrack[i]['type'], idx_ptrack[i]['column'])) # Take FULL backup to clean every ptrack - self.backup_node(backup_dir, 'replica', replica, options=['-j100', '--stream', + self.backup_node(backup_dir, 'replica', replica, options=['-j10', '--stream', '--master-host=localhost', '--master-db=postgres', '--master-port={0}'.format(master.port)]) master.safe_psql('postgres', 'checkpoint') @@ -150,7 +150,7 @@ class SimpleTest(ProbackupTest, unittest.TestCase): master.safe_psql('postgres', 'vacuum t_heap') # Take PTRACK backup to clean every ptrack - backup_id = self.backup_node(backup_dir, 'replica', replica, backup_type='ptrack', options=['-j100', '--stream', + backup_id = self.backup_node(backup_dir, 'replica', replica, backup_type='ptrack', options=['-j10', '--stream', '--master-host=localhost', '--master-db=postgres', '--master-port={0}'.format(master.port)]) master.safe_psql('postgres', 'checkpoint') @@ -171,7 +171,7 @@ class SimpleTest(ProbackupTest, unittest.TestCase): master.safe_psql('postgres', 'checkpoint') # Take PAGE backup to clean every ptrack - self.backup_node(backup_dir, 'replica', replica, backup_type='page', options=['-j100', + self.backup_node(backup_dir, 'replica', replica, backup_type='page', options=['-j10', '--master-host=localhost', '--master-db=postgres', '--master-port={0}'.format(master.port)]) master.safe_psql('postgres', 'checkpoint')