From 26c38bfd3ec7175fe978329f100a6e5b06b4501d Mon Sep 17 00:00:00 2001 From: "re:fi.64" Date: Sat, 26 Sep 2026 18:06:21 -0500 Subject: [PATCH] tests: Make waits for stratis filesystem expansion less racy --- tests/test_e2e.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/tests/test_e2e.py b/tests/test_e2e.py index a136700..6c4d389 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -12,7 +12,18 @@ from .testutils.k8s import TEST_NAMESPACE, pod_logs, wait_for_pod_success from .testutils.stratis import PoolSelection -async def run_pod(*, config: Config, script: str, pvc: str) -> None: +async def run_pod(*, config: Config, pvc: str, filename: str, size_mi: int) -> None: + script = f""" + while true; do + free=$(df -B1M --output=avail /test | tail -1) + echo "$free" + [[ "$free" -lt {size_mi} ]] || break + sleep 1 + done + dd if=/dev/zero of=/test/{filename} bs=1M count={size_mi} + echo ok. + """ + pod = await k8s.core.v1.Pod( metadata=ObjectMeta(name='fill'), spec=k8s.core.v1.PodSpec( @@ -20,7 +31,7 @@ async def run_pod(*, config: Config, script: str, pvc: str) -> None: containers=[ k8s.core.v1.Container( name='fill', - command=['bash', '-exc', script + '\necho ok.'], + command=['bash', '-exc', script], image='debian:trixie-slim', volume_mounts=[ k8s.core.v1.VolumeMount(name='test', mount_path='/test'), @@ -70,7 +81,8 @@ async def test_e2e(k8s_config: Config, selection: PoolSelection) -> None: await run_pod( config=k8s_config, pvc=pvc_name, - script='dd if=/dev/zero of=/test/bigfile bs=1M count=1900', + filename='bigfile', + size_mi=1900, ) pvc = await pvc.async_fetch() @@ -82,10 +94,8 @@ async def test_e2e(k8s_config: Config, selection: PoolSelection) -> None: await run_pod( config=k8s_config, pvc=pvc_name, - script=""" - sleep 12 # make sure stratis gets a chance to grow the fs - dd if=/dev/zero of=/test/bigfile.2 bs=1M count=1000 - """, + filename='bigfile.2', + size_mi=1000, ) await k8s_vs.snapshot.v1.VolumeSnapshotClass( @@ -123,10 +133,8 @@ async def test_e2e(k8s_config: Config, selection: PoolSelection) -> None: await run_pod( config=k8s_config, pvc=snap_name, - script=""" - sleep 12 # make sure stratis gets a chance to grow the fs - dd if=/dev/zero of=/test/bigfile.3 bs=1M count=1000 - """, + filename='bigfile.3', + size_mi=1000, ) node = await k8s.core.v1.Node.async_get('lima-topolvm-stratis-test') -- 2.51.2