From 2a095952c312284c9ccf4b24e833d4970b2bb212 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Sun, 11 May 2025 20:44:52 +0300 Subject: [PATCH 1/3] [#258] Declaration of ProbackupTest::pg_node is corrected ProbackupTest::pg_node is testgres.NodeApp, not testgres.PostgresNode. Asserts are added. --- .../pg_probackup2/pg_probackup2/tests/test_basic.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py b/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py index f22a62bf..bf3671ae 100644 --- a/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py +++ b/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py @@ -11,7 +11,7 @@ class ProbackupTest: - pg_node: testgres.PostgresNode + pg_node: testgres.NodeApp @staticmethod def probackup_is_available() -> bool: @@ -75,6 +75,11 @@ def helper__build_backup_dir(self, backup='backup'): @pytest.mark.skipif(not ProbackupTest.probackup_is_available(), reason="Check that PGPROBACKUPBIN is defined and is valid.") class TestBasic(ProbackupTest): def test_full_backup(self): + assert self.pg_node is not None + assert type(self.pg_node) == testgres.NodeApp # noqa: E721 + assert self.pb is not None + assert type(self.pb) == ProbackupApp # noqa: E721 + # Setting up a simple test node node = self.pg_node.make_simple('node', pg_options={"fsync": "off", "synchronous_commit": "off"}) From 753f03a2fb147be98a2307fb79fd1e2a59a5e926 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Sun, 11 May 2025 20:55:26 +0300 Subject: [PATCH 2/3] [#258] TestBasic::test_full_backup cleans node object Node cleanup is added. TODO: we should to stop node only and cleanup his data in conftest. --- Asserts are added. --- .../pg_probackup2/tests/test_basic.py | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py b/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py index bf3671ae..8d734f7b 100644 --- a/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py +++ b/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py @@ -83,18 +83,22 @@ def test_full_backup(self): # Setting up a simple test node node = self.pg_node.make_simple('node', pg_options={"fsync": "off", "synchronous_commit": "off"}) - # Initialize and configure Probackup - self.pb.init() - self.pb.add_instance('node', node) - self.pb.set_archiving('node', node) + assert node is not None + assert type(node) == testgres.PostgresNode - # Start the node and initialize pgbench - node.slow_start() - node.pgbench_init(scale=100, no_vacuum=True) + with node: + # Initialize and configure Probackup + self.pb.init() + self.pb.add_instance('node', node) + self.pb.set_archiving('node', node) - # Perform backup and validation - backup_id = self.pb.backup_node('node', node) - out = self.pb.validate('node', backup_id) + # Start the node and initialize pgbench + node.slow_start() + node.pgbench_init(scale=100, no_vacuum=True) - # Check if the backup is valid - assert f"INFO: Backup {backup_id} is valid" in out + # Perform backup and validation + backup_id = self.pb.backup_node('node', node) + out = self.pb.validate('node', backup_id) + + # Check if the backup is valid + assert f"INFO: Backup {backup_id} is valid" in out From 0685eda8cb3a1721c2dff0963fba538ce478b391 Mon Sep 17 00:00:00 2001 From: "d.kovalenko" Date: Sun, 11 May 2025 21:19:55 +0300 Subject: [PATCH 3/3] [FIX] flake8 (E721) --- .../plugins/pg_probackup2/pg_probackup2/tests/test_basic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py b/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py index 8d734f7b..2540ddb0 100644 --- a/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py +++ b/testgres/plugins/pg_probackup2/pg_probackup2/tests/test_basic.py @@ -84,7 +84,7 @@ def test_full_backup(self): node = self.pg_node.make_simple('node', pg_options={"fsync": "off", "synchronous_commit": "off"}) assert node is not None - assert type(node) == testgres.PostgresNode + assert type(node) == testgres.PostgresNode # noqa: E721 with node: # Initialize and configure Probackup