Skip to content

Commit

Permalink
WIP installation on a disk with a Dell utility partition
Browse files Browse the repository at this point in the history
  • Loading branch information
ydirson committed Oct 10, 2024
1 parent daa623c commit 42364a8
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 12 deletions.
28 changes: 26 additions & 2 deletions tests/install/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,19 @@ def installer_iso(request):
@pytest.fixture(scope='function')
def install_disk(request):
firmware = request.getfixturevalue("firmware")
yield {"uefi": "nvme0n1", "bios": "sda"}[firmware]
if firmware.startswith("uefi"):
yield "nvme0n1"
elif firmware.startswith("bios"):
yield "sda"
else:
assert False, f"unknown firmware {firmware!r}"

@pytest.fixture(scope='function')
def answerfile_maybe_tweak_parttable(request, answerfile):
firmware = request.getfixturevalue("firmware")
if firmware.endswith("+dell"):
answerfile.top_append(dict(TAG="script", stage="installation-start",
type="url", CONTENTS="file:///root/preinstall-utilitypart.sh"))

# Remasters the ISO sepecified by `installer_iso` mark, with:
# - network and ssh support activated, and .ssh/authorized_key so tests can
Expand All @@ -127,7 +139,7 @@ def install_disk(request):
# in contexts where the same IP is reused by successively different MACs
# (when cloning VMs from cache)
@pytest.fixture(scope='function')
def remastered_iso(installer_iso, answerfile):
def remastered_iso(installer_iso, answerfile, install_disk):
iso_file = installer_iso['iso']
unsigned = installer_iso['unsigned']

Expand Down Expand Up @@ -223,6 +235,18 @@ def remastered_iso(installer_iso, answerfile):
chmod +x "$INSTALLIMG/etc/init.d/S12test-pingpxe"
fi
cat > "$INSTALLIMG/root/preinstall-utilitypart.sh" <<'EOF'
#!/bin/sh
set -ex
# Dell utility partition
sgdisk --zap-all /dev/{install_disk}
sfdisk /dev/{install_disk} << 'EOP'
unit: sectors
p1 : start= 2048, size= 32768, Id=de
EOP
EOF
cat > "$INSTALLIMG/root/postinstall.sh" <<'EOF'
#!/bin/sh
set -ex
Expand Down
24 changes: 14 additions & 10 deletions tests/install/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class TestNested:
"xs8", "ch821.1",
"xs70",
))
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
@pytest.mark.parametrize("firmware", ("uefi", "bios", "bios+dell"))
@pytest.mark.vm_definitions(
lambda firmware: dict(
name="vm1",
Expand All @@ -52,6 +52,7 @@ class TestNested:
dict(param_name="platform", key="device-model", value="qemu-upstream-uefi"),
),
"bios": (),
"bios+dell": (),
}[firmware],
vdis=[dict(name="vm1 system disk", size="100GiB", device="xvda", userdevice="0")],
cd_vbd=dict(device="xvdd", userdevice="3"),
Expand All @@ -69,7 +70,8 @@ class TestNested:
"guest-storage": "no" if local_sr == "nosr" else "yes",
"CONTENTS": install_disk},
))
def test_install(self, vm_booted_with_installer, install_disk,
def test_install(self, answerfile_maybe_tweak_parttable,
vm_booted_with_installer, install_disk,
firmware, iso_version, package_source, local_sr):
host_vm = vm_booted_with_installer
installer.monitor_install(ip=host_vm.ip)
Expand Down Expand Up @@ -107,7 +109,7 @@ def helper_vm_with_plugged_disk(running_vm, create_vms):
"ch821.1", "xs8",
"xs70",
))
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
@pytest.mark.parametrize("firmware", ("uefi", "bios", "bios+dell"))
@pytest.mark.continuation_of(
lambda version, firmware, local_sr, package_source: [dict(
vm="vm1",
Expand All @@ -117,7 +119,9 @@ def test_tune_firstboot(self, create_vms, helper_vm_with_plugged_disk,
firmware, version, machine, local_sr, package_source):
helper_vm = helper_vm_with_plugged_disk

helper_vm.ssh(["mount /dev/xvdb1 /mnt"])
main_part = "/dev/xvdb2" if firmware.endswith("+dell") else "/dev/xvdb1"

helper_vm.ssh(["mount", main_part, "/mnt"])
try:
# hostname
logging.info("Setting hostname to %r", machine)
Expand All @@ -138,7 +142,7 @@ def test_tune_firstboot(self, create_vms, helper_vm_with_plugged_disk,
'/mnt/etc/xensource-inventory'])
helper_vm.ssh(["grep UUID /mnt/etc/xensource-inventory"])
finally:
helper_vm.ssh(["umount /dev/xvdb1"])
helper_vm.ssh(["umount", main_part])

def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT'):
host_vm = create_vms[0]
Expand Down Expand Up @@ -298,7 +302,7 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT'):
"ch821.1", "xs8",
"xs70",
))
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
@pytest.mark.parametrize("firmware", ("uefi", "bios", "bios+dell"))
@pytest.mark.continuation_of(
lambda firmware, version, machine, local_sr, package_source: [
dict(vm="vm1",
Expand Down Expand Up @@ -327,7 +331,7 @@ def test_boot_inst(self, create_vms,
("821.1", "821.1"),
("75", "821.1"),
])
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
@pytest.mark.parametrize("firmware", ("uefi", "bios", "bios+dell"))
@pytest.mark.continuation_of(
lambda firmware, orig_version, machine, package_source, local_sr: [dict(
vm="vm1",
Expand Down Expand Up @@ -362,7 +366,7 @@ def test_upgrade(self, vm_booted_with_installer, install_disk,
"821.1-821.1",
"75-821.1",
))
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
@pytest.mark.parametrize("firmware", ("uefi", "bios", "bios+dell"))
@pytest.mark.continuation_of(
lambda firmware, mode, machine, package_source, local_sr: [dict(
vm="vm1",
Expand All @@ -387,7 +391,7 @@ def test_boot_upg(self, create_vms,
("83rcnet-83rcnet", "83rcnet"), # FIXME
("821.1-821.1", "821.1"),
])
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
@pytest.mark.parametrize("firmware", ("uefi", "bios", "bios+dell"))
@pytest.mark.continuation_of(
lambda firmware, orig_version, local_sr, package_source: [dict(
vm="vm1",
Expand Down Expand Up @@ -418,7 +422,7 @@ def test_restore(self, vm_booted_with_installer, install_disk,
"83rcnet-83rcnet", "83rcnet-83rcnet-83rcnet", # FIXME
"821.1-821.1-821.1",
))
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
@pytest.mark.parametrize("firmware", ("uefi", "bios", "bios+dell"))
@pytest.mark.continuation_of(
lambda firmware, mode, package_source, local_sr: [dict(
vm="vm1",
Expand Down

0 comments on commit 42364a8

Please sign in to comment.