Skip to content

Commit 4c87b02

Browse files
committed
fixup: run more tests on PCI enabled
This commit allows more test to run with PCI enabled, just in case we missed something else. Signed-off-by: Riccardo Mancini <[email protected]>
1 parent 1b5241f commit 4c87b02

File tree

11 files changed

+125
-101
lines changed

11 files changed

+125
-101
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_concurrency.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
NO_OF_MICROVMS = 20
88

99

10-
def test_run_concurrency(microvm_factory, guest_kernel, rootfs):
10+
def test_run_concurrency(microvm_factory, guest_kernel, rootfs, pci_enabled):
1111
"""
1212
Check we can spawn multiple microvms.
1313
"""
1414

1515
def launch1():
16-
microvm = microvm_factory.build(guest_kernel, rootfs)
16+
microvm = microvm_factory.build(guest_kernel, rootfs, pci=pci_enabled)
1717
microvm.time_api_requests = False # is flaky because of parallelism
1818
microvm.spawn()
1919
microvm.basic_config(vcpu_count=1, mem_size_mib=128)

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_drive_vhost_user.py

Lines changed: 65 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,62 @@
66
import shutil
77
from pathlib import Path
88

9+
import pytest
10+
911
import host_tools.drive as drive_tools
1012
from framework.utils_drive import partuuid_and_disk_path
1113
from host_tools.fcmetrics import FcDeviceMetrics
1214

1315

16+
@pytest.fixture
17+
def uvm_vhost_user_plain_any(microvm_factory, guest_kernel, pci_enabled):
18+
"""Builds a plain VM with no root volume"""
19+
return microvm_factory.build(
20+
guest_kernel, None, pci=pci_enabled, monitor_memory=False
21+
)
22+
23+
24+
@pytest.fixture
25+
def uvm_vhost_user_booted_ro(uvm_vhost_user_plain_any, rootfs):
26+
"""Returns a VM with a vhost-user rootfs"""
27+
vm = uvm_vhost_user_plain_any
28+
29+
# We need to setup ssh keys manually because we did not specify rootfs
30+
# in microvm_factory.build method
31+
ssh_key = rootfs.with_suffix(".id_rsa")
32+
vm.ssh_key = ssh_key
33+
vm.spawn()
34+
vm.basic_config(add_root_device=False)
35+
vm.add_vhost_user_drive("rootfs", rootfs, is_root_device=True, is_read_only=True)
36+
vm.add_net_iface()
37+
vm.start()
38+
39+
return vm
40+
41+
42+
@pytest.fixture
43+
def uvm_vhost_user_booted_rw(uvm_vhost_user_plain_any, rootfs):
44+
"""Returns a VM with a vhost-user rootfs"""
45+
vm = uvm_vhost_user_plain_any
46+
47+
# We need to setup ssh keys manually because we did not specify rootfs
48+
# in microvm_factory.build method
49+
ssh_key = rootfs.with_suffix(".id_rsa")
50+
vm.ssh_key = ssh_key
51+
vm.spawn()
52+
vm.basic_config(add_root_device=False)
53+
# Create a rw rootfs file that is unique to the microVM
54+
rootfs_rw = Path(vm.chroot()) / "rootfs"
55+
shutil.copy(rootfs, rootfs_rw)
56+
vm.add_vhost_user_drive(
57+
"rootfs", rootfs_rw, is_root_device=True, is_read_only=False
58+
)
59+
vm.add_net_iface()
60+
vm.start()
61+
62+
return vm
63+
64+
1465
def _check_block_size(ssh_connection, dev_path, size):
1566
"""
1667
Checks the size of the block device.
@@ -34,26 +85,16 @@ def _check_drives(test_microvm, assert_dict, keys_array):
3485
assert blockdev_out_line_cols[col] == assert_dict[key]
3586

3687

37-
def test_vhost_user_block(microvm_factory, guest_kernel, rootfs):
88+
def test_vhost_user_block(uvm_vhost_user_booted_ro):
3889
"""
3990
This test simply tries to boot a VM with
4091
vhost-user-block as a root device.
4192
"""
4293

43-
vm = microvm_factory.build(guest_kernel, None, monitor_memory=False)
44-
45-
# We need to setup ssh keys manually because we did not specify rootfs
46-
# in microvm_factory.build method
47-
ssh_key = rootfs.with_suffix(".id_rsa")
48-
vm.ssh_key = ssh_key
49-
vm.spawn()
50-
vm.basic_config(add_root_device=False)
51-
vm.add_vhost_user_drive("rootfs", rootfs, is_root_device=True, is_read_only=True)
52-
vm.add_net_iface()
94+
vm = uvm_vhost_user_booted_ro
5395
vhost_user_block_metrics = FcDeviceMetrics(
5496
"vhost_user_block", 1, aggr_supported=False
5597
)
56-
vm.start()
5798

5899
# Now check that vhost-user-block with rw is last.
59100
# 1-0 means line 1, column 0.
@@ -65,29 +106,14 @@ def test_vhost_user_block(microvm_factory, guest_kernel, rootfs):
65106
vhost_user_block_metrics.validate(vm)
66107

67108

68-
def test_vhost_user_block_read_write(microvm_factory, guest_kernel, rootfs):
109+
def test_vhost_user_block_read_write(uvm_vhost_user_booted_rw):
69110
"""
70111
This test simply tries to boot a VM with
71112
vhost-user-block as a root device.
72113
This test configures vhost-user-block to be read write.
73114
"""
74115

75-
vm = microvm_factory.build(guest_kernel, None, monitor_memory=False)
76-
77-
# We need to setup ssh keys manually because we did not specify rootfs
78-
# in microvm_factory.build method
79-
ssh_key = rootfs.with_suffix(".id_rsa")
80-
vm.ssh_key = ssh_key
81-
vm.spawn()
82-
vm.basic_config(add_root_device=False)
83-
84-
# Create a rw rootfs file that is unique to the microVM
85-
rootfs_rw = Path(vm.chroot()) / "rootfs"
86-
shutil.copy(rootfs, rootfs_rw)
87-
88-
vm.add_vhost_user_drive("rootfs", rootfs_rw, is_root_device=True)
89-
vm.add_net_iface()
90-
vm.start()
116+
vm = uvm_vhost_user_booted_rw
91117

92118
# Now check that vhost-user-block with rw is last.
93119
# 1-0 means line 1, column 0.
@@ -98,22 +124,12 @@ def test_vhost_user_block_read_write(microvm_factory, guest_kernel, rootfs):
98124
_check_drives(vm, assert_dict, assert_dict.keys())
99125

100126

101-
def test_vhost_user_block_disconnect(microvm_factory, guest_kernel, rootfs):
127+
def test_vhost_user_block_disconnect(uvm_vhost_user_booted_ro):
102128
"""
103129
Test that even if backend is killed, Firecracker is still responsive.
104130
"""
105131

106-
vm = microvm_factory.build(guest_kernel, None, monitor_memory=False)
107-
108-
# We need to set up ssh keys manually because we did not specify rootfs
109-
# in microvm_factory.build method
110-
ssh_key = rootfs.with_suffix(".id_rsa")
111-
vm.ssh_key = ssh_key
112-
vm.spawn()
113-
vm.basic_config(add_root_device=False)
114-
vm.add_vhost_user_drive("rootfs", rootfs, is_root_device=True, is_read_only=True)
115-
vm.add_net_iface()
116-
vm.start()
132+
vm = uvm_vhost_user_booted_ro
117133

118134
# Killing the backend
119135
vm.disks_vhost_user["rootfs"].kill()
@@ -123,15 +139,15 @@ def test_vhost_user_block_disconnect(microvm_factory, guest_kernel, rootfs):
123139
_config = vm.api.vm_config.get().json()
124140

125141

126-
def test_device_ordering(microvm_factory, guest_kernel, rootfs):
142+
def test_device_ordering(uvm_vhost_user_plain_any, rootfs):
127143
"""
128144
Verify device ordering.
129145
130146
The root device should correspond to /dev/vda in the guest and
131147
the order of the other devices should match their configuration order.
132148
"""
133149

134-
vm = microvm_factory.build(guest_kernel, None, monitor_memory=False)
150+
vm = uvm_vhost_user_plain_any
135151

136152
# We need to setup ssh keys manually because we did not specify rootfs
137153
# in microvm_factory.build method
@@ -194,16 +210,12 @@ def test_device_ordering(microvm_factory, guest_kernel, rootfs):
194210
vhost_user_block_metrics.validate(vm)
195211

196212

197-
def test_partuuid_boot(
198-
microvm_factory,
199-
guest_kernel,
200-
rootfs,
201-
):
213+
def test_partuuid_boot(uvm_vhost_user_plain_any, rootfs):
202214
"""
203215
Test the output reported by blockdev when booting with PARTUUID.
204216
"""
205217

206-
vm = microvm_factory.build(guest_kernel, None, monitor_memory=False)
218+
vm = uvm_vhost_user_plain_any
207219

208220
# We need to setup ssh keys manually because we did not specify rootfs
209221
# in microvm_factory.build method
@@ -230,12 +242,12 @@ def test_partuuid_boot(
230242
_check_drives(vm, assert_dict, assert_dict.keys())
231243

232244

233-
def test_partuuid_update(microvm_factory, guest_kernel, rootfs):
245+
def test_partuuid_update(uvm_vhost_user_plain_any, rootfs):
234246
"""
235247
Test successful switching from PARTUUID boot to /dev/vda boot.
236248
"""
237249

238-
vm = microvm_factory.build(guest_kernel, None, monitor_memory=False)
250+
vm = uvm_vhost_user_plain_any
239251

240252
# We need to setup ssh keys manually because we did not specify rootfs
241253
# in microvm_factory.build method
@@ -272,7 +284,7 @@ def test_partuuid_update(microvm_factory, guest_kernel, rootfs):
272284
vhost_user_block_metrics.validate(vm)
273285

274286

275-
def test_config_change(microvm_factory, guest_kernel, rootfs):
287+
def test_config_change(uvm_plain_any):
276288
"""
277289
Verify handling of block device resize.
278290
We expect that the guest will start reporting the updated size
@@ -283,7 +295,7 @@ def test_config_change(microvm_factory, guest_kernel, rootfs):
283295
new_sizes = [20, 10, 30] # MB
284296
mkfs_mount_cmd = "mkfs.ext4 /dev/vdb && mkdir -p /tmp/tmp && mount /dev/vdb /tmp/tmp && umount /tmp/tmp"
285297

286-
vm = microvm_factory.build(guest_kernel, rootfs, monitor_memory=False)
298+
vm = uvm_plain_any
287299
vm.spawn(log_level="Info")
288300
vm.basic_config()
289301
vm.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: 12 additions & 11 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()
@@ -499,11 +498,13 @@ def test_snapshot_overwrite_self(guest_kernel, rootfs, microvm_factory):
499498
# restored, with a new snapshot of this vm, does not break the VM
500499

501500

502-
def test_vmgenid(guest_kernel_linux_6_1, rootfs, microvm_factory, snapshot_type):
501+
def test_vmgenid(
502+
guest_kernel_linux_6_1, rootfs, microvm_factory, pci_enabled, snapshot_type
503+
):
503504
"""
504505
Test VMGenID device upon snapshot resume
505506
"""
506-
base_vm = microvm_factory.build(guest_kernel_linux_6_1, rootfs)
507+
base_vm = microvm_factory.build(guest_kernel_linux_6_1, rootfs, pci=pci_enabled)
507508
base_vm.spawn()
508509
base_vm.basic_config(track_dirty_pages=True)
509510
base_vm.add_net_iface()

0 commit comments

Comments
 (0)