Skip to content

Commit 2edba63

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 c3b1b23 commit 2edba63

File tree

4 files changed

+83
-34
lines changed

4 files changed

+83
-34
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

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: 70 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,23 @@ 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}-{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,18 @@ 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}-{package_source}-{local_sr}]"))])
310336
def test_boot_inst(self, create_vms,
311-
firmware, version, machine, package_source, local_sr):
337+
firmware, version, machine, package_source, system_disk_config, local_sr):
312338
self._test_firstboot(create_vms, version, machine=machine)
313339

314340
@pytest.mark.usefixtures("xcpng_chained")
315341
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
316342
@pytest.mark.parametrize("package_source", ("iso", "net"))
343+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
317344
@pytest.mark.parametrize("machine", ("host1", "host2"))
318345
@pytest.mark.parametrize(("orig_version", "iso_version"), [
319346
("83nightly", "83nightly"),
@@ -330,26 +357,32 @@ def test_boot_inst(self, create_vms,
330357
])
331358
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
332359
@pytest.mark.continuation_of(
333-
lambda firmware, orig_version, machine, package_source, local_sr: [dict(
360+
lambda firmware, orig_version, machine, system_disk_config, package_source, local_sr: [dict(
334361
vm="vm1",
335-
image_test=f"TestNested::test_boot_inst[{firmware}-{orig_version}-{machine}-{package_source}-{local_sr}]")])
362+
image_test=f"TestNested::test_boot_inst[{firmware}-{orig_version}-{machine}-{system_disk_config}-{package_source}-{local_sr}]")])
336363
@pytest.mark.answerfile(
337-
lambda system_disks_names, package_source, iso_version: AnswerFile("UPGRADE").top_append(
364+
lambda system_disks_names, package_source, system_disk_config, iso_version: AnswerFile("UPGRADE").top_append(
338365
{"TAG": "source", "type": "local"} if package_source == "iso"
339366
else {"TAG": "source", "type": "url",
340367
"CONTENTS": ISO_IMAGES[iso_version]['net-url']} if package_source == "net"
341368
else ValueError(f"package_source {package_source!r}"),
342369
{"TAG": "existing-installation",
343-
"CONTENTS": system_disks_names[0]},
370+
"CONTENTS": (system_disks_names[0] if system_disk_config == "disk"
371+
else "md127" if system_disk_config == "raid1"
372+
else "should-not-happen")}
373+
if system_disk_config in ("disk", "raid1")
374+
else ValueError(f"system_disk_config {system_disk_config!r}"),
344375
))
345376
def test_upgrade(self, vm_booted_with_installer, system_disks_names,
346-
firmware, orig_version, iso_version, machine, package_source, local_sr):
377+
firmware, orig_version, iso_version, machine, package_source,
378+
system_disk_config, local_sr):
347379
host_vm = vm_booted_with_installer
348380
installer.monitor_upgrade(ip=host_vm.ip)
349381

350382
@pytest.mark.usefixtures("xcpng_chained")
351383
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
352384
@pytest.mark.parametrize("package_source", ("iso", "net"))
385+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
353386
@pytest.mark.parametrize("machine", ("host1", "host2"))
354387
@pytest.mark.parametrize("mode", (
355388
"83nightly-83nightly",
@@ -366,16 +399,17 @@ def test_upgrade(self, vm_booted_with_installer, system_disks_names,
366399
))
367400
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
368401
@pytest.mark.continuation_of(
369-
lambda firmware, mode, machine, package_source, local_sr: [dict(
402+
lambda firmware, mode, machine, system_disk_config, package_source, local_sr: [dict(
370403
vm="vm1",
371-
image_test=(f"TestNested::test_upgrade[{firmware}-{mode}-{machine}-{package_source}-{local_sr}]"))])
404+
image_test=(f"TestNested::test_upgrade[{firmware}-{mode}-{machine}-{system_disk_config}-{package_source}-{local_sr}]"))])
372405
def test_boot_upg(self, create_vms,
373-
firmware, mode, machine, package_source, local_sr):
406+
firmware, mode, machine, package_source, system_disk_config, local_sr):
374407
self._test_firstboot(create_vms, mode, machine=machine)
375408

376409
@pytest.mark.usefixtures("xcpng_chained")
377410
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
378411
@pytest.mark.parametrize("package_source", ("iso", "net"))
412+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
379413
@pytest.mark.parametrize(("orig_version", "iso_version"), [
380414
("83nightly-83nightly", "83nightly"),
381415
("830-83nightly", "83nightly"),
@@ -391,22 +425,28 @@ def test_boot_upg(self, create_vms,
391425
])
392426
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
393427
@pytest.mark.continuation_of(
394-
lambda firmware, orig_version, local_sr, package_source: [dict(
428+
lambda firmware, orig_version, local_sr, system_disk_config, package_source: [dict(
395429
vm="vm1",
396-
image_test=f"TestNested::test_boot_upg[{firmware}-{orig_version}-host1-{package_source}-{local_sr}]")])
430+
image_test=f"TestNested::test_boot_upg[{firmware}-{orig_version}-host1-{system_disk_config}-{package_source}-{local_sr}]")])
397431
@pytest.mark.answerfile(
398-
lambda system_disks_names: AnswerFile("RESTORE").top_append(
432+
lambda system_disks_names, system_disk_config: AnswerFile("RESTORE").top_append(
399433
{"TAG": "backup-disk",
400-
"CONTENTS": system_disks_names[0]},
434+
"CONTENTS": (system_disks_names[0] if system_disk_config == "disk"
435+
else "md127" if system_disk_config == "raid1"
436+
else "should-not-happen")}
437+
if system_disk_config in ("disk", "raid1")
438+
else ValueError(f"system_disk_config {system_disk_config!r}"),
401439
))
402440
def test_restore(self, vm_booted_with_installer, system_disks_names,
403-
firmware, orig_version, iso_version, package_source, local_sr):
441+
firmware, orig_version, iso_version, package_source,
442+
system_disk_config, local_sr):
404443
host_vm = vm_booted_with_installer
405444
installer.monitor_restore(ip=host_vm.ip)
406445

407446
@pytest.mark.usefixtures("xcpng_chained")
408447
@pytest.mark.parametrize("local_sr", ("nosr", "ext", "lvm"))
409448
@pytest.mark.parametrize("package_source", ("iso", "net"))
449+
@pytest.mark.parametrize("system_disk_config", ("disk", "raid1"))
410450
@pytest.mark.parametrize("mode", (
411451
"83nightly-83nightly-83nightly",
412452
"830-83nightly-83nightly",
@@ -422,9 +462,9 @@ def test_restore(self, vm_booted_with_installer, system_disks_names,
422462
))
423463
@pytest.mark.parametrize("firmware", ("uefi", "bios"))
424464
@pytest.mark.continuation_of(
425-
lambda firmware, mode, package_source, local_sr: [dict(
465+
lambda firmware, mode, system_disk_config, package_source, local_sr: [dict(
426466
vm="vm1",
427-
image_test=(f"TestNested::test_restore[{firmware}-{mode}-{package_source}-{local_sr}]"))])
467+
image_test=(f"TestNested::test_restore[{firmware}-{mode}-{system_disk_config}-{package_source}-{local_sr}]"))])
428468
def test_boot_rst(self, create_vms,
429-
firmware, mode, package_source, local_sr):
469+
firmware, mode, package_source, system_disk_config, local_sr):
430470
self._test_firstboot(create_vms, mode, is_restore=True)

0 commit comments

Comments
 (0)