Skip to content

Commit 76b81d8

Browse files
Manciukicbchalios
authored andcommitted
refactor(test): add uvm_plain_acpi and _6_1 fixtures
Simplify the test code by introducing two new fixtures that are used in a few places in the code. This will also allow these tests to run on PCI. Signed-off-by: Riccardo Mancini <[email protected]> Signed-off-by: Babis Chalios <[email protected]>
1 parent 5c89b37 commit 76b81d8

File tree

6 files changed

+24
-28
lines changed

6 files changed

+24
-28
lines changed

tests/conftest.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,18 @@ def uvm_plain(microvm_factory, guest_kernel_linux_5_10, rootfs, pci_enabled):
514514
return microvm_factory.build(guest_kernel_linux_5_10, rootfs, pci=pci_enabled)
515515

516516

517+
@pytest.fixture
518+
def uvm_plain_6_1(microvm_factory, guest_kernel_linux_6_1, rootfs, pci_enabled):
519+
"""Create a vanilla VM, non-parametrized"""
520+
return microvm_factory.build(guest_kernel_linux_6_1, rootfs, pci=pci_enabled)
521+
522+
523+
@pytest.fixture
524+
def uvm_plain_acpi(microvm_factory, guest_kernel_acpi, rootfs, pci_enabled):
525+
"""Create a vanilla VM, non-parametrized"""
526+
return microvm_factory.build(guest_kernel_acpi, rootfs, pci=pci_enabled)
527+
528+
517529
@pytest.fixture
518530
def uvm_plain_rw(microvm_factory, guest_kernel_linux_5_10, rootfs_rw):
519531
"""Create a vanilla VM, non-parametrized"""

tests/integration_tests/functional/test_snapshot_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,11 +482,11 @@ def test_snapshot_overwrite_self(uvm_plain_any, microvm_factory):
482482
# restored, with a new snapshot of this vm, does not break the VM
483483

484484

485-
def test_vmgenid(guest_kernel_linux_6_1, rootfs, microvm_factory, snapshot_type):
485+
def test_vmgenid(uvm_plain_6_1, microvm_factory, snapshot_type):
486486
"""
487487
Test VMGenID device upon snapshot resume
488488
"""
489-
base_vm = microvm_factory.build(guest_kernel_linux_6_1, rootfs)
489+
base_vm = uvm_plain_6_1
490490
base_vm.spawn()
491491
base_vm.basic_config(track_dirty_pages=True)
492492
base_vm.add_net_iface()

tests/integration_tests/performance/test_block.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -161,24 +161,19 @@ def emit_fio_metrics(logs_dir, metrics):
161161
@pytest.mark.parametrize("fio_block_size", [4096], ids=["bs4096"])
162162
@pytest.mark.parametrize("fio_engine", ["libaio", "psync"])
163163
def test_block_performance(
164-
microvm_factory,
165-
guest_kernel_acpi,
166-
rootfs,
164+
uvm_any_acpi,
167165
vcpus,
168166
fio_mode,
169167
fio_block_size,
170168
fio_engine,
171-
pci_enabled,
172169
io_engine,
173170
metrics,
174171
results_dir,
175172
):
176173
"""
177174
Execute block device emulation benchmarking scenarios.
178175
"""
179-
vm = microvm_factory.build(
180-
guest_kernel_acpi, rootfs, monitor_memory=False, pci=pci_enabled
181-
)
176+
vm = uvm_any_acpi
182177
vm.spawn(log_level="Info", emit_metrics=True)
183178
vm.basic_config(vcpu_count=vcpus, mem_size_mib=GUEST_MEM_MIB)
184179
vm.add_net_iface()
@@ -216,9 +211,7 @@ def test_block_performance(
216211
@pytest.mark.parametrize("fio_mode", ["randread"])
217212
@pytest.mark.parametrize("fio_block_size", [4096], ids=["bs4096"])
218213
def test_block_vhost_user_performance(
219-
microvm_factory,
220-
guest_kernel_acpi,
221-
rootfs,
214+
uvm_any_acpi,
222215
vcpus,
223216
fio_mode,
224217
fio_block_size,
@@ -229,7 +222,7 @@ def test_block_vhost_user_performance(
229222
Execute block device emulation benchmarking scenarios.
230223
"""
231224

232-
vm = microvm_factory.build(guest_kernel_acpi, rootfs, monitor_memory=False)
225+
vm = uvm_any_acpi
233226
vm.spawn(log_level="Info", emit_metrics=True)
234227
vm.basic_config(vcpu_count=vcpus, mem_size_mib=GUEST_MEM_MIB)
235228
vm.add_net_iface()

tests/integration_tests/performance/test_network.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,14 @@ def consume_ping_output(ping_putput):
3838

3939

4040
@pytest.fixture
41-
def network_microvm(request, microvm_factory, guest_kernel_acpi, rootfs, pci_enabled):
41+
def network_microvm(request, uvm_plain_acpi):
4242
"""Creates a microvm with the networking setup used by the performance tests in this file.
4343
This fixture receives its vcpu count via indirect parameterization"""
4444

4545
guest_mem_mib = 1024
4646
guest_vcpus = request.param
4747

48-
vm = microvm_factory.build(
49-
guest_kernel_acpi, rootfs, monitor_memory=False, pci=pci_enabled
50-
)
48+
vm = uvm_plain_acpi
5149
vm.spawn(log_level="Info", emit_metrics=True)
5250
vm.basic_config(vcpu_count=guest_vcpus, mem_size_mib=guest_mem_mib)
5351
vm.add_net_iface()

tests/integration_tests/performance/test_vhost_user_metrics.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111

1212
@pytest.mark.parametrize("vcpu_count", [1, 2], ids=["1vcpu", "2vcpu"])
13-
def test_vhost_user_block_metrics(
14-
microvm_factory, guest_kernel_acpi, rootfs, vcpu_count, metrics
15-
):
13+
def test_vhost_user_block_metrics(uvm_plain_acpi, vcpu_count, metrics):
1614
"""
1715
This test tries to boot a VM with vhost-user-block
1816
as a scratch device, resize the vhost-user scratch drive to have
@@ -28,7 +26,7 @@ def test_vhost_user_block_metrics(
2826
# low->high->low->high and so the numbers are not in monotonic sequence.
2927
new_sizes = [20, 10, 30] # MB
3028

31-
vm = microvm_factory.build(guest_kernel_acpi, rootfs, monitor_memory=False)
29+
vm = uvm_plain_acpi
3230
vm.spawn(log_level="Info")
3331
vm.basic_config(vcpu_count=vcpu_count)
3432
vm.add_net_iface()

tests/integration_tests/performance/test_vsock.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,9 @@ def guest_command(self, port_offset):
7575
@pytest.mark.parametrize("payload_length", ["64K", "1024K"], ids=["p64K", "p1024K"])
7676
@pytest.mark.parametrize("mode", ["g2h", "h2g", "bd"])
7777
def test_vsock_throughput(
78-
microvm_factory,
79-
guest_kernel_acpi,
80-
rootfs,
78+
uvm_plain_acpi,
8179
vcpus,
8280
payload_length,
83-
pci_enabled,
8481
mode,
8582
metrics,
8683
results_dir,
@@ -95,9 +92,7 @@ def test_vsock_throughput(
9592
pytest.skip("bidrectional test only done with at least 2 vcpus")
9693

9794
mem_size_mib = 1024
98-
vm = microvm_factory.build(
99-
guest_kernel_acpi, rootfs, monitor_memory=False, pci=pci_enabled
100-
)
95+
vm = uvm_plain_acpi
10196
vm.spawn(log_level="Info", emit_metrics=True)
10297
vm.basic_config(vcpu_count=vcpus, mem_size_mib=mem_size_mib)
10398
vm.add_net_iface()

0 commit comments

Comments
 (0)