Skip to content

Commit 950e085

Browse files
committed
WIP install: add raid1/disk variants
- addition of raid to answerfile is clunky - specification of helper VM is clunky - only deals with install for now - pycodestyle unwanted W504 line break after binary operator
1 parent 6427753 commit 950e085

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
lines changed

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: 37 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,22 @@ 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+
helper_vm.ssh(["apk add mdadm"])
141+
helper_vm.ssh(["mdadm -A /dev/md/127 -N localhost:127"])
142+
helper_vm.ssh(["mount /dev/md127p1 /mnt"])
143+
else:
144+
raise ValueError(f"unhandled system_disk {system_disk!r}")
145+
124146
try:
125147
# hostname
126148
logging.info("Setting hostname to %r", machine)
@@ -134,7 +156,7 @@ def test_tune_firstboot(self, create_vms, helper_vm_with_plugged_disk,
134156
'/mnt/etc/xensource-inventory'])
135157
helper_vm.ssh(["grep UUID /mnt/etc/xensource-inventory"])
136158
finally:
137-
helper_vm.ssh(["umount /dev/xvdb1"])
159+
helper_vm.ssh(["umount /mnt"])
138160

139161
def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=False):
140162
host_vm = create_vms[0]
@@ -290,6 +312,7 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
290312
@pytest.mark.usefixtures("xcpng_chained")
291313
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
292314
@pytest.mark.parametrize("package_source", ("iso", "net"))
315+
@pytest.mark.parametrize("system_disk", ("disk", "raid1"))
293316
@pytest.mark.parametrize("machine", ("host1", "host2"))
294317
@pytest.mark.parametrize("version", (
295318
"83nightly", "830net",
@@ -303,12 +326,12 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
303326
))
304327
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
305328
@pytest.mark.continuation_of(
306-
lambda firmware, version, machine, local_sr, package_source: [
329+
lambda firmware, version, machine, local_sr, package_source, system_disk: [
307330
dict(vm="vm1",
308331
image_test=("TestNested::test_tune_firstboot"
309-
f"[None-{firmware}-{version}-{machine}-{package_source}-{local_sr}]"))])
332+
f"[None-{firmware}-{version}-{machine}-{system_disk}-{package_source}-{local_sr}]"))])
310333
def test_boot_inst(self, create_vms,
311-
firmware, version, machine, package_source, local_sr):
334+
firmware, version, machine, package_source, system_disk, local_sr):
312335
self._test_firstboot(create_vms, version, machine=machine)
313336

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

0 commit comments

Comments
 (0)