@@ -43,6 +43,7 @@ def helper_vm_with_plugged_disk(running_vm, create_vms):
43
43
class TestNested :
44
44
@pytest .mark .parametrize ("local_sr" , ("nosr" , "ext" , "lvm" ))
45
45
@pytest .mark .parametrize ("package_source" , ("iso" , "net" ))
46
+ @pytest .mark .parametrize ("system_disk_config" , ("disk" , "raid1" ))
46
47
@pytest .mark .parametrize ("iso_version" , (
47
48
"83nightly" , "830net" ,
48
49
"830" ,
@@ -54,7 +55,7 @@ class TestNested:
54
55
))
55
56
@pytest .mark .parametrize ("firmware" , ("uefi" , "bios" ))
56
57
@pytest .mark .vm_definitions (
57
- lambda firmware : dict (
58
+ lambda firmware , system_disk_config : dict (
58
59
name = "vm1" ,
59
60
template = "Other install media" ,
60
61
params = (
@@ -74,31 +75,47 @@ class TestNested:
74
75
),
75
76
"bios" : (),
76
77
}[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
+ ),
78
82
cd_vbd = dict (device = "xvdd" , userdevice = "3" ),
79
83
vifs = [dict (index = 0 , network_name = NETWORKS ["MGMT" ])],
80
84
))
81
85
@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" )
83
87
.top_setattr ({} if local_sr == "nosr" else {"sr-type" : local_sr })
84
88
.top_append (
85
89
{"TAG" : "source" , "type" : "local" } if package_source == "iso"
86
90
else {"TAG" : "source" , "type" : "url" ,
87
91
"CONTENTS" : ISO_IMAGES [iso_version ]['net-url' ]} if package_source == "net"
88
92
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
+
89
101
{"TAG" : "admin-interface" , "name" : "eth0" , "proto" : "dhcp" },
90
102
{"TAG" : "primary-disk" ,
91
103
"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} " ),
93
109
))
94
110
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 ):
96
112
host_vm = vm_booted_with_installer
97
113
installer .monitor_install (ip = host_vm .ip )
98
114
99
115
@pytest .mark .usefixtures ("xcpng_chained" )
100
116
@pytest .mark .parametrize ("local_sr" , ("nosr" , "ext" , "lvm" ))
101
117
@pytest .mark .parametrize ("package_source" , ("iso" , "net" ))
118
+ @pytest .mark .parametrize ("system_disk_config" , ("disk" , "raid1" ))
102
119
@pytest .mark .parametrize ("machine" , ("host1" , "host2" ))
103
120
@pytest .mark .parametrize ("version" , (
104
121
"83nightly" , "830net" ,
@@ -112,15 +129,23 @@ def test_install(self, vm_booted_with_installer, system_disks_names,
112
129
))
113
130
@pytest .mark .parametrize ("firmware" , ("uefi" , "bios" ))
114
131
@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 (
116
133
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 } ]" )])
119
135
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 ):
121
137
helper_vm = helper_vm_with_plugged_disk
122
138
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
+
124
149
try :
125
150
# hostname
126
151
logging .info ("Setting hostname to %r" , machine )
@@ -134,7 +159,7 @@ def test_tune_firstboot(self, create_vms, helper_vm_with_plugged_disk,
134
159
'/mnt/etc/xensource-inventory' ])
135
160
helper_vm .ssh (["grep UUID /mnt/etc/xensource-inventory" ])
136
161
finally :
137
- helper_vm .ssh (["umount /dev/xvdb1 " ])
162
+ helper_vm .ssh (["umount /mnt " ])
138
163
139
164
def _test_firstboot (self , create_vms , mode , * , machine = 'DEFAULT' , is_restore = False ):
140
165
host_vm = create_vms [0 ]
@@ -290,6 +315,7 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
290
315
@pytest .mark .usefixtures ("xcpng_chained" )
291
316
@pytest .mark .parametrize ("local_sr" , ("nosr" , "ext" , "lvm" ))
292
317
@pytest .mark .parametrize ("package_source" , ("iso" , "net" ))
318
+ @pytest .mark .parametrize ("system_disk_config" , ("disk" , "raid1" ))
293
319
@pytest .mark .parametrize ("machine" , ("host1" , "host2" ))
294
320
@pytest .mark .parametrize ("version" , (
295
321
"83nightly" , "830net" ,
@@ -303,17 +329,18 @@ def _test_firstboot(self, create_vms, mode, *, machine='DEFAULT', is_restore=Fal
303
329
))
304
330
@pytest .mark .parametrize ("firmware" , ("uefi" , "bios" ))
305
331
@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 : [
307
333
dict (vm = "vm1" ,
308
334
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 } ]" ))])
310
336
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 ):
312
338
self ._test_firstboot (create_vms , version , machine = machine )
313
339
314
340
@pytest .mark .usefixtures ("xcpng_chained" )
315
341
@pytest .mark .parametrize ("local_sr" , ("nosr" , "ext" , "lvm" ))
316
342
@pytest .mark .parametrize ("package_source" , ("iso" , "net" ))
343
+ @pytest .mark .parametrize ("system_disk_config" , ("disk" , "raid1" ))
317
344
@pytest .mark .parametrize ("machine" , ("host1" , "host2" ))
318
345
@pytest .mark .parametrize (("orig_version" , "iso_version" ), [
319
346
("83nightly" , "83nightly" ),
@@ -330,26 +357,32 @@ def test_boot_inst(self, create_vms,
330
357
])
331
358
@pytest .mark .parametrize ("firmware" , ("uefi" , "bios" ))
332
359
@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 (
334
361
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 } ]" )])
336
363
@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 (
338
365
{"TAG" : "source" , "type" : "local" } if package_source == "iso"
339
366
else {"TAG" : "source" , "type" : "url" ,
340
367
"CONTENTS" : ISO_IMAGES [iso_version ]['net-url' ]} if package_source == "net"
341
368
else ValueError (f"package_source { package_source !r} " ),
342
369
{"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} " ),
344
375
))
345
376
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 ):
347
379
host_vm = vm_booted_with_installer
348
380
installer .monitor_upgrade (ip = host_vm .ip )
349
381
350
382
@pytest .mark .usefixtures ("xcpng_chained" )
351
383
@pytest .mark .parametrize ("local_sr" , ("nosr" , "ext" , "lvm" ))
352
384
@pytest .mark .parametrize ("package_source" , ("iso" , "net" ))
385
+ @pytest .mark .parametrize ("system_disk_config" , ("disk" , "raid1" ))
353
386
@pytest .mark .parametrize ("machine" , ("host1" , "host2" ))
354
387
@pytest .mark .parametrize ("mode" , (
355
388
"83nightly-83nightly" ,
@@ -366,16 +399,17 @@ def test_upgrade(self, vm_booted_with_installer, system_disks_names,
366
399
))
367
400
@pytest .mark .parametrize ("firmware" , ("uefi" , "bios" ))
368
401
@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 (
370
403
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 } ]" ))])
372
405
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 ):
374
407
self ._test_firstboot (create_vms , mode , machine = machine )
375
408
376
409
@pytest .mark .usefixtures ("xcpng_chained" )
377
410
@pytest .mark .parametrize ("local_sr" , ("nosr" , "ext" , "lvm" ))
378
411
@pytest .mark .parametrize ("package_source" , ("iso" , "net" ))
412
+ @pytest .mark .parametrize ("system_disk_config" , ("disk" , "raid1" ))
379
413
@pytest .mark .parametrize (("orig_version" , "iso_version" ), [
380
414
("83nightly-83nightly" , "83nightly" ),
381
415
("830-83nightly" , "83nightly" ),
@@ -391,22 +425,28 @@ def test_boot_upg(self, create_vms,
391
425
])
392
426
@pytest .mark .parametrize ("firmware" , ("uefi" , "bios" ))
393
427
@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 (
395
429
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 } ]" )])
397
431
@pytest .mark .answerfile (
398
- lambda system_disks_names : AnswerFile ("RESTORE" ).top_append (
432
+ lambda system_disks_names , system_disk_config : AnswerFile ("RESTORE" ).top_append (
399
433
{"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} " ),
401
439
))
402
440
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 ):
404
443
host_vm = vm_booted_with_installer
405
444
installer .monitor_restore (ip = host_vm .ip )
406
445
407
446
@pytest .mark .usefixtures ("xcpng_chained" )
408
447
@pytest .mark .parametrize ("local_sr" , ("nosr" , "ext" , "lvm" ))
409
448
@pytest .mark .parametrize ("package_source" , ("iso" , "net" ))
449
+ @pytest .mark .parametrize ("system_disk_config" , ("disk" , "raid1" ))
410
450
@pytest .mark .parametrize ("mode" , (
411
451
"83nightly-83nightly-83nightly" ,
412
452
"830-83nightly-83nightly" ,
@@ -422,9 +462,9 @@ def test_restore(self, vm_booted_with_installer, system_disks_names,
422
462
))
423
463
@pytest .mark .parametrize ("firmware" , ("uefi" , "bios" ))
424
464
@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 (
426
466
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 } ]" ))])
428
468
def test_boot_rst (self , create_vms ,
429
- firmware , mode , package_source , local_sr ):
469
+ firmware , mode , package_source , system_disk_config , local_sr ):
430
470
self ._test_firstboot (create_vms , mode , is_restore = True )
0 commit comments