Skip to content

Commit e5184a4

Browse files
author
vshepard
committed
Add cleanup parameter - clean full dir
1 parent a61f794 commit e5184a4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

testgres/node.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -912,13 +912,14 @@ def free_port(self):
912912
self._should_free_port = False
913913
release_port(self.port)
914914

915-
def cleanup(self, max_attempts=3):
915+
def cleanup(self, max_attempts=3, full=False):
916916
"""
917917
Stop node if needed and remove its data/logs directory.
918918
NOTE: take a look at TestgresConfig.node_cleanup_full.
919919
920920
Args:
921921
max_attempts: how many times should we try to stop()?
922+
full: clean full base dir
922923
923924
Returns:
924925
This instance of :class:`.PostgresNode`.
@@ -927,7 +928,7 @@ def cleanup(self, max_attempts=3):
927928
self._try_shutdown(max_attempts)
928929

929930
# choose directory to be removed
930-
if testgres_config.node_cleanup_full:
931+
if testgres_config.node_cleanup_full or full:
931932
rm_dir = self.base_dir # everything
932933
else:
933934
rm_dir = self.data_dir # just data, save logs
@@ -1655,8 +1656,7 @@ def upgrade_from(self, old_node, options=None, expect_error=False):
16551656
"--old-datadir", old_node.data_dir,
16561657
"--new-datadir", self.data_dir,
16571658
"--old-port", str(old_node.port),
1658-
"--new-port", str(self.port),
1659-
"--copy"
1659+
"--new-port", str(self.port)
16601660
]
16611661
upgrade_command += options
16621662

testgres/operations/local_ops.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ def rmdirs(self, path, ignore_errors=True, retries=3, delay=1):
162162
rmtree(path, ignore_errors=ignore_errors)
163163
if not os.path.exists(path):
164164
return True
165+
except FileNotFoundError:
166+
return True
165167
except Exception as e:
166168
print(f"Error: Failed to remove directory {path} on attempt {attempt + 1}: {e}")
167169
time.sleep(delay)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy