Skip to content

Commit b54c656

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 391e1b0 commit b54c656

File tree

6 files changed

+93
-38
lines changed

6 files changed

+93
-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+
({"uefi": "nvme0n2", "bios": "sdb"}[firmware],)
106+
if system_disk_config == "raid1"
107+
else ()
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: 76 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,47 @@ 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
{"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+
{"TAG": "raid", "device": "md127",
95+
"CONTENTS": [
96+
{"TAG": "disk", "CONTENTS": diskname} for diskname in system_disks_names
97+
]} if system_disk_config == "raid1"
98+
else None if system_disk_config == "disk"
99+
else ValueError(f"system_disk_config {system_disk_config!r}"),
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": ("md127" if system_disk_config == "raid1"
105+
else system_disks_names[0] if system_disk_config == "disk"
106+
else "should-not-happen"),
107+
} if system_disk_config in ("disk", "raid1")
108+
else ValueError(f"system_disk_config {system_disk_config!r}"),
93109
))
94110
def test_install(self, vm_booted_with_installer, system_disks_names,
95-
firmware, iso_version, package_source, local_sr):
111+
firmware, iso_version, package_source, system_disk_config, local_sr):
96112
host_vm = vm_booted_with_installer
97113
installer.monitor_install(ip=host_vm.ip)
98114

99115
@pytest.mark.usefixtures("xcpng_chained")
100116
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
101117
@pytest.mark.parametrize("package_source", ("iso", "net"))
118+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
102119
@pytest.mark.parametrize("machine", ("host1", "host2"))
103120
@pytest.mark.parametrize("version", (
104121
"83nightly", "830net",
@@ -112,15 +129,24 @@ def test_install(self, vm_booted_with_installer, system_disks_names,
112129
))
113130
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
114131
@pytest.mark.continuation_of(
115-
lambda version, firmware, local_sr, package_source: [dict(
132+
lambda version, firmware, local_sr, package_source, system_disk_config: [dict(
116133
vm="vm1",
117-
image_test=f"TestNested::test_install[{firmware}-{version}-{package_source}-{local_sr}]")])
118-
@pytest.mark.small_vm
134+
image_test=(f"TestNested::test_install[{firmware}-{version}-{system_disk_config}"
135+
f"-{package_source}-{local_sr}]"))])
119136
def test_tune_firstboot(self, create_vms, helper_vm_with_plugged_disk,
120-
firmware, version, machine, local_sr, package_source):
137+
firmware, version, machine, local_sr, package_source, system_disk_config):
121138
helper_vm = helper_vm_with_plugged_disk
122139

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

139165
def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=False):
140166
host_vm = create_vms[0]
@@ -290,6 +316,7 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
290316
@pytest.mark.usefixtures("xcpng_chained")
291317
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
292318
@pytest.mark.parametrize("package_source", ("iso", "net"))
319+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
293320
@pytest.mark.parametrize("machine", ("host1", "host2"))
294321
@pytest.mark.parametrize("version", (
295322
"83nightly", "830net",
@@ -303,17 +330,19 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
303330
))
304331
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
305332
@pytest.mark.continuation_of(
306-
lambda firmware, version, machine, local_sr, package_source: [
333+
lambda firmware, version, machine, local_sr, package_source, system_disk_config: [
307334
dict(vm="vm1",
308335
image_test=("TestNested::test_tune_firstboot"
309-
f"[None-{firmware}-{version}-{machine}-{package_source}-{local_sr}]"))])
336+
f"[None-{firmware}-{version}-{machine}-{system_disk_config}"
337+
f"-{package_source}-{local_sr}]"))])
310338
def test_boot_inst(self, create_vms,
311-
firmware, version, machine, package_source, local_sr):
339+
firmware, version, machine, package_source, system_disk_config, local_sr):
312340
self._test_firstboot(create_vms, version, machine=machine)
313341

314342
@pytest.mark.usefixtures("xcpng_chained")
315343
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
316344
@pytest.mark.parametrize("package_source", ("iso", "net"))
345+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
317346
@pytest.mark.parametrize("machine", ("host1", "host2"))
318347
@pytest.mark.parametrize(("orig_version", "iso_version"), [
319348
("83nightly", "83nightly"),
@@ -330,26 +359,33 @@ def test_boot_inst(self, create_vms,
330359
])
331360
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
332361
@pytest.mark.continuation_of(
333-
lambda firmware, orig_version, machine, package_source, local_sr: [dict(
362+
lambda firmware, orig_version, machine, system_disk_config, package_source, local_sr: [dict(
334363
vm="vm1",
335-
image_test=f"TestNested::test_boot_inst[{firmware}-{orig_version}-{machine}-{package_source}-{local_sr}]")])
364+
image_test=(f"TestNested::test_boot_inst[{firmware}-{orig_version}-{machine}-{system_disk_config}"
365+
f"-{package_source}-{local_sr}]"))])
336366
@pytest.mark.answerfile(
337-
lambda system_disks_names, package_source, iso_version: AnswerFile("UPGRADE").top_append(
367+
lambda system_disks_names, package_source, system_disk_config, iso_version: AnswerFile("UPGRADE").top_append(
338368
{"TAG": "source", "type": "local"} if package_source == "iso"
339369
else {"TAG": "source", "type": "url",
340370
"CONTENTS": ISO_IMAGES[iso_version]['net-url']} if package_source == "net"
341371
else ValueError(f"package_source {package_source!r}"),
342372
{"TAG": "existing-installation",
343-
"CONTENTS": system_disks_names[0]},
373+
"CONTENTS": (system_disks_names[0] if system_disk_config == "disk"
374+
else "md127" if system_disk_config == "raid1"
375+
else "should-not-happen")}
376+
if system_disk_config in ("disk", "raid1")
377+
else ValueError(f"system_disk_config {system_disk_config!r}"),
344378
))
345379
def test_upgrade(self, vm_booted_with_installer, system_disks_names,
346-
firmware, orig_version, iso_version, machine, package_source, local_sr):
380+
firmware, orig_version, iso_version, machine, package_source,
381+
system_disk_config, local_sr):
347382
host_vm = vm_booted_with_installer
348383
installer.monitor_upgrade(ip=host_vm.ip)
349384

350385
@pytest.mark.usefixtures("xcpng_chained")
351386
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
352387
@pytest.mark.parametrize("package_source", ("iso", "net"))
388+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
353389
@pytest.mark.parametrize("machine", ("host1", "host2"))
354390
@pytest.mark.parametrize("mode", (
355391
"83nightly-83nightly",
@@ -366,16 +402,18 @@ def test_upgrade(self, vm_booted_with_installer, system_disks_names,
366402
))
367403
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
368404
@pytest.mark.continuation_of(
369-
lambda firmware, mode, machine, package_source, local_sr: [dict(
405+
lambda firmware, mode, machine, system_disk_config, package_source, local_sr: [dict(
370406
vm="vm1",
371-
image_test=(f"TestNested::test_upgrade[{firmware}-{mode}-{machine}-{package_source}-{local_sr}]"))])
407+
image_test=(f"TestNested::test_upgrade[{firmware}-{mode}-{machine}-{system_disk_config}"
408+
f"-{package_source}-{local_sr}]"))])
372409
def test_boot_upg(self, create_vms,
373-
firmware, mode, machine, package_source, local_sr):
410+
firmware, mode, machine, package_source, system_disk_config, local_sr):
374411
self._test_firstboot(create_vms, mode, machine=machine)
375412

376413
@pytest.mark.usefixtures("xcpng_chained")
377414
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
378415
@pytest.mark.parametrize("package_source", ("iso", "net"))
416+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
379417
@pytest.mark.parametrize(("orig_version", "iso_version"), [
380418
("83nightly-83nightly", "83nightly"),
381419
("830-83nightly", "83nightly"),
@@ -391,22 +429,29 @@ def test_boot_upg(self, create_vms,
391429
])
392430
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
393431
@pytest.mark.continuation_of(
394-
lambda firmware, orig_version, local_sr, package_source: [dict(
432+
lambda firmware, orig_version, local_sr, system_disk_config, package_source: [dict(
395433
vm="vm1",
396-
image_test=f"TestNested::test_boot_upg[{firmware}-{orig_version}-host1-{package_source}-{local_sr}]")])
434+
image_test=(f"TestNested::test_boot_upg[{firmware}-{orig_version}-host1-{system_disk_config}"
435+
f"-{package_source}-{local_sr}]"))])
397436
@pytest.mark.answerfile(
398-
lambda system_disks_names: AnswerFile("RESTORE").top_append(
437+
lambda system_disks_names, system_disk_config: AnswerFile("RESTORE").top_append(
399438
{"TAG": "backup-disk",
400-
"CONTENTS": system_disks_names[0]},
439+
"CONTENTS": (system_disks_names[0] if system_disk_config == "disk"
440+
else "md127" if system_disk_config == "raid1"
441+
else "should-not-happen")}
442+
if system_disk_config in ("disk", "raid1")
443+
else ValueError(f"system_disk_config {system_disk_config!r}"),
401444
))
402445
def test_restore(self, vm_booted_with_installer, system_disks_names,
403-
firmware, orig_version, iso_version, package_source, local_sr):
446+
firmware, orig_version, iso_version, package_source,
447+
system_disk_config, local_sr):
404448
host_vm = vm_booted_with_installer
405449
installer.monitor_restore(ip=host_vm.ip)
406450

407451
@pytest.mark.usefixtures("xcpng_chained")
408452
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
409453
@pytest.mark.parametrize("package_source", ("iso", "net"))
454+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
410455
@pytest.mark.parametrize("mode", (
411456
"83nightly-83nightly-83nightly",
412457
"830-83nightly-83nightly",
@@ -422,9 +467,10 @@ def test_restore(self, vm_booted_with_installer, system_disks_names,
422467
))
423468
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
424469
@pytest.mark.continuation_of(
425-
lambda firmware, mode, package_source, local_sr: [dict(
470+
lambda firmware, mode, system_disk_config, package_source, local_sr: [dict(
426471
vm="vm1",
427-
image_test=(f"TestNested::test_restore[{firmware}-{mode}-{package_source}-{local_sr}]"))])
472+
image_test=(f"TestNested::test_restore[{firmware}-{mode}-{system_disk_config}"
473+
f"-{package_source}-{local_sr}]"))])
428474
def test_boot_rst(self, create_vms,
429-
firmware, mode, package_source, local_sr):
475+
firmware, mode, package_source, system_disk_config, local_sr):
430476
self._test_firstboot(create_vms, mode, is_restore=True)

0 commit comments

Comments
 (0)