Skip to content

Commit b5c2467

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 b8669e2 commit b5c2467

File tree

2 files changed

+44
-13
lines changed

2 files changed

+44
-13
lines changed

tests/conftest.py

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

522522

523+
def rootfs_fxt(request):
524+
"""Return a read-only rootfs."""
525+
if request.param is None:
526+
pytest.fail(f"No disk artifacts found in {ARTIFACT_DIR}")
527+
return request.param
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+
def match_rootfs_to_kernel(request):
538+
"""For 5.10, use Ubuntu as rootfs, otherwise use AL2023.
539+
Reason: AL2023 does not officially support 5.10"""
540+
for name in request.fixturenames:
541+
if name.startswith("guest_kernel"):
542+
kernel = request.getfixturevalue(name)
543+
if kernel and kernel.stem[2:] == "linux-5.10":
544+
return "ubuntu"
545+
break
546+
return "amazonlinux"
547+
548+
523549
@pytest.fixture
524-
def rootfs():
525-
"""Return an Ubuntu 24.04 read-only rootfs"""
526-
disk_list = disks("ubuntu-24.04.squashfs")
550+
def rootfs(request):
551+
"""Return a read-only rootfs. Ubuntu for 5.10, AL2023 for 6.1."""
552+
distro = match_rootfs_to_kernel(request)
553+
disk_list = disks(f"{distro}*.squashfs")
527554
if not disk_list:
528-
pytest.fail(
529-
f"No disk artifacts found matching 'ubuntu-24.04.squashfs' in {ARTIFACT_DIR}"
530-
)
555+
pytest.fail(f"No {distro} squashfs found in {ARTIFACT_DIR}")
531556
return disk_list[0]
532557

533558

534559
@pytest.fixture
535-
def rootfs_rw():
536-
"""Return an Ubuntu 24.04 ext4 rootfs"""
537-
disk_list = disks("ubuntu-24.04.ext4")
560+
def rootfs_rw(request):
561+
"""Return a writeable rootfs. Ubuntu for 5.10, AL2023 for 6.1."""
562+
distro = match_rootfs_to_kernel(request)
563+
disk_list = disks(f"{distro}*.ext4")
538564
if not disk_list:
539-
pytest.fail(
540-
f"No disk artifacts found matching 'ubuntu-24.04.ext4' in {ARTIFACT_DIR}"
541-
)
565+
pytest.fail(f"No {distro} ext4 found in {ARTIFACT_DIR}")
542566
return disk_list[0]
543567

544568

@@ -586,7 +610,7 @@ def artifact_dir():
586610
def uvm_plain_any(microvm_factory, guest_kernel, rootfs, pci_enabled):
587611
"""All guest kernels
588612
kernel: all
589-
rootfs: Ubuntu 24.04
613+
rootfs: Ubuntu for 5.10, AL2023 for 6.1
590614
"""
591615
return microvm_factory.build(guest_kernel, rootfs, pci=pci_enabled)
592616

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)