Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PostgresNode_Base is added #222

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

Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
PostgresNode::clean is corrected
PostgresNode_Base::clean deletes data_dir and logs_dir

PostgresNode::clean calls PostgresNode_Base::clean and deletes base_dir.
  • Loading branch information
dmitry-lipetsk committed Mar 17, 2025
commit 9e1979f3b7818d38778f1094e2314cfd0718835a
12 changes: 12 additions & 0 deletions testgres/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ def utils_log_name(self):
def pg_log_name(self):
return self.pg_log_file

def cleanup(self, max_attempts=3, full=False):
super().cleanup(max_attempts, full)

base_dir_items = self.os_ops.listdir(self.base_dir)
assert base_dir_items is not None
assert type(base_dir_items) == list # noqa: E721

if len(base_dir_items) == 0:
self.os_ops.rmdirs(self.base_dir, ignore_errors=False)

return self


class NodeApp:

Expand Down
10 changes: 3 additions & 7 deletions testgres/node_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,22 +1170,18 @@ def cleanup(self, max_attempts=3, full=False):

Args:
max_attempts: how many times should we try to stop()?
full: clean full base dir
full: clean logs dir, too.

Returns:
This instance of :class:`.PostgresNode_Base`.
"""

self._try_shutdown(max_attempts)

# choose directory to be removed
if testgres_config.node_cleanup_full or full:
rm_dir = self.base_dir # everything
else:
rm_dir = self.data_dir # just data, save logs

self._os_ops.rmdirs(rm_dir, ignore_errors=False)
self._os_ops.rmdirs(self.logs_dir, ignore_errors=False)

self._os_ops.rmdirs(self.data_dir, ignore_errors=False)
return self

@method_decorator(positional_args_hack(['dbname', 'query']))
Expand Down