- Notifications
You must be signed in to change notification settings - Fork36
FUSE SUPPORT#184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
FUSE SUPPORT#184
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -45,6 +45,7 @@ class ProbackupApp: | ||
def __init__(self, test_class: unittest.TestCase, | ||
pg_node, pb_log_path, test_env, auto_compress_alg, backup_dir, probackup_path=None): | ||
self.process = None | ||
self.test_class = test_class | ||
self.pg_node = pg_node | ||
self.pb_log_path = pb_log_path | ||
@@ -60,8 +61,35 @@ def __init__(self, test_class: unittest.TestCase, | ||
self.test_class.output = None | ||
self.execution_time = None | ||
def form_daemon_process(self, cmdline, env): | ||
def stream_output(stream: subprocess.PIPE) -> None: | ||
try: | ||
for line in iter(stream.readline, ''): | ||
print(line) | ||
self.test_class.output += line | ||
finally: | ||
stream.close() | ||
self.process = subprocess.Popen( | ||
cmdline, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
text=True, | ||
env=env | ||
) | ||
logging.info(f"Process started in background with PID: {self.process.pid}") | ||
if self.process.stdout and self.process.stderr: | ||
stdout_thread = threading.Thread(target=stream_output, args=(self.process.stdout,), daemon=True) | ||
stderr_thread = threading.Thread(target=stream_output, args=(self.process.stderr,), daemon=True) | ||
stdout_thread.start() | ||
stderr_thread.start() | ||
return self.process.pid | ||
def run(self, command, gdb=False, old_binary=False, return_id=True, env=None, | ||
skip_log_directory=False, expect_error=False, use_backup_dir=True, daemonize=False): | ||
""" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Это будет раз на команду задаваться или на весь тестовый прогон? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Раз на команду, нужно для того чтобы мочь запустить команду в фоновом режиме. В моем случае чтобы запустить пробэкап с опцией fuse в фоне. | ||
Run pg_probackup | ||
backup_dir: target directory for making backup | ||
@@ -118,11 +146,14 @@ def run(self, command, gdb=False, old_binary=False, return_id=True, env=None, | ||
logging.warning("pg_probackup gdb suspended, waiting gdb connection on localhost:{0}".format(gdb_port)) | ||
start_time = time.time() | ||
if daemonize: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. часть в daemonize можно вынести в функцию например такую form_daemon_process There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Сделаю, разумно There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Поправлено | ||
return self.form_daemon_process(cmdline, env) | ||
else: | ||
self.test_class.output = subprocess.check_output( | ||
cmdline, | ||
stderr=subprocess.STDOUT, | ||
env=env | ||
).decode('utf-8', errors='replace') | ||
end_time = time.time() | ||
self.execution_time = end_time - start_time | ||