Skip to content

Commit 98d0d55

Browse files
Manciukicroypat
authored andcommitted
refactor(test): use uvm_plain* fixture instead factory.build
This patch updates all the places in the code with a uvm_plain* fixture when that was equivalent to the previous behaviour. In particular: - microvm_factory.build(guest_kernel_linux_5_10, rootfs) => uvm_plain - microvm_factory.build(guest_kernel, rootfs) => uvm_plain_any Signed-off-by: Riccardo Mancini <[email protected]>
1 parent 97d683a commit 98d0d55

File tree

6 files changed

+22
-33
lines changed

6 files changed

+22
-33
lines changed

tests/integration_tests/functional/test_balloon.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,11 @@ def test_stats_update(uvm_plain_any):
449449
assert next_stats["available_memory"] != final_stats["available_memory"]
450450

451451

452-
def test_balloon_snapshot(microvm_factory, guest_kernel, rootfs):
452+
def test_balloon_snapshot(uvm_plain_any, microvm_factory):
453453
"""
454454
Test that the balloon works after pause/resume.
455455
"""
456-
vm = microvm_factory.build(guest_kernel, rootfs)
456+
vm = uvm_plain_any
457457
vm.spawn()
458458
vm.basic_config(
459459
vcpu_count=2,
@@ -531,11 +531,11 @@ def test_balloon_snapshot(microvm_factory, guest_kernel, rootfs):
531531
assert stats_after_snap["available_memory"] > latest_stats["available_memory"]
532532

533533

534-
def test_memory_scrub(microvm_factory, guest_kernel, rootfs):
534+
def test_memory_scrub(uvm_plain_any):
535535
"""
536536
Test that the memory is zeroed after deflate.
537537
"""
538-
microvm = microvm_factory.build(guest_kernel, rootfs)
538+
microvm = uvm_plain_any
539539
microvm.spawn()
540540
microvm.basic_config(vcpu_count=2, mem_size_mib=256)
541541
microvm.add_net_iface()

tests/integration_tests/functional/test_cpu_template_helper.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,7 @@ def get_guest_msrs(microvm, msr_index_list):
261261
),
262262
)
263263
def test_cpu_config_dump_vs_actual(
264-
microvm_factory,
265-
guest_kernel,
266-
rootfs,
264+
uvm_plain_any,
267265
cpu_template_helper,
268266
tmp_path,
269267
):
@@ -277,7 +275,7 @@ def test_cpu_config_dump_vs_actual(
277275
dump_cpu_config = build_cpu_config_dict(cpu_config_path)
278276

279277
# Retrieve actual CPU config from guest
280-
microvm = microvm_factory.build(guest_kernel, rootfs)
278+
microvm = uvm_plain_any
281279
microvm.spawn()
282280
microvm.basic_config(vcpu_count=1)
283281
microvm.add_net_iface()

tests/integration_tests/functional/test_feat_parity.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,11 @@ def inst_set_cpu_template_fxt(request):
2828

2929

3030
@pytest.fixture(name="vm")
31-
def vm_fxt(
32-
microvm_factory,
33-
inst_set_cpu_template,
34-
guest_kernel,
35-
rootfs,
36-
):
31+
def vm_fxt(uvm_plain_any, inst_set_cpu_template):
3732
"""
3833
Create a VM, using the normal CPU templates
3934
"""
40-
vm = microvm_factory.build(guest_kernel, rootfs)
35+
vm = uvm_plain_any
4136
vm.spawn()
4237
vm.basic_config(vcpu_count=1, mem_size_mib=1024, cpu_template=inst_set_cpu_template)
4338
vm.add_net_iface()

tests/integration_tests/functional/test_snapshot_basic.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ def test_snapshot_current_version(uvm_nano):
115115
def test_cycled_snapshot_restore(
116116
bin_vsock_path,
117117
tmp_path,
118+
uvm_plain_any,
118119
microvm_factory,
119-
guest_kernel,
120-
rootfs,
121120
snapshot_type,
122121
use_snapshot_editor,
123122
cpu_template_any,
@@ -133,7 +132,7 @@ def test_cycled_snapshot_restore(
133132
logger = logging.getLogger("snapshot_sequence")
134133
diff_snapshots = snapshot_type == SnapshotType.DIFF
135134

136-
vm = microvm_factory.build(guest_kernel, rootfs)
135+
vm = uvm_plain_any
137136
vm.spawn()
138137
vm.basic_config(
139138
vcpu_count=2,
@@ -249,7 +248,7 @@ def test_load_snapshot_failure_handling(uvm_plain):
249248
vm.mark_killed()
250249

251250

252-
def test_cmp_full_and_first_diff_mem(microvm_factory, guest_kernel, rootfs):
251+
def test_cmp_full_and_first_diff_mem(uvm_plain_any):
253252
"""
254253
Compare memory of 2 consecutive full and diff snapshots.
255254
@@ -260,7 +259,7 @@ def test_cmp_full_and_first_diff_mem(microvm_factory, guest_kernel, rootfs):
260259
"""
261260
logger = logging.getLogger("snapshot_sequence")
262261

263-
vm = microvm_factory.build(guest_kernel, rootfs)
262+
vm = uvm_plain_any
264263
vm.spawn()
265264
vm.basic_config(
266265
vcpu_count=2,
@@ -430,12 +429,12 @@ def test_create_large_diff_snapshot(uvm_plain):
430429
# process would have been taken down.
431430

432431

433-
def test_diff_snapshot_overlay(guest_kernel, rootfs, microvm_factory):
432+
def test_diff_snapshot_overlay(uvm_plain_any, microvm_factory):
434433
"""
435434
Tests that if we take a diff snapshot and direct firecracker to write it on
436435
top of an existing snapshot file, it will successfully merge them.
437436
"""
438-
basevm = microvm_factory.build(guest_kernel, rootfs)
437+
basevm = uvm_plain_any
439438
basevm.spawn()
440439
basevm.basic_config(track_dirty_pages=True)
441440
basevm.add_net_iface()
@@ -467,15 +466,15 @@ def test_diff_snapshot_overlay(guest_kernel, rootfs, microvm_factory):
467466
# Check that the restored VM works
468467

469468

470-
def test_snapshot_overwrite_self(guest_kernel, rootfs, microvm_factory):
469+
def test_snapshot_overwrite_self(uvm_plain_any, microvm_factory):
471470
"""Tests that if we try to take a snapshot that would overwrite the
472471
very file from which the current VM is stored, nothing happens.
473472
474473
Note that even though we map the file as MAP_PRIVATE, the documentation
475474
of mmap does not specify what should happen if the file is changed after being
476475
mmap'd (https://man7.org/linux/man-pages/man2/mmap.2.html). It seems that
477476
these changes can propagate to the mmap'd memory region."""
478-
base_vm = microvm_factory.build(guest_kernel, rootfs)
477+
base_vm = uvm_plain_any
479478
base_vm.spawn()
480479
base_vm.basic_config()
481480
base_vm.add_net_iface()

tests/integration_tests/performance/test_huge_pages.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ def test_hugetlbfs_boot(uvm_plain):
6868
)
6969

7070

71-
def test_hugetlbfs_snapshot(microvm_factory, guest_kernel_linux_5_10, rootfs):
71+
def test_hugetlbfs_snapshot(microvm_factory, uvm_plain):
7272
"""
7373
Test hugetlbfs snapshot restore via uffd
7474
"""
7575

7676
### Create Snapshot ###
77-
vm = microvm_factory.build(guest_kernel_linux_5_10, rootfs)
77+
vm = uvm_plain
7878
vm.memory_monitor = None
7979
vm.spawn()
8080
vm.basic_config(huge_pages=HugePagesConfig.HUGETLBFS_2MB, mem_size_mib=128)
@@ -138,8 +138,7 @@ def test_hugetlbfs_diff_snapshot(microvm_factory, uvm_plain):
138138
@pytest.mark.parametrize("huge_pages", HugePagesConfig)
139139
def test_ept_violation_count(
140140
microvm_factory,
141-
guest_kernel_linux_5_10,
142-
rootfs,
141+
uvm_plain,
143142
metrics,
144143
huge_pages,
145144
):
@@ -149,7 +148,7 @@ def test_ept_violation_count(
149148
"""
150149

151150
### Create Snapshot ###
152-
vm = microvm_factory.build(guest_kernel_linux_5_10, rootfs)
151+
vm = uvm_plain
153152
vm.memory_monitor = None
154153
vm.spawn()
155154
vm.basic_config(huge_pages=huge_pages, mem_size_mib=256)

tests/integration_tests/performance/test_snapshot.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,13 @@ def test_population_latency(
255255

256256
@pytest.mark.nonci
257257
def test_snapshot_create_latency(
258-
microvm_factory,
259-
guest_kernel_linux_5_10,
260-
rootfs,
258+
uvm_plain,
261259
metrics,
262260
snapshot_type,
263261
):
264262
"""Measure the latency of creating a Full snapshot"""
265263

266-
vm = microvm_factory.build(guest_kernel_linux_5_10, rootfs, monitor_memory=False)
264+
vm = uvm_plain
267265
vm.spawn()
268266
vm.basic_config(
269267
vcpu_count=2,

0 commit comments

Comments
 (0)