Skip to content

Commit 3290135

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 3290135

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
@@ -512,25 +512,49 @@ def guest_kernel_fxt(request, record_property):
512512
)
513513

514514

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
520+
521+
522+
def rootfs_rw_fxt(request):
523+
"""Return a writeable rootfs."""
524+
if request.param is None:
525+
pytest.fail(f"No disk artifacts found in {ARTIFACT_DIR}")
526+
return request.param
527+
528+
529+
def match_rootfs_to_kernel(request):
530+
"""For 5.10, use Ubuntu as rootfs, otherwise use AL2023.
531+
Reason: AL2023 does not officially support 5.10"""
532+
for name in request.fixturenames:
533+
if name.startswith("guest_kernel"):
534+
kernel = request.getfixturevalue(name)
535+
if kernel and kernel.stem[2:] == "linux-5.10":
536+
return "ubuntu"
537+
break
538+
return "amazonlinux"
539+
540+
515541
@pytest.fixture
516-
def rootfs():
517-
"""Return an Ubuntu 24.04 read-only rootfs"""
518-
disk_list = disks("ubuntu-24.04.squashfs")
542+
def rootfs(request):
543+
"""Return a read-only rootfs. Ubuntu for 5.10, AL2023 for 6.1."""
544+
distro = match_rootfs_to_kernel(request)
545+
disk_list = disks(f"{distro}*.squashfs")
519546
if not disk_list:
520-
pytest.fail(
521-
f"No disk artifacts found matching 'ubuntu-24.04.squashfs' in {ARTIFACT_DIR}"
522-
)
547+
pytest.fail(f"No {distro} squashfs found in {ARTIFACT_DIR}")
523548
return disk_list[0]
524549

525550

526551
@pytest.fixture
527-
def rootfs_rw():
528-
"""Return an Ubuntu 24.04 ext4 rootfs"""
529-
disk_list = disks("ubuntu-24.04.ext4")
552+
def rootfs_rw(request):
553+
"""Return a writeable rootfs. Ubuntu for 5.10, AL2023 for 6.1."""
554+
distro = match_rootfs_to_kernel(request)
555+
disk_list = disks(f"{distro}*.ext4")
530556
if not disk_list:
531-
pytest.fail(
532-
f"No disk artifacts found matching 'ubuntu-24.04.ext4' in {ARTIFACT_DIR}"
533-
)
557+
pytest.fail(f"No {distro} ext4 found in {ARTIFACT_DIR}")
534558
return disk_list[0]
535559

536560

@@ -578,7 +602,7 @@ def artifact_dir():
578602
def uvm_plain_any(microvm_factory, guest_kernel, rootfs, pci_enabled):
579603
"""All guest kernels
580604
kernel: all
581-
rootfs: Ubuntu 24.04
605+
rootfs: Ubuntu for 5.10, AL2023 for 6.1
582606
"""
583607
return microvm_factory.build(guest_kernel, rootfs, pci=pci_enabled)
584608

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)