testgres-pg-probackup2 0.0.5__tar.gz → 0.1.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.
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/PKG-INFO +2 -2
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/pg_probackup2/app.py +54 -6
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/pg_probackup2/init_helpers.py +8 -5
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/setup.py +1 -1
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/testgres_pg_probackup2.egg-info/PKG-INFO +2 -2
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/README.md +0 -0
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/pg_probackup2/__init__.py +0 -0
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/pg_probackup2/gdb.py +0 -0
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/pg_probackup2/storage/__init__.py +0 -0
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/pg_probackup2/storage/fs_backup.py +0 -0
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/setup.cfg +0 -0
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/testgres_pg_probackup2.egg-info/SOURCES.txt +0 -0
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/testgres_pg_probackup2.egg-info/dependency_links.txt +0 -0
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/testgres_pg_probackup2.egg-info/requires.txt +0 -0
- {testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/testgres_pg_probackup2.egg-info/top_level.txt +0 -0
|
@@ -45,6 +45,7 @@ class ProbackupApp:
|
|
|
45
45
|
|
|
46
46
|
def __init__(self, test_class: unittest.TestCase,
|
|
47
47
|
pg_node, pb_log_path, test_env, auto_compress_alg, backup_dir, probackup_path=None):
|
|
48
|
+
self.process = None
|
|
48
49
|
self.test_class = test_class
|
|
49
50
|
self.pg_node = pg_node
|
|
50
51
|
self.pb_log_path = pb_log_path
|
|
@@ -60,8 +61,35 @@ class ProbackupApp:
|
|
|
60
61
|
self.test_class.output = None
|
|
61
62
|
self.execution_time = None
|
|
62
63
|
|
|
64
|
+
def form_daemon_process(self, cmdline, env):
|
|
65
|
+
def stream_output(stream: subprocess.PIPE) -> None:
|
|
66
|
+
try:
|
|
67
|
+
for line in iter(stream.readline, ''):
|
|
68
|
+
print(line)
|
|
69
|
+
self.test_class.output += line
|
|
70
|
+
finally:
|
|
71
|
+
stream.close()
|
|
72
|
+
|
|
73
|
+
self.process = subprocess.Popen(
|
|
74
|
+
cmdline,
|
|
75
|
+
stdout=subprocess.PIPE,
|
|
76
|
+
stderr=subprocess.PIPE,
|
|
77
|
+
text=True,
|
|
78
|
+
env=env
|
|
79
|
+
)
|
|
80
|
+
logging.info(f"Process started in background with PID: {self.process.pid}")
|
|
81
|
+
|
|
82
|
+
if self.process.stdout and self.process.stderr:
|
|
83
|
+
stdout_thread = threading.Thread(target=stream_output, args=(self.process.stdout,), daemon=True)
|
|
84
|
+
stderr_thread = threading.Thread(target=stream_output, args=(self.process.stderr,), daemon=True)
|
|
85
|
+
|
|
86
|
+
stdout_thread.start()
|
|
87
|
+
stderr_thread.start()
|
|
88
|
+
|
|
89
|
+
return self.process.pid
|
|
90
|
+
|
|
63
91
|
def run(self, command, gdb=False, old_binary=False, return_id=True, env=None,
|
|
64
|
-
skip_log_directory=False, expect_error=False, use_backup_dir=True):
|
|
92
|
+
skip_log_directory=False, expect_error=False, use_backup_dir=True, daemonize=False):
|
|
65
93
|
"""
|
|
66
94
|
Run pg_probackup
|
|
67
95
|
backup_dir: target directory for making backup
|
|
@@ -118,11 +146,14 @@ class ProbackupApp:
|
|
|
118
146
|
logging.warning("pg_probackup gdb suspended, waiting gdb connection on localhost:{0}".format(gdb_port))
|
|
119
147
|
|
|
120
148
|
start_time = time.time()
|
|
121
|
-
|
|
122
|
-
cmdline,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
149
|
+
if daemonize:
|
|
150
|
+
return self.form_daemon_process(cmdline, env)
|
|
151
|
+
else:
|
|
152
|
+
self.test_class.output = subprocess.check_output(
|
|
153
|
+
cmdline,
|
|
154
|
+
stderr=subprocess.STDOUT,
|
|
155
|
+
env=env
|
|
156
|
+
).decode('utf-8', errors='replace')
|
|
126
157
|
end_time = time.time()
|
|
127
158
|
self.execution_time = end_time - start_time
|
|
128
159
|
|
|
@@ -811,5 +842,22 @@ class ProbackupApp:
|
|
|
811
842
|
]
|
|
812
843
|
return self.run(cmd + options, expect_error=expect_error)
|
|
813
844
|
|
|
845
|
+
def maintain(
|
|
846
|
+
self, instance=None, backup_id=None,
|
|
847
|
+
options=None, old_binary=False, gdb=False, expect_error=False
|
|
848
|
+
):
|
|
849
|
+
if options is None:
|
|
850
|
+
options = []
|
|
851
|
+
cmd_list = [
|
|
852
|
+
'maintain',
|
|
853
|
+
]
|
|
854
|
+
if instance:
|
|
855
|
+
cmd_list += ['--instance={0}'.format(instance)]
|
|
856
|
+
if backup_id:
|
|
857
|
+
cmd_list += ['-i', backup_id]
|
|
858
|
+
|
|
859
|
+
return self.run(cmd_list + options, old_binary=old_binary, gdb=gdb,
|
|
860
|
+
expect_error=expect_error)
|
|
861
|
+
|
|
814
862
|
def build_backup_dir(self, backup='backup'):
|
|
815
863
|
return fs_backup_class(rel_path=self.rel_path, backup=backup)
|
|
@@ -121,8 +121,7 @@ class Init(object):
|
|
|
121
121
|
self.probackup_path = probackup_path_tmp
|
|
122
122
|
|
|
123
123
|
if not self.probackup_path:
|
|
124
|
-
|
|
125
|
-
exit(1)
|
|
124
|
+
raise Exception('pg_probackup binary is not found')
|
|
126
125
|
|
|
127
126
|
if os.name == 'posix':
|
|
128
127
|
self.EXTERNAL_DIRECTORY_DELIMITER = ':'
|
|
@@ -213,11 +212,15 @@ class Init(object):
|
|
|
213
212
|
if self.probackup_version.split('.')[0].isdigit():
|
|
214
213
|
self.major_version = int(self.probackup_version.split('.')[0])
|
|
215
214
|
else:
|
|
216
|
-
|
|
217
|
-
sys.exit(1)
|
|
215
|
+
raise Exception('Can\'t process pg_probackup version \"{}\": the major version is expected to be a number'.format(self.probackup_version))
|
|
218
216
|
|
|
219
217
|
def test_env(self):
|
|
220
218
|
return self._test_env.copy()
|
|
221
219
|
|
|
222
220
|
|
|
223
|
-
|
|
221
|
+
try:
|
|
222
|
+
init_params = Init()
|
|
223
|
+
except Exception as e:
|
|
224
|
+
logging.error(str(e))
|
|
225
|
+
logging.warning("testgres.plugins.probackup2.init_params is set to None.")
|
|
226
|
+
init_params = None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/pg_probackup2/storage/__init__.py
RENAMED
|
File without changes
|
{testgres_pg_probackup2-0.0.5 → testgres_pg_probackup2-0.1.0}/pg_probackup2/storage/fs_backup.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|