Skip to content

Commit 304c393

Browse files
committed
test(balloon): ensure we always wait long enough for stats to update
Always wait twice the stats polling interval when trying to a comparison between "old" and "new" balloon stats. This is to ensure that the "new" stats are definitely new, and we didn't hit some unlikely race condition where we request stats right as the device is still in the process of updating them. We were seeing intermittent issues such as test_balloon.py:531: in test_balloon_snapshot assert stats_after_snap["available_memory"] > latest_stats["available_memory"] E assert 186281984 > 186281984 Signed-off-by: Patrick Roy <[email protected]>
1 parent 357dedc commit 304c393

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/integration_tests/functional/test_balloon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def test_stats_update(uvm_plain_any):
433433
test_microvm.api.balloon.patch(amount_mib=10)
434434

435435
# Wait out the polling interval, then get the updated stats.
436-
time.sleep(STATS_POLLING_INTERVAL_S)
436+
time.sleep(STATS_POLLING_INTERVAL_S * 2)
437437
next_stats = test_microvm.api.balloon_stats.get().json()
438438
assert initial_stats["available_memory"] != next_stats["available_memory"]
439439

@@ -497,7 +497,7 @@ def test_balloon_snapshot(microvm_factory, guest_kernel, rootfs):
497497
firecracker_pid = microvm.firecracker_pid
498498

499499
# Wait out the polling interval, then get the updated stats.
500-
time.sleep(STATS_POLLING_INTERVAL_S)
500+
time.sleep(STATS_POLLING_INTERVAL_S * 2)
501501
stats_after_snap = microvm.api.balloon_stats.get().json()
502502

503503
# Check memory usage.
@@ -523,7 +523,7 @@ def test_balloon_snapshot(microvm_factory, guest_kernel, rootfs):
523523
# Get the stats after we take a snapshot and dirty some memory,
524524
# then reclaim it.
525525
# Ensure we gave enough time for the stats to update.
526-
time.sleep(STATS_POLLING_INTERVAL_S)
526+
time.sleep(STATS_POLLING_INTERVAL_S * 2)
527527
latest_stats = microvm.api.balloon_stats.get().json()
528528

529529
# Ensure the stats are still working after restore and show

0 commit comments

Comments
 (0)