Skip to content

Commit b63370c

Browse files
committed
test(balloon): enable secret_free on all balloon tests
Add the secret_free fixture parameter to all balloon functional tests, so they run with both SF_OFF and SF_ON variants. This exercises the new fallocate(PUNCH_HOLE) discard path for guest_memfd-backed memory during balloon inflate/deflate. Signed-off-by: Jack Thomson <jackabt@amazon.com>
1 parent bdca352 commit b63370c

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

tests/integration_tests/functional/test_balloon.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ def _test_rss_memory_lower(test_microvm):
9393

9494

9595
# pylint: disable=C0103
96-
def test_rss_memory_lower(uvm_plain_any):
96+
def test_rss_memory_lower(uvm_plain_any, secret_free):
9797
"""
9898
Test that inflating the balloon makes guest use less rss memory.
9999
"""
100100
test_microvm = uvm_plain_any
101101
test_microvm.spawn()
102-
test_microvm.basic_config()
102+
test_microvm.basic_config(secret_free=secret_free)
103103
test_microvm.add_net_iface()
104104

105105
# Add a memory balloon.
@@ -114,13 +114,13 @@ def test_rss_memory_lower(uvm_plain_any):
114114

115115

116116
# pylint: disable=C0103
117-
def test_inflate_reduces_free(uvm_plain_any):
117+
def test_inflate_reduces_free(uvm_plain_any, secret_free):
118118
"""
119119
Check that the output of free in guest changes with inflate.
120120
"""
121121
test_microvm = uvm_plain_any
122122
test_microvm.spawn()
123-
test_microvm.basic_config()
123+
test_microvm.basic_config(secret_free=secret_free)
124124
test_microvm.add_net_iface()
125125

126126
# Install deflated balloon.
@@ -150,7 +150,7 @@ def test_inflate_reduces_free(uvm_plain_any):
150150

151151
# pylint: disable=C0103
152152
@pytest.mark.parametrize("deflate_on_oom", [True, False])
153-
def test_deflate_on_oom(uvm_plain_any, deflate_on_oom):
153+
def test_deflate_on_oom(uvm_plain_any, secret_free, deflate_on_oom):
154154
"""
155155
Verify that setting the `deflate_on_oom` option works correctly.
156156
@@ -167,7 +167,7 @@ def test_deflate_on_oom(uvm_plain_any, deflate_on_oom):
167167

168168
test_microvm = uvm_plain_any
169169
test_microvm.spawn()
170-
test_microvm.basic_config()
170+
test_microvm.basic_config(secret_free=secret_free)
171171
test_microvm.add_net_iface()
172172

173173
# Add a deflated memory balloon.
@@ -215,13 +215,13 @@ def test_deflate_on_oom(uvm_plain_any, deflate_on_oom):
215215

216216

217217
# pylint: disable=C0103
218-
def test_reinflate_balloon(uvm_plain_any):
218+
def test_reinflate_balloon(uvm_plain_any, secret_free):
219219
"""
220220
Verify that repeatedly inflating and deflating the balloon works.
221221
"""
222222
test_microvm = uvm_plain_any
223223
test_microvm.spawn()
224-
test_microvm.basic_config()
224+
test_microvm.basic_config(secret_free=secret_free)
225225
test_microvm.add_net_iface()
226226

227227
# Add a deflated memory balloon.
@@ -280,13 +280,13 @@ def test_reinflate_balloon(uvm_plain_any):
280280

281281

282282
# pylint: disable=C0103
283-
def test_stats(uvm_plain_any):
283+
def test_stats(uvm_plain_any, secret_free):
284284
"""
285285
Verify that balloon stats work as expected.
286286
"""
287287
test_microvm = uvm_plain_any
288288
test_microvm.spawn()
289-
test_microvm.basic_config()
289+
test_microvm.basic_config(secret_free=secret_free)
290290
test_microvm.add_net_iface()
291291

292292
# Add a memory balloon with stats enabled.
@@ -351,13 +351,13 @@ def test_stats(uvm_plain_any):
351351
check_guest_dmesg_for_stalls(test_microvm.ssh)
352352

353353

354-
def test_stats_update(uvm_plain_any):
354+
def test_stats_update(uvm_plain_any, secret_free):
355355
"""
356356
Verify that balloon stats update correctly.
357357
"""
358358
test_microvm = uvm_plain_any
359359
test_microvm.spawn()
360-
test_microvm.basic_config()
360+
test_microvm.basic_config(secret_free=secret_free)
361361
test_microvm.add_net_iface()
362362

363363
# Add a memory balloon with stats enabled.
@@ -403,7 +403,7 @@ def test_stats_update(uvm_plain_any):
403403
check_guest_dmesg_for_stalls(test_microvm.ssh)
404404

405405

406-
def test_balloon_snapshot(uvm_plain_any, microvm_factory):
406+
def test_balloon_snapshot(uvm_plain_any, secret_free, microvm_factory):
407407
"""
408408
Test that the balloon works after pause/resume.
409409
"""
@@ -415,6 +415,7 @@ def test_balloon_snapshot(uvm_plain_any, microvm_factory):
415415
vm.basic_config(
416416
vcpu_count=2,
417417
mem_size_mib=256,
418+
secret_free=secret_free,
418419
)
419420
vm.add_net_iface()
420421

@@ -488,7 +489,9 @@ def test_balloon_snapshot(uvm_plain_any, microvm_factory):
488489

489490

490491
@pytest.mark.parametrize("method", ["reporting", "hinting"])
491-
def test_hinting_reporting_snapshot(uvm_plain_any, microvm_factory, method):
492+
def test_hinting_reporting_snapshot(
493+
uvm_plain_any, secret_free, microvm_factory, method
494+
):
492495
"""
493496
Test that the balloon hinting and reporting works after pause/resume.
494497
"""
@@ -500,6 +503,7 @@ def test_hinting_reporting_snapshot(uvm_plain_any, microvm_factory, method):
500503
vm.basic_config(
501504
vcpu_count=2,
502505
mem_size_mib=256,
506+
secret_free=secret_free,
503507
)
504508
vm.add_net_iface()
505509

@@ -575,13 +579,13 @@ def test_hinting_reporting_snapshot(uvm_plain_any, microvm_factory, method):
575579

576580

577581
@pytest.mark.parametrize("method", ["traditional", "hinting", "reporting"])
578-
def test_memory_scrub(uvm_plain_any, method):
582+
def test_memory_scrub(uvm_plain_any, secret_free, method):
579583
"""
580584
Test that the memory is zeroed after deflate.
581585
"""
582586
microvm = uvm_plain_any
583587
microvm.spawn()
584-
microvm.basic_config(vcpu_count=2, mem_size_mib=256)
588+
microvm.basic_config(vcpu_count=2, mem_size_mib=256, secret_free=secret_free)
585589
microvm.add_net_iface()
586590

587591
free_page_reporting = method == "reporting"

0 commit comments

Comments
 (0)