@@ -43,6 +43,7 @@ def helper_vm_with_plugged_disk(running_vm, create_vms):
4343class 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