Skip to content

Commit 21d5f8c

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 0b433dc commit 21d5f8c

2 files changed

Lines changed: 44 additions & 13 deletions

File tree

tests/conftest.py

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -532,25 +532,49 @@ def guest_kernel_fxt(request, record_property):
532532
)
533533

534534

535+
def rootfs_fxt(request):
536+
"""Return a read-only rootfs."""
537+
if request.param is None:
538+
pytest.fail(f"No disk artifacts found in {ARTIFACT_DIR}")
539+
return request.param
540+
541+
542+
def rootfs_rw_fxt(request):
543+
"""Return a writeable rootfs."""
544+
if request.param is None:
545+
pytest.fail(f"No disk artifacts found in {ARTIFACT_DIR}")
546+
return request.param
547+
548+
549+
def match_rootfs_to_kernel(request):
550+
"""For 5.10, use Ubuntu as rootfs, otherwise use AL2023.
551+
Reason: AL2023 does not officially support 5.10"""
552+
for name in request.fixturenames:
553+
if name.startswith("guest_kernel"):
554+
kernel = request.getfixturevalue(name)
555+
if kernel and kernel.stem[2:] == "linux-5.10":
556+
return "ubuntu"
557+
break
558+
return "amazonlinux"
559+
560+
535561
@pytest.fixture
536-
def rootfs():
537-
"""Return an Ubuntu 24.04 read-only rootfs"""
538-
disk_list = disks("ubuntu-24.04.squashfs")
562+
def rootfs(request):
563+
"""Return a read-only rootfs. Ubuntu for 5.10, AL2023 for 6.1."""
564+
distro = match_rootfs_to_kernel(request)
565+
disk_list = disks(f"{distro}*.squashfs")
539566
if not disk_list:
540-
pytest.fail(
541-
f"No disk artifacts found matching 'ubuntu-24.04.squashfs' in {ARTIFACT_DIR}"
542-
)
567+
pytest.fail(f"No {distro} squashfs found in {ARTIFACT_DIR}")
543568
return disk_list[0]
544569

545570

546571
@pytest.fixture
547-
def rootfs_rw():
548-
"""Return an Ubuntu 24.04 ext4 rootfs"""
549-
disk_list = disks("ubuntu-24.04.ext4")
572+
def rootfs_rw(request):
573+
"""Return a writeable rootfs. Ubuntu for 5.10, AL2023 for 6.1."""
574+
distro = match_rootfs_to_kernel(request)
575+
disk_list = disks(f"{distro}*.ext4")
550576
if not disk_list:
551-
pytest.fail(
552-
f"No disk artifacts found matching 'ubuntu-24.04.ext4' in {ARTIFACT_DIR}"
553-
)
577+
pytest.fail(f"No {distro} ext4 found in {ARTIFACT_DIR}")
554578
return disk_list[0]
555579

556580

@@ -598,7 +622,7 @@ def artifact_dir():
598622
def uvm_plain_any(microvm_factory, guest_kernel, rootfs, pci_enabled):
599623
"""All guest kernels
600624
kernel: all
601-
rootfs: Ubuntu 24.04
625+
rootfs: Ubuntu for 5.10, AL2023 for 6.1
602626
"""
603627
return microvm_factory.build(guest_kernel, rootfs, pci=pci_enabled)
604628

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)