Skip to content
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

test: make diskusage data available even after successful runs #792

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,4 @@ jobs:
run: |
df -h
sudo du -sh * /var/tmp /tmp /var/lib/containers | sort -sh
sudo find /mnt/var/tmp/bib-tests -name du.log|sudo xargs cat
23 changes: 13 additions & 10 deletions test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,19 @@ def del_ami():
# Try to cache as much as possible
for image_type in image_types:
img = artifact[image_type]
print(f"Checking disk usage for {img}")
if os.path.exists(img):
# might already be removed if we're deleting 'raw' and 'ami'
disk_usage = shutil.disk_usage(img)
print(f"NOTE: disk usage after {img}: {disk_usage.free / 1_000_000} / {disk_usage.total / 1_000_000}")
if disk_usage.free < 1_000_000_000:
print(f"WARNING: running low on disk space, removing {img}")
img.unlink()
else:
print("does not exist")
# XXX: make parallizable via flock
with open(shared_tmpdir / "du.log", "a") as fp:
fp.write(f"Checking disk usage for {img}\n")
if os.path.exists(img):
# might already be removed if we're deleting 'raw' and 'ami'
disk_usage = shutil.disk_usage(img)
fp.write(f"NOTE: disk usage after {img}: {disk_usage.free / 1_000_000} / {disk_usage.total / 1_000_000}\n")
if disk_usage.free < 1_000_000_000:
fp.write(f"WARNING: running low on disk space, removing {img}\n")
img.unlink()
else:
fp.write("does not exist\n")
fp.write("---\n")
subprocess.run(["podman", "rmi", container_ref], check=False)
return

Expand Down
Loading