Skip to content

Commit 30c5c7e

Browse files
committed
tests: Check for stalls in balloon tests
Update our balloon tests to check for stall messages in the guest. Signed-off-by: Jack Thomson <[email protected]>
1 parent 4bd3c6a commit 30c5c7e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/integration_tests/functional/test_balloon.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
STATS_POLLING_INTERVAL_S = 1
1717

1818

19+
def check_guest_dmesg_for_stalls(ssh_connection):
20+
"""Check guest dmesg for RCU stalls and soft lockups."""
21+
_, stdout, _ = ssh_connection.run("dmesg")
22+
assert "rcu_sched self-detected stall on CPU" not in stdout
23+
assert "rcu_preempt detected stalls on CPUs/tasks" not in stdout
24+
assert "BUG: soft lockup -" not in stdout
25+
26+
1927
def lower_ssh_oom_chance(ssh_connection):
2028
"""Lure OOM away from ssh process"""
2129
logger = logging.getLogger("lower_ssh_oom_chance")
@@ -76,6 +84,7 @@ def _test_rss_memory_lower(test_microvm):
7684

7785
# Check that the ballooning reclaimed the memory.
7886
assert balloon_rss - init_rss <= 15000
87+
check_guest_dmesg_for_stalls(ssh_connection)
7988

8089

8190
# pylint: disable=C0103
@@ -131,6 +140,7 @@ def test_inflate_reduces_free(uvm_plain_any):
131140

132141
# Assert that ballooning reclaimed about 64 MB of memory.
133142
assert available_mem_inflated <= available_mem_deflated - 85 * 64000 / 100
143+
check_guest_dmesg_for_stalls(test_microvm.ssh)
134144

135145

136146
# pylint: disable=C0103
@@ -192,6 +202,7 @@ def test_deflate_on_oom(uvm_plain_any, deflate_on_oom):
192202
print(f"size before: {balloon_size_before} size after: {balloon_size_after}")
193203
if deflate_on_oom:
194204
assert balloon_size_after < balloon_size_before, "Balloon did not deflate"
205+
check_guest_dmesg_for_stalls(test_microvm.ssh)
195206
else:
196207
assert balloon_size_after >= balloon_size_before, "Balloon deflated"
197208
# Kill it here, letting the infrastructure know that the process might
@@ -255,6 +266,7 @@ def test_reinflate_balloon(uvm_plain_any):
255266
# is probably freed after the first inflation.
256267
assert (third_reading - first_reading) <= 20000
257268
assert abs(second_reading - fourth_reading) <= 20000
269+
check_guest_dmesg_for_stalls(test_microvm.ssh)
258270

259271

260272
# pylint: disable=C0103
@@ -326,6 +338,7 @@ def test_stats(uvm_plain_any):
326338
# Ensure the stats reflect deflating the balloon.
327339
assert inflated_stats["free_memory"] < deflated_stats["free_memory"]
328340
assert inflated_stats["available_memory"] < deflated_stats["available_memory"]
341+
check_guest_dmesg_for_stalls(test_microvm.ssh)
329342

330343

331344
def test_stats_update(uvm_plain_any):
@@ -377,6 +390,7 @@ def test_stats_update(uvm_plain_any):
377390

378391
# Ensure that stats don't have unknown balloon stats fields
379392
assert "balloon: unknown stats update tag:" not in test_microvm.log_data
393+
check_guest_dmesg_for_stalls(test_microvm.ssh)
380394

381395

382396
def test_balloon_snapshot(uvm_plain_any, microvm_factory):
@@ -453,6 +467,7 @@ def test_balloon_snapshot(uvm_plain_any, microvm_factory):
453467
# Ensure the stats are still working after restore and show
454468
# that the balloon inflated.
455469
assert stats_after_snap["available_memory"] > latest_stats["available_memory"]
470+
check_guest_dmesg_for_stalls(microvm.ssh)
456471

457472

458473
@pytest.mark.parametrize("method", ["reporting", "hinting"])
@@ -532,6 +547,7 @@ def test_hinting_reporting_snapshot(uvm_plain_any, microvm_factory, method):
532547
# There should be a reduction in RSS, but it's inconsistent.
533548
# We only test that the reduction happens.
534549
assert third_reading > fourth_reading
550+
check_guest_dmesg_for_stalls(microvm.ssh)
535551

536552

537553
@pytest.mark.parametrize("method", ["traditional", "hinting", "reporting"])
@@ -581,3 +597,4 @@ def test_memory_scrub(uvm_plain_any, method):
581597
_ = get_stable_rss_mem(microvm)
582598

583599
microvm.ssh.check_output("/usr/local/bin/readmem {} {}".format(60, 1))
600+
check_guest_dmesg_for_stalls(microvm.ssh)

0 commit comments

Comments
 (0)