Skip to content

Commit 14d1ffc

Browse files
committed
WIP install: add raid1/disk variants
- addition of raid to answerfile is clunky - only deals with install for now
1 parent c7be8ca commit 14d1ffc

File tree

3 files changed

+43
-17
lines changed

3 files changed

+43
-17
lines changed

lib/typing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
# field's type, but allows them in places we wouldn't want them,
2626
# and forces every XML attribute we use to appear here.
2727
# NOTE: duplicated below, TypedDict() expects a dictionary literal as the second argument
28+
'device': NotRequired[str],
2829
'guest-storage': NotRequired[str],
2930
'mode': NotRequired[str],
3031
'name': NotRequired[str],
@@ -42,6 +43,7 @@
4243
# field's type, but allows them in places we wouldn't want them,
4344
# and forces every XML attribute we use to appear here.
4445
# NOTE: duplicated above, TypedDict() expects a dictionary literal as the second argument
46+
'device': NotRequired[str],
4547
'guest-storage': NotRequired[str],
4648
'mode': NotRequired[str],
4749
'name': NotRequired[str],

tests/install/test-sequences/inst.lst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
tests/install/test.py::TestNested::test_install[uefi-83nightly-iso-ext]
2-
tests/install/test.py::TestNested::test_tune_firstboot[None-uefi-83nightly-host1-iso-ext]
3-
tests/install/test.py::TestNested::test_boot_inst[uefi-83nightly-host1-iso-ext]
1+
tests/install/test.py::TestNested::test_install[uefi-83nightly-disk-iso-ext]
2+
tests/install/test.py::TestNested::test_tune_firstboot[None-uefi-83nightly-host1-disk-iso-ext]
3+
tests/install/test.py::TestNested::test_boot_inst[uefi-83nightly-host1-disk-iso-ext]

tests/install/test.py

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def helper_vm_with_plugged_disk(running_vm, create_vms):
4343
class TestNested:
4444
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
4545
@pytest.mark.parametrize("package_source", ("iso", "net"))
46+
@pytest.mark.parametrize("system_disk", ("disk", "raid1"))
4647
@pytest.mark.parametrize("iso_version", (
4748
"83nightly", "830net",
4849
"830",
@@ -54,7 +55,7 @@ class TestNested:
5455
))
5556
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
5657
@pytest.mark.vm_definitions(
57-
lambda firmware: dict(
58+
lambda firmware, system_disk: dict(
5859
name="vm1",
5960
template="Other install media",
6061
params=(
@@ -74,31 +75,45 @@ class TestNested:
7475
),
7576
"bios": (),
7677
}[firmware],
77-
vdis=[dict(name="vm1 system disk", size="100GiB", device="xvda", userdevice="0")],
78+
vdis=([dict(name="vm1 system disk", size="100GiB", device="xvda", userdevice="0")]
79+
+ ([dict(name="vm1 system disk mirror", size="100GiB", device="xvdb", userdevice="1")]
80+
if system_disk == "raid1" else [])
81+
),
7882
cd_vbd=dict(device="xvdd", userdevice="3"),
7983
vifs=[dict(index=0, network_name=NETWORKS["MGMT"])],
8084
))
8185
@pytest.mark.answerfile(
82-
lambda install_disk, local_sr, package_source, iso_version: AnswerFile("INSTALL")
86+
lambda firmware, install_disk, local_sr, package_source, system_disk, iso_version: AnswerFile("INSTALL")
8387
.top_setattr({} if local_sr == "nosr" else {"sr-type": local_sr})
8488
.top_append(
8589
{"TAG": "source", "type": "local"} if package_source == "iso"
8690
else {"TAG": "source", "type": "url",
8791
"CONTENTS": ISO_IMAGES[iso_version]['net-url']} if package_source == "net"
8892
else ValueError(f"package_source {package_source!r}"),
93+
94+
# FIXME belongs to a generalization of install_disk fixture
95+
{"TAG": "raid", "device": "md127",
96+
"CONTENTS": (
97+
{"TAG": "disk", "CONTENTS": {"bios": "sda", "uefi": "nvme0n1"}[firmware]},
98+
{"TAG": "disk", "CONTENTS": {"bios": "sdb", "uefi": "nvme0n2"}[firmware]},
99+
)} if system_disk == "raid1"
100+
else None if system_disk == "disk"
101+
else ValueError(f"system_disk {system_disk!r}"),
102+
89103
{"TAG": "admin-interface", "name": "eth0", "proto": "dhcp"},
90104
{"TAG": "primary-disk",
91105
"guest-storage": "no" if local_sr == "nosr" else "yes",
92-
"CONTENTS": install_disk},
106+
"CONTENTS": "md127" if system_disk == "raid1" else install_disk},
93107
))
94108
def test_install(self, vm_booted_with_installer, install_disk,
95-
firmware, iso_version, package_source, local_sr):
109+
firmware, iso_version, package_source, system_disk, local_sr):
96110
host_vm = vm_booted_with_installer
97111
installer.monitor_install(ip=host_vm.ip)
98112

99113
@pytest.mark.usefixtures("xcpng_chained")
100114
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
101115
@pytest.mark.parametrize("package_source", ("iso", "net"))
116+
@pytest.mark.parametrize("system_disk", ("disk", "raid1"))
102117
@pytest.mark.parametrize("machine", ("host1", "host2"))
103118
@pytest.mark.parametrize("version", (
104119
"83nightly", "830net",
@@ -112,15 +127,23 @@ def test_install(self, vm_booted_with_installer, install_disk,
112127
))
113128
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
114129
@pytest.mark.continuation_of(
115-
lambda version, firmware, local_sr, package_source: [dict(
130+
lambda version, firmware, local_sr, package_source, system_disk: [dict(
116131
vm="vm1",
117-
image_test=f"TestNested::test_install[{firmware}-{version}-{package_source}-{local_sr}]")])
118-
@pytest.mark.small_vm
132+
image_test=f"TestNested::test_install[{firmware}-{version}-{system_disk}-{package_source}-{local_sr}]")])
119133
def test_tune_firstboot(self, create_vms, helper_vm_with_plugged_disk,
120-
firmware, version, machine, local_sr, package_source):
134+
firmware, version, machine, local_sr, package_source, system_disk):
121135
helper_vm = helper_vm_with_plugged_disk
122136

123-
helper_vm.ssh(["mount /dev/xvdb1 /mnt"])
137+
if system_disk == "disk":
138+
helper_vm.ssh(["mount /dev/xvdb1 /mnt"])
139+
elif system_disk == "raid1":
140+
# FIXME helper VM has to be an Alpine, that should not be a random vm_ref
141+
helper_vm.ssh(["apk add mdadm"])
142+
helper_vm.ssh(["mdadm -A /dev/md/127 -N localhost:127"])
143+
helper_vm.ssh(["mount /dev/md127p1 /mnt"])
144+
else:
145+
raise ValueError(f"unhandled system_disk {system_disk!r}")
146+
124147
try:
125148
# hostname
126149
logging.info("Setting hostname to %r", machine)
@@ -134,7 +157,7 @@ def test_tune_firstboot(self, create_vms, helper_vm_with_plugged_disk,
134157
'/mnt/etc/xensource-inventory'])
135158
helper_vm.ssh(["grep UUID /mnt/etc/xensource-inventory"])
136159
finally:
137-
helper_vm.ssh(["umount /dev/xvdb1"])
160+
helper_vm.ssh(["umount /mnt"])
138161

139162
def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=False):
140163
host_vm = create_vms[0]
@@ -290,6 +313,7 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
290313
@pytest.mark.usefixtures("xcpng_chained")
291314
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
292315
@pytest.mark.parametrize("package_source", ("iso", "net"))
316+
@pytest.mark.parametrize("system_disk", ("disk", "raid1"))
293317
@pytest.mark.parametrize("machine", ("host1", "host2"))
294318
@pytest.mark.parametrize("version", (
295319
"83nightly", "830net",
@@ -303,12 +327,12 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
303327
))
304328
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
305329
@pytest.mark.continuation_of(
306-
lambda firmware, version, machine, local_sr, package_source: [
330+
lambda firmware, version, machine, local_sr, package_source, system_disk: [
307331
dict(vm="vm1",
308332
image_test=("TestNested::test_tune_firstboot"
309-
f"[None-{firmware}-{version}-{machine}-{package_source}-{local_sr}]"))])
333+
f"[None-{firmware}-{version}-{machine}-{system_disk}-{package_source}-{local_sr}]"))])
310334
def test_boot_inst(self, create_vms,
311-
firmware, version, machine, package_source, local_sr):
335+
firmware, version, machine, package_source, system_disk, local_sr):
312336
self._test_firstboot(create_vms, version, machine=machine)
313337

314338
@pytest.mark.usefixtures("xcpng_chained")

0 commit comments

Comments
 (0)