Skip to content

Commit

Permalink
test: rename drop ubuntu version from rootfs fixture
Browse files Browse the repository at this point in the history
It is unlikely that we will ever support more than one rootfs.

Signed-off-by: Pablo Barbáchano <[email protected]>
  • Loading branch information
pb8o committed Oct 23, 2024
1 parent a9b06ad commit c780883
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 83 deletions.
13 changes: 5 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,20 +400,17 @@ def rootfs_fxt(request, record_property):
)

# Fixtures for all Ubuntu rootfs, and specific versions
rootfs = pytest.fixture(rootfs_fxt, params=rootfs_params("*.squashfs"))
rootfs_ubuntu_24 = pytest.fixture(
rootfs_fxt, params=rootfs_params("ubuntu-24*.squashfs")
)
rootfs = pytest.fixture(rootfs_fxt, params=rootfs_params("ubuntu-24*.squashfs"))
rootfs_rw = pytest.fixture(rootfs_fxt, params=rootfs_params("*.ext4"))


@pytest.fixture
def uvm_plain(microvm_factory, guest_kernel_linux_5_10, rootfs_ubuntu_24):
def uvm_plain(microvm_factory, guest_kernel_linux_5_10, rootfs):
"""Create a vanilla VM, non-parametrized
kernel: 5.10
rootfs: Ubuntu 24.04
"""
return microvm_factory.build(guest_kernel_linux_5_10, rootfs_ubuntu_24)
return microvm_factory.build(guest_kernel_linux_5_10, rootfs)


@pytest.fixture
Expand Down Expand Up @@ -442,12 +439,12 @@ def artifact_dir():


@pytest.fixture
def uvm_plain_any(microvm_factory, guest_kernel, rootfs_ubuntu_24):
def uvm_plain_any(microvm_factory, guest_kernel, rootfs):
"""All guest kernels
kernel: all
rootfs: Ubuntu 24.04
"""
return microvm_factory.build(guest_kernel, rootfs_ubuntu_24)
return microvm_factory.build(guest_kernel, rootfs)


guest_kernel_6_1_debug = pytest.fixture(
Expand Down
16 changes: 6 additions & 10 deletions tests/integration_tests/functional/test_cpu_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def msr_cpu_template_fxt(request):
@pytest.mark.timeout(900)
@pytest.mark.nonci
def test_cpu_rdmsr(
microvm_factory, msr_cpu_template, guest_kernel, rootfs_ubuntu_24, results_dir
microvm_factory, msr_cpu_template, guest_kernel, rootfs, results_dir
):
"""
Test MSRs that are available to the guest.
Expand Down Expand Up @@ -307,7 +307,7 @@ def test_cpu_rdmsr(
"""

vcpus, guest_mem_mib = 1, 1024
vm = microvm_factory.build(guest_kernel, rootfs_ubuntu_24, monitor_memory=False)
vm = microvm_factory.build(guest_kernel, rootfs, monitor_memory=False)
vm.spawn()
vm.add_net_iface()
vm.basic_config(
Expand Down Expand Up @@ -376,9 +376,7 @@ def dump_msr_state_to_file(dump_fname, ssh_conn, shared_names):
)
@pytest.mark.timeout(900)
@pytest.mark.nonci
def test_cpu_wrmsr_snapshot(
microvm_factory, guest_kernel, rootfs_ubuntu_24, msr_cpu_template
):
def test_cpu_wrmsr_snapshot(microvm_factory, guest_kernel, rootfs, msr_cpu_template):
"""
This is the first part of the test verifying
that MSRs retain their values after restoring from a snapshot.
Expand All @@ -398,7 +396,7 @@ def test_cpu_wrmsr_snapshot(
shared_names = SNAPSHOT_RESTORE_SHARED_NAMES

vcpus, guest_mem_mib = 1, 1024
vm = microvm_factory.build(guest_kernel, rootfs_ubuntu_24, monitor_memory=False)
vm = microvm_factory.build(guest_kernel, rootfs, monitor_memory=False)
vm.spawn()
vm.add_net_iface()
vm.basic_config(
Expand Down Expand Up @@ -533,9 +531,7 @@ def dump_cpuid_to_file(dump_fname, ssh_conn):
)
@pytest.mark.timeout(900)
@pytest.mark.nonci
def test_cpu_cpuid_snapshot(
microvm_factory, guest_kernel, rootfs_ubuntu_24, msr_cpu_template
):
def test_cpu_cpuid_snapshot(microvm_factory, guest_kernel, rootfs, msr_cpu_template):
"""
This is the first part of the test verifying
that CPUID remains the same after restoring from a snapshot.
Expand All @@ -551,7 +547,7 @@ def test_cpu_cpuid_snapshot(

vm = microvm_factory.build(
kernel=guest_kernel,
rootfs=rootfs_ubuntu_24,
rootfs=rootfs,
)
vm.spawn()
vm.add_net_iface()
Expand Down
12 changes: 6 additions & 6 deletions tests/integration_tests/functional/test_cpu_features_aarch64.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ def get_cpu_template_dir(cpu_template):
PLATFORM != "aarch64",
reason="This is aarch64 specific test.",
)
def test_default_cpu_features(microvm_factory, guest_kernel, rootfs_ubuntu_24):
def test_default_cpu_features(microvm_factory, guest_kernel, rootfs):
"""
Check the CPU features for a microvm with the specified config.
"""

vm = microvm_factory.build(guest_kernel, rootfs_ubuntu_24, monitor_memory=False)
vm = microvm_factory.build(guest_kernel, rootfs, monitor_memory=False)
vm.spawn()
vm.basic_config()
vm.add_net_iface()
Expand All @@ -86,13 +86,13 @@ def test_default_cpu_features(microvm_factory, guest_kernel, rootfs_ubuntu_24):
reason="This is aarch64 specific test.",
)
def test_cpu_features_with_static_template(
microvm_factory, guest_kernel, rootfs_ubuntu_24, cpu_template
microvm_factory, guest_kernel, rootfs, cpu_template
):
"""
Check the CPU features for a microvm with the specified config.
"""

vm = microvm_factory.build(guest_kernel, rootfs_ubuntu_24, monitor_memory=False)
vm = microvm_factory.build(guest_kernel, rootfs, monitor_memory=False)
vm.spawn()
vm.basic_config(cpu_template=cpu_template)
vm.add_net_iface()
Expand All @@ -114,13 +114,13 @@ def test_cpu_features_with_static_template(
reason="This is aarch64 specific test.",
)
def test_cpu_features_with_custom_template(
microvm_factory, guest_kernel, rootfs_ubuntu_24, custom_cpu_template
microvm_factory, guest_kernel, rootfs, custom_cpu_template
):
"""
Check the CPU features for a microvm with the specified config.
"""

vm = microvm_factory.build(guest_kernel, rootfs_ubuntu_24, monitor_memory=False)
vm = microvm_factory.build(guest_kernel, rootfs, monitor_memory=False)
vm.spawn()
vm.basic_config()
vm.api.cpu_config.put(**custom_cpu_template["template"])
Expand Down
52 changes: 21 additions & 31 deletions tests/integration_tests/functional/test_drive_vhost_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _check_drives(test_microvm, assert_dict, keys_array):
assert blockdev_out_line_cols[col] == assert_dict[key]


def test_vhost_user_block(microvm_factory, guest_kernel, rootfs_ubuntu_24):
def test_vhost_user_block(microvm_factory, guest_kernel, rootfs):
"""
This test simply tries to boot a VM with
vhost-user-block as a root device.
Expand All @@ -44,13 +44,11 @@ def test_vhost_user_block(microvm_factory, guest_kernel, rootfs_ubuntu_24):

# We need to setup ssh keys manually because we did not specify rootfs
# in microvm_factory.build method
ssh_key = rootfs_ubuntu_24.with_suffix(".id_rsa")
ssh_key = rootfs.with_suffix(".id_rsa")
vm.ssh_key = ssh_key
vm.spawn()
vm.basic_config(add_root_device=False)
vm.add_vhost_user_drive(
"rootfs", rootfs_ubuntu_24, is_root_device=True, is_read_only=True
)
vm.add_vhost_user_drive("rootfs", rootfs, is_root_device=True, is_read_only=True)
vm.add_net_iface()
vhost_user_block_metrics = FcDeviceMetrics(
"vhost_user_block", 1, aggr_supported=False
Expand All @@ -67,7 +65,7 @@ def test_vhost_user_block(microvm_factory, guest_kernel, rootfs_ubuntu_24):
vhost_user_block_metrics.validate(vm)


def test_vhost_user_block_read_write(microvm_factory, guest_kernel, rootfs_ubuntu_24):
def test_vhost_user_block_read_write(microvm_factory, guest_kernel, rootfs):
"""
This test simply tries to boot a VM with
vhost-user-block as a root device.
Expand All @@ -78,14 +76,14 @@ def test_vhost_user_block_read_write(microvm_factory, guest_kernel, rootfs_ubunt

# We need to setup ssh keys manually because we did not specify rootfs
# in microvm_factory.build method
ssh_key = rootfs_ubuntu_24.with_suffix(".id_rsa")
ssh_key = rootfs.with_suffix(".id_rsa")
vm.ssh_key = ssh_key
vm.spawn()
vm.basic_config(add_root_device=False)

# Create a rw rootfs file that is unique to the microVM
rootfs_rw = Path(vm.chroot()) / "rootfs"
shutil.copy(rootfs_ubuntu_24, rootfs_rw)
shutil.copy(rootfs, rootfs_rw)

vm.add_vhost_user_drive("rootfs", rootfs_rw, is_root_device=True)
vm.add_net_iface()
Expand All @@ -100,7 +98,7 @@ def test_vhost_user_block_read_write(microvm_factory, guest_kernel, rootfs_ubunt
_check_drives(vm, assert_dict, assert_dict.keys())


def test_vhost_user_block_disconnect(microvm_factory, guest_kernel, rootfs_ubuntu_24):
def test_vhost_user_block_disconnect(microvm_factory, guest_kernel, rootfs):
"""
Test that even if backend is killed, Firecracker is still responsive.
"""
Expand All @@ -109,13 +107,11 @@ def test_vhost_user_block_disconnect(microvm_factory, guest_kernel, rootfs_ubunt

# We need to set up ssh keys manually because we did not specify rootfs
# in microvm_factory.build method
ssh_key = rootfs_ubuntu_24.with_suffix(".id_rsa")
ssh_key = rootfs.with_suffix(".id_rsa")
vm.ssh_key = ssh_key
vm.spawn()
vm.basic_config(add_root_device=False)
vm.add_vhost_user_drive(
"rootfs", rootfs_ubuntu_24, is_root_device=True, is_read_only=True
)
vm.add_vhost_user_drive("rootfs", rootfs, is_root_device=True, is_read_only=True)
vm.add_net_iface()
vm.start()

Expand All @@ -127,7 +123,7 @@ def test_vhost_user_block_disconnect(microvm_factory, guest_kernel, rootfs_ubunt
_config = vm.api.vm_config.get().json()


def test_device_ordering(microvm_factory, guest_kernel, rootfs_ubuntu_24):
def test_device_ordering(microvm_factory, guest_kernel, rootfs):
"""
Verify device ordering.
Expand All @@ -139,7 +135,7 @@ def test_device_ordering(microvm_factory, guest_kernel, rootfs_ubuntu_24):

# We need to setup ssh keys manually because we did not specify rootfs
# in microvm_factory.build method
ssh_key = rootfs_ubuntu_24.with_suffix(".id_rsa")
ssh_key = rootfs.with_suffix(".id_rsa")
vm.ssh_key = ssh_key
vm.spawn()
vm.basic_config(add_root_device=False)
Expand All @@ -150,17 +146,15 @@ def test_device_ordering(microvm_factory, guest_kernel, rootfs_ubuntu_24):
vm.add_drive("scratch1", fs1.path)

# Adding second block device (rootfs)
vm.add_vhost_user_drive(
"rootfs", rootfs_ubuntu_24, is_root_device=True, is_read_only=True
)
vm.add_vhost_user_drive("rootfs", rootfs, is_root_device=True, is_read_only=True)

# Adding third block device.
fs2 = drive_tools.FilesystemFile(os.path.join(vm.fsfiles, "scratch2"), size=512)
vm.add_drive("scratch2", fs2.path)

# Create a rw rootfs file that is unique to the microVM
rootfs_rw = Path(vm.chroot()) / "rootfs"
shutil.copy(rootfs_ubuntu_24, rootfs_rw)
shutil.copy(rootfs, rootfs_rw)

# Adding forth block device.
vm.add_vhost_user_drive("dummy_rootfs", rootfs_rw)
Expand All @@ -171,7 +165,7 @@ def test_device_ordering(microvm_factory, guest_kernel, rootfs_ubuntu_24):
)
vm.start()

rootfs_size = rootfs_ubuntu_24.stat().st_size
rootfs_size = rootfs.stat().st_size

# The devices were added in this order: fs1, rootfs, fs2. fs3
# However, the rootfs is the root device and goes first,
Expand Down Expand Up @@ -203,7 +197,7 @@ def test_device_ordering(microvm_factory, guest_kernel, rootfs_ubuntu_24):
def test_partuuid_boot(
microvm_factory,
guest_kernel,
rootfs_ubuntu_24,
rootfs,
):
"""
Test the output reported by blockdev when booting with PARTUUID.
Expand All @@ -213,15 +207,13 @@ def test_partuuid_boot(

# We need to setup ssh keys manually because we did not specify rootfs
# in microvm_factory.build method
ssh_key = rootfs_ubuntu_24.with_suffix(".id_rsa")
ssh_key = rootfs.with_suffix(".id_rsa")
vm.ssh_key = ssh_key
vm.spawn()
vm.basic_config(add_root_device=False)

# Create a rootfs with partuuid unique to this microVM
partuuid, disk_path = partuuid_and_disk_path(
rootfs_ubuntu_24, Path(vm.chroot()) / "disk.img"
)
partuuid, disk_path = partuuid_and_disk_path(rootfs, Path(vm.chroot()) / "disk.img")

vm.add_vhost_user_drive(
"1", disk_path, is_root_device=True, partuuid=partuuid, is_read_only=True
Expand All @@ -238,7 +230,7 @@ def test_partuuid_boot(
_check_drives(vm, assert_dict, assert_dict.keys())


def test_partuuid_update(microvm_factory, guest_kernel, rootfs_ubuntu_24):
def test_partuuid_update(microvm_factory, guest_kernel, rootfs):
"""
Test successful switching from PARTUUID boot to /dev/vda boot.
"""
Expand All @@ -247,7 +239,7 @@ def test_partuuid_update(microvm_factory, guest_kernel, rootfs_ubuntu_24):

# We need to setup ssh keys manually because we did not specify rootfs
# in microvm_factory.build method
ssh_key = rootfs_ubuntu_24.with_suffix(".id_rsa")
ssh_key = rootfs.with_suffix(".id_rsa")
vm.ssh_key = ssh_key
vm.spawn()
vm.basic_config(add_root_device=False)
Expand All @@ -256,16 +248,14 @@ def test_partuuid_update(microvm_factory, guest_kernel, rootfs_ubuntu_24):
# Add the root block device specified through PARTUUID.
vm.add_vhost_user_drive(
"rootfs",
rootfs_ubuntu_24,
rootfs,
is_root_device=True,
partuuid="0eaa91a0-01",
is_read_only=True,
)

# Adding a drive with the same ID creates another backend with another socket.
vm.add_vhost_user_drive(
"rootfs", rootfs_ubuntu_24, is_root_device=True, is_read_only=True
)
vm.add_vhost_user_drive("rootfs", rootfs, is_root_device=True, is_read_only=True)

vhost_user_block_metrics = FcDeviceMetrics(
"vhost_user_block", 1, aggr_supported=False
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/functional/test_drive_virtio.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@


@pytest.fixture
def partuuid_and_disk_path_tmpfs(rootfs_ubuntu_24, tmp_path):
def partuuid_and_disk_path_tmpfs(rootfs, tmp_path):
"""
We create a new file in tmpfs, get its partuuid and use it as a rootfs.
"""
disk_path = tmp_path / "disk.img"
yield partuuid_and_disk_path(rootfs_ubuntu_24, disk_path)
yield partuuid_and_disk_path(rootfs, disk_path)
disk_path.unlink()


Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/functional/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ def test_tap_offload_booted(uvm_plain_any):
run_udp_offload_test(vm)


def test_tap_offload_restored(microvm_factory, guest_kernel, rootfs_ubuntu_24):
def test_tap_offload_restored(microvm_factory, guest_kernel, rootfs):
"""
Verify that tap offload features are configured for a restored VM.
"""
src = microvm_factory.build(guest_kernel, rootfs_ubuntu_24, monitor_memory=False)
src = microvm_factory.build(guest_kernel, rootfs, monitor_memory=False)
src.spawn()
src.basic_config()
src.add_net_iface()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def mount_tmpfs_small(worker_id):


def test_diff_snapshot_works_after_error(
microvm_factory, guest_kernel_linux_5_10, rootfs_ubuntu_24, mount_tmpfs_small
microvm_factory, guest_kernel_linux_5_10, rootfs, mount_tmpfs_small
):
"""
Test that if a partial snapshot errors it will work after and not lose data
"""
uvm = microvm_factory.build(
guest_kernel_linux_5_10,
rootfs_ubuntu_24,
rootfs,
jailer_kwargs={"chroot_base": mount_tmpfs_small},
)

Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/functional/test_snapshot_phase1.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

@pytest.mark.nonci
def test_snapshot_phase1(
microvm_factory, guest_kernel, rootfs_ubuntu_24, cpu_template_any, results_dir
microvm_factory, guest_kernel, rootfs, cpu_template_any, results_dir
):
"""Create a snapshot and save it to disk"""

vm = microvm_factory.build(guest_kernel, rootfs_ubuntu_24, monitor_memory=False)
vm = microvm_factory.build(guest_kernel, rootfs, monitor_memory=False)
vm.spawn(log_level="Info")
vm.add_net_iface()

Expand Down
Loading

0 comments on commit c780883

Please sign in to comment.