Skip to content

Commit 5c89b37

Browse files
Manciukicbchalios
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]> Signed-off-by: Babis Chalios <[email protected]>
1 parent ba6aeb3 commit 5c89b37

File tree

6 files changed

+22
-35
lines changed

6 files changed

+22
-35
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
@@ -266,9 +266,7 @@ def get_guest_msrs(microvm, msr_index_list):
266266
),
267267
)
268268
def test_cpu_config_dump_vs_actual(
269-
microvm_factory,
270-
guest_kernel,
271-
rootfs,
269+
uvm_plain_any,
272270
cpu_template_helper,
273271
tmp_path,
274272
):
@@ -282,7 +280,7 @@ def test_cpu_config_dump_vs_actual(
282280
dump_cpu_config = build_cpu_config_dict(cpu_config_path)
283281

284282
# Retrieve actual CPU config from guest
285-
microvm = microvm_factory.build(guest_kernel, rootfs)
283+
microvm = uvm_plain_any
286284
microvm.spawn()
287285
microvm.basic_config(vcpu_count=1)
288286
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,
@@ -132,7 +131,7 @@ def test_cycled_snapshot_restore(
132131

133132
logger = logging.getLogger("snapshot_sequence")
134133

135-
vm = microvm_factory.build(guest_kernel, rootfs)
134+
vm = uvm_plain_any
136135
vm.spawn()
137136
vm.basic_config(
138137
vcpu_count=2,
@@ -248,7 +247,7 @@ def test_load_snapshot_failure_handling(uvm_plain):
248247
vm.mark_killed()
249248

250249

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

262-
vm = microvm_factory.build(guest_kernel, rootfs)
261+
vm = uvm_plain_any
263262
vm.spawn()
264263
vm.basic_config(
265264
vcpu_count=2,
@@ -414,12 +413,12 @@ def test_create_large_diff_snapshot(uvm_plain):
414413
# process would have been taken down.
415414

416415

417-
def test_diff_snapshot_overlay(guest_kernel, rootfs, microvm_factory):
416+
def test_diff_snapshot_overlay(uvm_plain_any, microvm_factory):
418417
"""
419418
Tests that if we take a diff snapshot and direct firecracker to write it on
420419
top of an existing snapshot file, it will successfully merge them.
421420
"""
422-
basevm = microvm_factory.build(guest_kernel, rootfs)
421+
basevm = uvm_plain_any
423422
basevm.spawn()
424423
basevm.basic_config(track_dirty_pages=True)
425424
basevm.add_net_iface()
@@ -451,15 +450,15 @@ def test_diff_snapshot_overlay(guest_kernel, rootfs, microvm_factory):
451450
# Check that the restored VM works
452451

453452

454-
def test_snapshot_overwrite_self(guest_kernel, rootfs, microvm_factory):
453+
def test_snapshot_overwrite_self(uvm_plain_any, microvm_factory):
455454
"""Tests that if we try to take a snapshot that would overwrite the
456455
very file from which the current VM is stored, nothing happens.
457456
458457
Note that even though we map the file as MAP_PRIVATE, the documentation
459458
of mmap does not specify what should happen if the file is changed after being
460459
mmap'd (https://man7.org/linux/man-pages/man2/mmap.2.html). It seems that
461460
these changes can propagate to the mmap'd memory region."""
462-
base_vm = microvm_factory.build(guest_kernel, rootfs)
461+
base_vm = uvm_plain_any
463462
base_vm.spawn()
464463
base_vm.basic_config()
465464
base_vm.add_net_iface()

tests/integration_tests/performance/test_huge_pages.py

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

7070

71-
def test_hugetlbfs_snapshot(
72-
microvm_factory, guest_kernel_linux_5_10, rootfs, snapshot_type
73-
):
71+
def test_hugetlbfs_snapshot(microvm_factory, uvm_plain, snapshot_type):
7472
"""
7573
Test hugetlbfs snapshot restore via uffd
7674
@@ -79,7 +77,7 @@ def test_hugetlbfs_snapshot(
7977
"""
8078

8179
### Create Snapshot ###
82-
vm = microvm_factory.build(guest_kernel_linux_5_10, rootfs)
80+
vm = uvm_plain
8381
vm.memory_monitor = None
8482
vm.spawn()
8583
vm.basic_config(
@@ -107,8 +105,7 @@ def test_hugetlbfs_snapshot(
107105
@pytest.mark.parametrize("huge_pages", HugePagesConfig)
108106
def test_ept_violation_count(
109107
microvm_factory,
110-
guest_kernel_linux_5_10,
111-
rootfs,
108+
uvm_plain,
112109
metrics,
113110
huge_pages,
114111
):
@@ -118,7 +115,7 @@ def test_ept_violation_count(
118115
"""
119116

120117
### Create Snapshot ###
121-
vm = microvm_factory.build(guest_kernel_linux_5_10, rootfs)
118+
vm = uvm_plain
122119
vm.memory_monitor = None
123120
vm.spawn()
124121
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)