@@ -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,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