Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Ignore error teardown #142

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions testgres/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ def _try_shutdown(self, max_attempts, with_force=False):
# The node has already stopped
pass

# Check that node stopped
p_status_output = self.os_ops.exec_command(f'ps -p {node_pid}', shell=True, expect_error=True).decode('utf-8')
# Check that node stopped - print only column pid without headers
p_status_output = self.os_ops.exec_command(f'ps -o pid= -p {node_pid}', shell=True, ignore_errors=True).decode('utf-8')
if p_status_output and str(node_pid) in p_status_output:
eprint(f'Failed to stop node {self.name}.')
else:
Expand Down
5 changes: 3 additions & 2 deletions testgres/operations/local_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,15 @@ def _run_command(self, cmd, shell, input, stdin, stdout, stderr, get_process, ti
raise ExecUtilException("Command timed out after {} seconds.".format(timeout))

def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False, encoding=None, shell=False,
text=False, input=None, stdin=None, stdout=None, stderr=None, get_process=False, timeout=None):
text=False, input=None, stdin=None, stdout=None, stderr=None, get_process=False, timeout=None,
ignore_errors=False):
"""
Execute a command in a subprocess and handle the output based on the provided parameters.
"""
process, output, error = self._run_command(cmd, shell, input, stdin, stdout, stderr, get_process, timeout, encoding)
if get_process:
return process
if (process.returncode != 0 or has_errors(output=output, error=error)) and not expect_error:
if not ignore_errors and ((process.returncode != 0 or has_errors(output=output, error=error)) and not expect_error):
self._raise_exec_exception('Utility exited with non-zero code. Error `{}`', cmd, process.returncode, error or output)

if verbose:
Expand Down
4 changes: 2 additions & 2 deletions testgres/operations/remote_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __enter__(self):

def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
encoding=None, shell=True, text=False, input=None, stdin=None, stdout=None,
stderr=None, get_process=None, timeout=None):
stderr=None, get_process=None, timeout=None, ignore_errors=False):
"""
Execute a command in the SSH session.
Args:
Expand Down Expand Up @@ -98,7 +98,7 @@ def exec_command(self, cmd, wait_exit=False, verbose=False, expect_error=False,
marker in error for marker in ['error', 'Permission denied', 'fatal', 'No such file or directory']
)

if error_found:
if not ignore_errors and error_found:
if isinstance(error, bytes):
message = b"Utility exited with non-zero code. Error: " + error
else:
Expand Down