Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: postgrespro/testgres
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: b2b947f
Choose a base ref
...
head repository: postgrespro/testgres
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f7893bf
Choose a head ref
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Jul 25, 2024

  1. Add log folder size in cleanup

    vshepard committed Jul 25, 2024
    Copy the full SHA
    f7893bf View commit details
Showing with 14 additions and 0 deletions.
  1. +14 −0 testgres/node.py
14 changes: 14 additions & 0 deletions testgres/node.py
Original file line number Diff line number Diff line change
@@ -913,6 +913,17 @@ def free_port(self):
self._should_free_port = False
release_port(self.port)

def _get_directory_size(self, directory):
"""Calculate the total size of a directory."""
total_size = 0
for dirpath, dirnames, filenames in os.walk(directory):
for f in filenames:
fp = os.path.join(dirpath, f)
# Skip if it is symbolic link
if not os.path.islink(fp):
total_size += os.path.getsize(fp)
return total_size

def cleanup(self, max_attempts=3, full=False):
"""
Stop node if needed and remove its data/logs directory.
@@ -934,6 +945,9 @@ def cleanup(self, max_attempts=3, full=False):
else:
rm_dir = self.data_dir # just data, save logs

dir_size = self._get_directory_size(rm_dir)
print(f"Cleanup: Size of the directory '{rm_dir}' before removal: {dir_size} bytes")

self.os_ops.rmdirs(rm_dir, ignore_errors=False)

return self