testgres-pg-probackup2 0.3.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (15) hide show
  1. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/PKG-INFO +1 -1
  2. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/pg_probackup2/app.py +22 -6
  3. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/setup.py +1 -1
  4. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/testgres_pg_probackup2.egg-info/PKG-INFO +1 -1
  5. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/README.md +0 -0
  6. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/pg_probackup2/__init__.py +0 -0
  7. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/pg_probackup2/gdb.py +0 -0
  8. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/pg_probackup2/init_helpers.py +0 -0
  9. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/pg_probackup2/storage/__init__.py +0 -0
  10. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/pg_probackup2/storage/fs_backup.py +0 -0
  11. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/setup.cfg +0 -0
  12. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/testgres_pg_probackup2.egg-info/SOURCES.txt +0 -0
  13. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/testgres_pg_probackup2.egg-info/dependency_links.txt +0 -0
  14. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/testgres_pg_probackup2.egg-info/requires.txt +0 -0
  15. {testgres_pg_probackup2-0.3.0 → testgres_pg_probackup2-0.5.0}/testgres_pg_probackup2.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testgres_pg_probackup2
3
- Version: 0.3.0
3
+ Version: 0.5.0
4
4
  Summary: Plugin for testgres that manages pg_probackup2
5
5
  Home-page: https://github.com/postgrespro/testgres
6
6
  Author: Postgres Professional
@@ -41,15 +41,24 @@ class ProbackupException(Exception):
41
41
  fs_backup_class = FSTestBackupDir
42
42
 
43
43
 
44
+ class _OutputContainer:
45
+ """Internal container for output and cmd when test_class is not provided"""
46
+ def __init__(self):
47
+ self.output = None
48
+ self.cmd = None
49
+
50
+
44
51
  class ProbackupApp:
45
52
 
46
- def __init__(self, test_class: unittest.TestCase,
47
- pg_node, pb_log_path, test_env, auto_compress_alg, backup_dir, probackup_path=None):
53
+ def __init__(self, test_class: unittest.TestCase = None,
54
+ pg_node=None, pb_log_path=None, test_env=None, auto_compress_alg=None,
55
+ backup_dir=None, probackup_path=None):
48
56
  self.process = None
49
- self.test_class = test_class
57
+ # Use provided test_class or create internal container
58
+ self.test_class = test_class if test_class is not None else _OutputContainer()
50
59
  self.pg_node = pg_node
51
60
  self.pb_log_path = pb_log_path
52
- self.test_env = test_env
61
+ self.test_env = test_env if test_env is not None else os.environ.copy()
53
62
  self.auto_compress_alg = auto_compress_alg
54
63
  self.backup_dir = backup_dir
55
64
  self.probackup_path = probackup_path or init_params.probackup_path
@@ -571,7 +580,7 @@ class ProbackupApp:
571
580
  backup_list.append(backup)
572
581
 
573
582
  if backup_id is not None:
574
- assert False, "Failed to find backup with ID: {0}".format(backup_id)
583
+ raise RuntimeError("Failed to find backup with ID: {0}".format(backup_id))
575
584
 
576
585
  return backup_list
577
586
  else:
@@ -629,7 +638,7 @@ class ProbackupApp:
629
638
  specific_record[name.strip()] = var
630
639
 
631
640
  if not specific_record:
632
- assert False, "Failed to find backup with ID: {0}".format(backup_id)
641
+ raise RuntimeError("Failed to find backup with ID: {0}".format(backup_id))
633
642
 
634
643
  return specific_record
635
644
 
@@ -778,6 +787,13 @@ class ProbackupApp:
778
787
  log_level=False, archive_timeout=False,
779
788
  custom_archive_command=None):
780
789
 
790
+ # check instance existing
791
+ instances_json = self.show(instance=None, as_json=True, expect_error=False, as_text=True)
792
+ instances_data = json.loads(instances_json)
793
+ if not any(inst_data.get('instance') == instance for inst_data in instances_data):
794
+ raise RuntimeError("Instance '{0}' does not exist. " \
795
+ "Please add the instance first using add_instance() or init_pb_node().".format(instance))
796
+
781
797
  # parse postgresql.auto.conf
782
798
  options = {}
783
799
  if replica:
@@ -4,7 +4,7 @@ except ImportError:
4
4
  from distutils.core import setup
5
5
 
6
6
  setup(
7
- version='0.3.0',
7
+ version='0.5.0',
8
8
  name='testgres_pg_probackup2',
9
9
  packages=['pg_probackup2', 'pg_probackup2.storage'],
10
10
  description='Plugin for testgres that manages pg_probackup2',
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testgres_pg_probackup2
3
- Version: 0.3.0
3
+ Version: 0.5.0
4
4
  Summary: Plugin for testgres that manages pg_probackup2
5
5
  Home-page: https://github.com/postgrespro/testgres
6
6
  Author: Postgres Professional