Skip to content

Commit a76a06e

Browse files
committed
install: add raid1/disk variants
Adds a new system_disk test parameter to distinguish raid1 setup from (pre-existing) single-disk one. Adds Alpine-specific setup for tune_firstboot to manually assemble the RAID. Signed-off-by: Yann Dirson <[email protected]>
1 parent 16a0db1 commit a76a06e

File tree

6 files changed

+89
-38
lines changed

6 files changed

+89
-38
lines changed

lib/typing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# No way to allow arbitrary fields in addition? This conveys the
3232
# field's type, but allows them in places we wouldn't want them,
3333
# and forces every XML attribute we use to appear here.
34+
'device': NotRequired[str],
3435
'guest-storage': NotRequired[str],
3536
'mode': NotRequired[str],
3637
'name': NotRequired[str],

tests/install/conftest.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,15 @@ def installer_iso(request):
9898
@pytest.fixture(scope='function')
9999
def system_disks_names(request):
100100
firmware = request.getfixturevalue("firmware")
101-
yield {"uefi": "nvme0n1", "bios": "sda"}[firmware]
101+
system_disk_config = request.getfixturevalue("system_disk_config")
102+
yield (
103+
({"uefi": "nvme0n1", "bios": "sda"}[firmware],)
104+
+ (
105+
{"raid1": {"uefi": "nvme0n2", "bios": "sdb"}[firmware],
106+
"disk": (),
107+
}[system_disk_config],
108+
)
109+
)
102110

103111
# Remasters the ISO sepecified by `installer_iso` mark, with:
104112
# - network and ssh support activated, and .ssh/authorized_key so tests can
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
tests/install/test.py::TestNested::test_restore[uefi-83nightly-83nightly-83nightly-iso-ext]
2-
tests/install/test.py::TestNested::test_boot_rst[uefi-83nightly-83nightly-83nightly-iso-ext]
1+
tests/install/test.py::TestNested::test_restore[uefi-83nightly-83nightly-83nightly-disk-iso-ext]
2+
tests/install/test.py::TestNested::test_boot_rst[uefi-83nightly-83nightly-83nightly-disk-iso-ext]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
tests/install/test.py::TestNested::test_upgrade[uefi-83nightly-83nightly-host1-iso-ext]
2-
tests/install/test.py::TestNested::test_boot_upg[uefi-83nightly-83nightly-host1-iso-ext]
1+
tests/install/test.py::TestNested::test_upgrade[uefi-83nightly-83nightly-host1-disk-iso-ext]
2+
tests/install/test.py::TestNested::test_boot_upg[uefi-83nightly-83nightly-host1-disk-iso-ext]

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: 72 additions & 30 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_config", ("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_config: dict(
5859
name="vm1",
5960
template="Other install media",
6061
params=(
@@ -74,31 +75,46 @@ 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_config == "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 system_disks_names, local_sr, package_source, iso_version: AnswerFile("INSTALL")
86+
lambda system_disks_names, local_sr, package_source, system_disk_config, iso_version: AnswerFile("INSTALL")
8387
.top_setattr({} if local_sr == "nosr" else {"sr-type": local_sr})
8488
.top_append(
8589
{"iso": {"TAG": "source", "type": "local"},
8690
"net": {"TAG": "source", "type": "url",
8791
"CONTENTS": ISO_IMAGES[iso_version]['net-url']},
8892
}[package_source],
93+
94+
{"raid1": {"TAG": "raid", "device": "md127",
95+
"CONTENTS": [
96+
{"TAG": "disk", "CONTENTS": diskname} for diskname in system_disks_names
97+
]},
98+
"disk": None,
99+
}[system_disk_config],
100+
89101
{"TAG": "admin-interface", "name": "eth0", "proto": "dhcp"},
90102
{"TAG": "primary-disk",
91103
"guest-storage": "no" if local_sr == "nosr" else "yes",
92-
"CONTENTS": system_disks_names[0]},
104+
"CONTENTS": {"disk": system_disks_names[0],
105+
"raid1": "md127",
106+
}[system_disk_config],
107+
},
93108
))
94109
def test_install(self, vm_booted_with_installer, system_disks_names,
95-
firmware, iso_version, package_source, local_sr):
110+
firmware, iso_version, package_source, system_disk_config, local_sr):
96111
host_vm = vm_booted_with_installer
97112
installer.monitor_install(ip=host_vm.ip)
98113

99114
@pytest.mark.usefixtures("xcpng_chained")
100115
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
101116
@pytest.mark.parametrize("package_source", ("iso", "net"))
117+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
102118
@pytest.mark.parametrize("machine", ("host1", "host2"))
103119
@pytest.mark.parametrize("version", (
104120
"83nightly", "830net",
@@ -112,15 +128,24 @@ def test_install(self, vm_booted_with_installer, system_disks_names,
112128
))
113129
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
114130
@pytest.mark.continuation_of(
115-
lambda version, firmware, local_sr, package_source: [dict(
131+
lambda version, firmware, local_sr, package_source, system_disk_config: [dict(
116132
vm="vm1",
117-
image_test=f"TestNested::test_install[{firmware}-{version}-{package_source}-{local_sr}]")])
118-
@pytest.mark.small_vm
133+
image_test=(f"TestNested::test_install[{firmware}-{version}-{system_disk_config}"
134+
f"-{package_source}-{local_sr}]"))])
119135
def test_tune_firstboot(self, create_vms, helper_vm_with_plugged_disk,
120-
firmware, version, machine, local_sr, package_source):
136+
firmware, version, machine, local_sr, package_source, system_disk_config):
121137
helper_vm = helper_vm_with_plugged_disk
122138

123-
helper_vm.ssh(["mount /dev/xvdb1 /mnt"])
139+
if system_disk_config == "disk":
140+
helper_vm.ssh(["mount /dev/xvdb1 /mnt"])
141+
elif system_disk_config == "raid1":
142+
# FIXME helper VM has to be an Alpine, that should not be a random vm_ref
143+
helper_vm.ssh(["apk add mdadm"])
144+
helper_vm.ssh(["mdadm -A /dev/md/127 -N localhost:127"])
145+
helper_vm.ssh(["mount /dev/md127p1 /mnt"])
146+
else:
147+
raise ValueError(f"unhandled system_disk_config {system_disk_config!r}")
148+
124149
try:
125150
# hostname
126151
logging.info("Setting hostname to %r", machine)
@@ -134,7 +159,7 @@ def test_tune_firstboot(self, create_vms, helper_vm_with_plugged_disk,
134159
'/mnt/etc/xensource-inventory'])
135160
helper_vm.ssh(["grep UUID /mnt/etc/xensource-inventory"])
136161
finally:
137-
helper_vm.ssh(["umount /dev/xvdb1"])
162+
helper_vm.ssh(["umount /mnt"])
138163

139164
def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=False):
140165
host_vm = create_vms[0]
@@ -290,6 +315,7 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
290315
@pytest.mark.usefixtures("xcpng_chained")
291316
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
292317
@pytest.mark.parametrize("package_source", ("iso", "net"))
318+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
293319
@pytest.mark.parametrize("machine", ("host1", "host2"))
294320
@pytest.mark.parametrize("version", (
295321
"83nightly", "830net",
@@ -303,17 +329,19 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
303329
))
304330
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
305331
@pytest.mark.continuation_of(
306-
lambda firmware, version, machine, local_sr, package_source: [
332+
lambda firmware, version, machine, local_sr, package_source, system_disk_config: [
307333
dict(vm="vm1",
308334
image_test=("TestNested::test_tune_firstboot"
309-
f"[None-{firmware}-{version}-{machine}-{package_source}-{local_sr}]"))])
335+
f"[None-{firmware}-{version}-{machine}-{system_disk_config}"
336+
f"-{package_source}-{local_sr}]"))])
310337
def test_boot_inst(self, create_vms,
311-
firmware, version, machine, package_source, local_sr):
338+
firmware, version, machine, package_source, system_disk_config, local_sr):
312339
self._test_firstboot(create_vms, version, machine=machine)
313340

314341
@pytest.mark.usefixtures("xcpng_chained")
315342
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
316343
@pytest.mark.parametrize("package_source", ("iso", "net"))
344+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
317345
@pytest.mark.parametrize("machine", ("host1", "host2"))
318346
@pytest.mark.parametrize(("orig_version", "iso_version"), [
319347
("83nightly", "83nightly"),
@@ -330,26 +358,32 @@ def test_boot_inst(self, create_vms,
330358
])
331359
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
332360
@pytest.mark.continuation_of(
333-
lambda firmware, orig_version, machine, package_source, local_sr: [dict(
361+
lambda firmware, orig_version, machine, system_disk_config, package_source, local_sr: [dict(
334362
vm="vm1",
335-
image_test=f"TestNested::test_boot_inst[{firmware}-{orig_version}-{machine}-{package_source}-{local_sr}]")])
363+
image_test=(f"TestNested::test_boot_inst[{firmware}-{orig_version}-{machine}-{system_disk_config}"
364+
f"-{package_source}-{local_sr}]"))])
336365
@pytest.mark.answerfile(
337-
lambda system_disks_names, package_source, iso_version: AnswerFile("UPGRADE").top_append(
366+
lambda system_disks_names, package_source, system_disk_config, iso_version:
367+
AnswerFile("UPGRADE").top_append(
338368
{"iso": {"TAG": "source", "type": "local"},
339369
"net": {"TAG": "source", "type": "url",
340370
"CONTENTS": ISO_IMAGES[iso_version]['net-url']},
341371
}[package_source],
342372
{"TAG": "existing-installation",
343-
"CONTENTS": system_disks_names[0]},
373+
"CONTENTS": {"disk": system_disks_names[0],
374+
"raid1": "md127",
375+
}[system_disk_config]},
344376
))
345377
def test_upgrade(self, vm_booted_with_installer, system_disks_names,
346-
firmware, orig_version, iso_version, machine, package_source, local_sr):
378+
firmware, orig_version, iso_version, machine, package_source,
379+
system_disk_config, local_sr):
347380
host_vm = vm_booted_with_installer
348381
installer.monitor_upgrade(ip=host_vm.ip)
349382

350383
@pytest.mark.usefixtures("xcpng_chained")
351384
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
352385
@pytest.mark.parametrize("package_source", ("iso", "net"))
386+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
353387
@pytest.mark.parametrize("machine", ("host1", "host2"))
354388
@pytest.mark.parametrize("mode", (
355389
"83nightly-83nightly",
@@ -366,16 +400,18 @@ def test_upgrade(self, vm_booted_with_installer, system_disks_names,
366400
))
367401
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
368402
@pytest.mark.continuation_of(
369-
lambda firmware, mode, machine, package_source, local_sr: [dict(
403+
lambda firmware, mode, machine, system_disk_config, package_source, local_sr: [dict(
370404
vm="vm1",
371-
image_test=(f"TestNested::test_upgrade[{firmware}-{mode}-{machine}-{package_source}-{local_sr}]"))])
405+
image_test=(f"TestNested::test_upgrade[{firmware}-{mode}-{machine}-{system_disk_config}"
406+
f"-{package_source}-{local_sr}]"))])
372407
def test_boot_upg(self, create_vms,
373-
firmware, mode, machine, package_source, local_sr):
408+
firmware, mode, machine, package_source, system_disk_config, local_sr):
374409
self._test_firstboot(create_vms, mode, machine=machine)
375410

376411
@pytest.mark.usefixtures("xcpng_chained")
377412
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
378413
@pytest.mark.parametrize("package_source", ("iso", "net"))
414+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
379415
@pytest.mark.parametrize(("orig_version", "iso_version"), [
380416
("83nightly-83nightly", "83nightly"),
381417
("830-83nightly", "83nightly"),
@@ -391,22 +427,27 @@ def test_boot_upg(self, create_vms,
391427
])
392428
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
393429
@pytest.mark.continuation_of(
394-
lambda firmware, orig_version, local_sr, package_source: [dict(
430+
lambda firmware, orig_version, local_sr, system_disk_config, package_source: [dict(
395431
vm="vm1",
396-
image_test=f"TestNested::test_boot_upg[{firmware}-{orig_version}-host1-{package_source}-{local_sr}]")])
432+
image_test=(f"TestNested::test_boot_upg[{firmware}-{orig_version}-host1-{system_disk_config}"
433+
f"-{package_source}-{local_sr}]"))])
397434
@pytest.mark.answerfile(
398-
lambda system_disks_names: AnswerFile("RESTORE").top_append(
435+
lambda system_disks_names, system_disk_config: AnswerFile("RESTORE").top_append(
399436
{"TAG": "backup-disk",
400-
"CONTENTS": system_disks_names[0]},
437+
"CONTENTS": {"disk": system_disks_names[0],
438+
"raid1": "md127",
439+
}[system_disk_config]},
401440
))
402441
def test_restore(self, vm_booted_with_installer, system_disks_names,
403-
firmware, orig_version, iso_version, package_source, local_sr):
442+
firmware, orig_version, iso_version, package_source,
443+
system_disk_config, local_sr):
404444
host_vm = vm_booted_with_installer
405445
installer.monitor_restore(ip=host_vm.ip)
406446

407447
@pytest.mark.usefixtures("xcpng_chained")
408448
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
409449
@pytest.mark.parametrize("package_source", ("iso", "net"))
450+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
410451
@pytest.mark.parametrize("mode", (
411452
"83nightly-83nightly-83nightly",
412453
"830-83nightly-83nightly",
@@ -422,9 +463,10 @@ def test_restore(self, vm_booted_with_installer, system_disks_names,
422463
))
423464
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
424465
@pytest.mark.continuation_of(
425-
lambda firmware, mode, package_source, local_sr: [dict(
466+
lambda firmware, mode, system_disk_config, package_source, local_sr: [dict(
426467
vm="vm1",
427-
image_test=(f"TestNested::test_restore[{firmware}-{mode}-{package_source}-{local_sr}]"))])
468+
image_test=(f"TestNested::test_restore[{firmware}-{mode}-{system_disk_config}"
469+
f"-{package_source}-{local_sr}]"))])
428470
def test_boot_rst(self, create_vms,
429-
firmware, mode, package_source, local_sr):
471+
firmware, mode, package_source, system_disk_config, local_sr):
430472
self._test_firstboot(create_vms, mode, is_restore=True)

0 commit comments

Comments
 (0)