Skip to content

Commit 47c5999

Browse files
committed
tests: modify rootfs fixtures for amazon linux
Now that we have an additional CI rootfs (amazon linux), our fixtures must be modified accordingly. For now, the default is Amazon linux, and new a new rootfs_any fixture has been created to be used by uvm_plain_any. TBD: running tests on both rootfs (via `uvm_plain_any`) adds 582 additional test cases. Do we really need this? Signed-off-by: James Curtis <jxcurtis@amazon.co.uk>
1 parent 5f3c27d commit 47c5999

2 files changed

Lines changed: 37 additions & 23 deletions

File tree

tests/conftest.py

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
import host_tools.cargo_build as build_tools
3333
from framework import defs, utils
34-
from framework.artifacts import disks, kernel_params
34+
from framework.artifacts import disk_params, kernel_params
3535
from framework.defs import ARTIFACT_DIR, DEFAULT_BINARY_DIR
3636
from framework.microvm import HugePagesConfig, MicroVMFactory, SnapshotType
3737
from framework.properties import global_props
@@ -512,26 +512,33 @@ def guest_kernel_fxt(request, record_property):
512512
)
513513

514514

515-
@pytest.fixture
516-
def rootfs():
517-
"""Return an Ubuntu 24.04 read-only rootfs"""
518-
disk_list = disks("ubuntu-24.04.squashfs")
519-
if not disk_list:
520-
pytest.fail(
521-
f"No disk artifacts found matching 'ubuntu-24.04.squashfs' in {ARTIFACT_DIR}"
522-
)
523-
return disk_list[0]
515+
def rootfs_fxt(request):
516+
"""Return a read-only rootfs."""
517+
if request.param is None:
518+
pytest.fail(f"No disk artifacts found in {ARTIFACT_DIR}")
519+
return request.param
524520

525521

526-
@pytest.fixture
527-
def rootfs_rw():
528-
"""Return an Ubuntu 24.04 ext4 rootfs"""
529-
disk_list = disks("ubuntu-24.04.ext4")
530-
if not disk_list:
531-
pytest.fail(
532-
f"No disk artifacts found matching 'ubuntu-24.04.ext4' in {ARTIFACT_DIR}"
533-
)
534-
return disk_list[0]
522+
rootfs_ubuntu = pytest.fixture(rootfs_fxt, params=disk_params("ubuntu*.squashfs"))
523+
rootfs_al = pytest.fixture(rootfs_fxt, params=disk_params("amazonlinux*.squashfs"))
524+
rootfs_any = pytest.fixture(rootfs_fxt, params=disk_params("*.squashfs"))
525+
526+
# Default ro rootfs used by tests
527+
rootfs = rootfs_ubuntu
528+
529+
530+
def rootfs_rw_fxt(request):
531+
"""Return a writeable rootfs."""
532+
if request.param is None:
533+
pytest.fail(f"No disk artifacts found in {ARTIFACT_DIR}")
534+
return request.param
535+
536+
537+
rootfs_rw_ubuntu = pytest.fixture(rootfs_rw_fxt, params=disk_params("ubuntu*.ext4"))
538+
rootfs_rw_al = pytest.fixture(rootfs_rw_fxt, params=disk_params("amazonlinux*.ext4"))
539+
540+
# Default rw rootfs used by tests
541+
rootfs_rw = rootfs_rw_ubuntu
535542

536543

537544
@pytest.fixture
@@ -575,12 +582,12 @@ def artifact_dir():
575582

576583

577584
@pytest.fixture
578-
def uvm_plain_any(microvm_factory, guest_kernel, rootfs, pci_enabled):
579-
"""All guest kernels
585+
def uvm_plain_any(microvm_factory, guest_kernel, rootfs_any, pci_enabled):
586+
"""All guest kernels and rootfs
580587
kernel: all
581-
rootfs: Ubuntu 24.04
588+
rootfs: Ubuntu 24.04 OR Amazon Linux 2023
582589
"""
583-
return microvm_factory.build(guest_kernel, rootfs, pci=pci_enabled)
590+
return microvm_factory.build(guest_kernel, rootfs_any, pci=pci_enabled)
584591

585592

586593
guest_kernel_6_1_debug = pytest.fixture(

tests/framework/artifacts.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,10 @@ def kernel_params(glob="vmlinux-*", select=kernels, artifact_dir=ARTIFACT_DIR) -
5050
return [
5151
pytest.param(kernel, id=kernel.name) for kernel in select(glob, artifact_dir)
5252
] or [pytest.param(None, id="no-kernel-found")]
53+
54+
55+
def disk_params(glob, select=disks):
56+
"""Return disk artifacts as pytest params"""
57+
return [pytest.param(disk, id=disk.stem) for disk in select(glob)] or [
58+
pytest.param(None, id="no-disk-found")
59+
]

0 commit comments

Comments
 (0)