Skip to content

Commit f7893bf

Browse files
author
vshepard
committed
Add log folder size in cleanup
1 parent 5c7cf18 commit f7893bf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

testgres/node.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,17 @@ def free_port(self):
913913
self._should_free_port = False
914914
release_port(self.port)
915915

916+
def _get_directory_size(self, directory):
917+
"""Calculate the total size of a directory."""
918+
total_size = 0
919+
for dirpath, dirnames, filenames in os.walk(directory):
920+
for f in filenames:
921+
fp = os.path.join(dirpath, f)
922+
# Skip if it is symbolic link
923+
if not os.path.islink(fp):
924+
total_size += os.path.getsize(fp)
925+
return total_size
926+
916927
def cleanup(self, max_attempts=3, full=False):
917928
"""
918929
Stop node if needed and remove its data/logs directory.
@@ -934,6 +945,9 @@ def cleanup(self, max_attempts=3, full=False):
934945
else:
935946
rm_dir = self.data_dir # just data, save logs
936947

948+
dir_size = self._get_directory_size(rm_dir)
949+
print(f"Cleanup: Size of the directory '{rm_dir}' before removal: {dir_size} bytes")
950+
937951
self.os_ops.rmdirs(rm_dir, ignore_errors=False)
938952

939953
return self

0 commit comments

Comments
 (0)