From d9cb01a167d38bfc17ca39cde43adf6104aa364e Mon Sep 17 00:00:00 2001 From: Grigory Smolkin Date: Fri, 1 Mar 2019 16:29:47 +0300 Subject: [PATCH] tests: added backup_test.BackupTest.test_persistent_slot_for_stream_backup() and backup_test.BackupTest.test_temp_slot_for_stream_backup() --- tests/archive.py | 6 ++-- tests/backup_test.py | 71 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 3 deletions(-) diff --git a/tests/archive.py b/tests/archive.py index 0881a050..51e46ea0 100644 --- a/tests/archive.py +++ b/tests/archive.py @@ -728,8 +728,8 @@ class ArchiveTest(ProbackupTest, unittest.TestCase): initdb_params=['--data-checksums'], pg_options={ 'max_wal_senders': '2', - 'checkpoint_timeout': '30s'} - ) + 'checkpoint_timeout': '30s'}) + self.init_pb(backup_dir) self.add_instance(backup_dir, 'node', node) node.slow_start() @@ -808,7 +808,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase): self.add_instance(backup_dir, 'node', node) node.slow_start() if self.get_version(node) < self.version_to_num('10.0'): - return unittest.skip('You need PostgreSQL 10 for this test') + return unittest.skip('You need PostgreSQL >= 10 for this test') else: pg_receivexlog_path = self.get_bin_path('pg_receivewal') diff --git a/tests/backup_test.py b/tests/backup_test.py index 740f08d3..9570b3d3 100644 --- a/tests/backup_test.py +++ b/tests/backup_test.py @@ -938,3 +938,74 @@ class BackupTest(ProbackupTest, unittest.TestCase): # Clean after yourself self.del_test_dir(module_name, fname) + + # @unittest.skip("skip") + def test_persistent_slot_for_stream_backup(self): + """""" + fname = self.id().split('.')[3] + backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') + node = self.make_simple_node( + base_dir=os.path.join(module_name, fname, 'node'), + set_replication=True, + initdb_params=['--data-checksums'], + pg_options={ + 'wal_level': 'replica', + 'max_wal_size': '40MB'}) + + self.init_pb(backup_dir) + self.add_instance(backup_dir, 'node', node) + self.set_archiving(backup_dir, 'node', node) + node.slow_start() + + node.safe_psql( + "postgres", + "SELECT pg_create_physical_replication_slot('slot_1')") + + # FULL backup + self.backup_node( + backup_dir, 'node', node, + options=['--stream', '--slot=slot_1']) + + # FULL backup + self.backup_node( + backup_dir, 'node', node, + options=['--stream', '--slot=slot_1']) + + # Clean after yourself + self.del_test_dir(module_name, fname) + + # @unittest.skip("skip") + def test_temp_slot_for_stream_backup(self): + """""" + fname = self.id().split('.')[3] + backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') + node = self.make_simple_node( + base_dir=os.path.join(module_name, fname, 'node'), + set_replication=True, + initdb_params=['--data-checksums'], + pg_options={ + 'wal_level': 'replica', + 'max_wal_size': '40MB'}) + + self.init_pb(backup_dir) + self.add_instance(backup_dir, 'node', node) + self.set_archiving(backup_dir, 'node', node) + node.slow_start() + + if self.get_version(node) < self.version_to_num('10.0'): + return unittest.skip('You need PostgreSQL >= 10 for this test') + else: + pg_receivexlog_path = self.get_bin_path('pg_receivewal') + + # FULL backup + self.backup_node( + backup_dir, 'node', node, + options=['--stream', '--slot=slot_1', '--temp-slot']) + + # FULL backup + self.backup_node( + backup_dir, 'node', node, + options=['--stream', '--temp-slot']) + + # Clean after yourself + self.del_test_dir(module_name, fname)