1
from . import VMBaseClass
2
from .releases import base_vm_classes as relbase
7
class TestMdadmAbs(VMBaseClass):
11
collect_scripts = [textwrap.dedent("""
13
cat /etc/fstab > fstab
14
mdadm --detail --scan > mdadm_status
15
mdadm --detail --scan | grep -c ubuntu > mdadm_active1
16
grep -c active /proc/mdstat > mdadm_active2
17
ls /dev/disk/by-dname > ls_dname
18
find /etc/network/interfaces.d > find_interfacesd
19
cat /proc/mdstat | tee mdstat
20
cat /proc/partitions | tee procpartitions
21
ls -1 /sys/class/block | tee sys_class_block
22
ls -1 /dev/md* | tee dev_md
25
def test_mdadm_output_files_exist(self):
26
self.output_files_exist(
27
["fstab", "mdadm_status", "mdadm_active1", "mdadm_active2",
30
def test_mdadm_status(self):
31
# ubuntu:<ID> is the name assigned to the md array
32
self.check_file_regex("mdadm_status", r"ubuntu:[0-9]*")
33
self.check_file_strippedline("mdadm_active1", self.active_mdadm)
34
self.check_file_strippedline("mdadm_active2", self.active_mdadm)
37
class TestMdadmBcacheAbs(TestMdadmAbs):
41
conf_file = "examples/tests/mdadm_bcache.yaml"
42
disk_to_check = [('main_disk', 1),
50
('cached_array_2', 0)]
51
extra_disks = ['4G', '4G']
52
collect_scripts = TestMdadmAbs.collect_scripts + [textwrap.dedent("""
54
bcache-super-show /dev/vda6 > bcache_super_vda6
55
bcache-super-show /dev/vda7 > bcache_super_vda7
56
bcache-super-show /dev/md0 > bcache_super_md0
57
ls /sys/fs/bcache > bcache_ls
58
cat /sys/block/bcache0/bcache/cache_mode > bcache_cache_mode
59
cat /sys/block/bcache1/bcache/cache_mode >> bcache_cache_mode
60
cat /sys/block/bcache2/bcache/cache_mode >> bcache_cache_mode
61
cat /proc/mounts > proc_mounts
62
find /etc/network/interfaces.d > find_interfacesd
65
'/dev/vda1': '/media/sda1',
67
'/dev/bcache1': '/media/data',
68
'/dev/bcache0': '/media/bcache_normal',
69
'/dev/bcache2': '/media/bcachefoo_fulldiskascache_storage'
72
def test_bcache_output_files_exist(self):
73
self.output_files_exist(["bcache_super_vda6",
79
def test_bcache_status(self):
85
bcache_cset_uuid = None
87
for bcache_super in bcache_supers:
88
for line in self.load_collect_file(bcache_super).splitlines():
89
if line != "" and line.split()[0] == "cset.uuid":
90
bcache_cset_uuid = line.split()[-1].rstrip()
91
if bcache_cset_uuid in found:
92
found[bcache_cset_uuid].append(bcache_super)
94
found[bcache_cset_uuid] = [bcache_super]
95
self.assertIsNotNone(bcache_cset_uuid)
96
self.assertTrue(bcache_cset_uuid in
97
self.load_collect_file("bcache_ls").splitlines())
99
# one cset.uuid for all devices
100
self.assertEqual(len(found), 1)
102
# three devices with same cset.uuid
103
self.assertEqual(len(found[bcache_cset_uuid]), 3)
105
# check the cset.uuid in the dict
106
self.assertEqual(list(found.keys()).pop(),
109
def test_bcache_cachemode(self):
110
# definition is on order 0->back,1->through,2->around
111
# but after reboot it can be anything since order is not guaranteed
112
# until we find a way to redetect the order we just check that all
114
self.check_file_regex("bcache_cache_mode", r"\[writeback\]")
115
self.check_file_regex("bcache_cache_mode", r"\[writethrough\]")
116
self.check_file_regex("bcache_cache_mode", r"\[writearound\]")
119
class TrustyTestMdadmBcache(relbase.trusty, TestMdadmBcacheAbs):
122
# FIXME(LP: #1523037): dname does not work on trusty
123
# when dname works on trusty, then we need to re-enable by removing line.
124
def test_dname(self):
125
print("test_dname does not work for Trusty")
127
def test_ptable(self):
128
print("test_ptable does not work for Trusty")
131
class TrustyHWEXTestMdadmBcache(relbase.trusty_hwe_x, TrustyTestMdadmBcache):
135
class XenialTestMdadmBcache(relbase.xenial, TestMdadmBcacheAbs):
139
class ZestyTestMdadmBcache(relbase.zesty, TestMdadmBcacheAbs):
143
class ArtfulTestMdadmBcache(relbase.artful, TestMdadmBcacheAbs):
147
class BionicTestMdadmBcache(relbase.bionic, TestMdadmBcacheAbs):
151
class TestMirrorbootAbs(TestMdadmAbs):
152
# alternative config for more complex setup
153
conf_file = "examples/tests/mirrorboot.yaml"
154
# initialize secondary disk
156
disk_to_check = [('main_disk', 1),
162
class TrustyTestMirrorboot(relbase.trusty, TestMirrorbootAbs):
165
# FIXME(LP: #1523037): dname does not work on trusty
166
# when dname works on trusty, then we need to re-enable by removing line.
167
def test_dname(self):
168
print("test_dname does not work for Trusty")
170
def test_ptable(self):
171
print("test_ptable does not work for Trusty")
174
class TrustyHWEXTestMirrorboot(relbase.trusty_hwe_x, TrustyTestMirrorboot):
175
# This tests kernel upgrade in target
179
class XenialTestMirrorboot(relbase.xenial, TestMirrorbootAbs):
183
class ZestyTestMirrorboot(relbase.zesty, TestMirrorbootAbs):
187
class ArtfulTestMirrorboot(relbase.artful, TestMirrorbootAbs):
191
class BionicTestMirrorboot(relbase.bionic, TestMirrorbootAbs):
195
class TestMirrorbootPartitionsAbs(TestMdadmAbs):
196
# alternative config for more complex setup
197
conf_file = "examples/tests/mirrorboot-msdos-partition.yaml"
198
# initialize secondary disk
199
extra_disks = ['10G']
200
disk_to_check = [('main_disk', 1),
205
class TrustyTestMirrorbootPartitions(relbase.trusty,
206
TestMirrorbootPartitionsAbs):
209
# FIXME(LP: #1523037): dname does not work on trusty
210
# when dname works on trusty, then we need to re-enable by removing line.
211
def test_dname(self):
212
print("test_dname does not work for Trusty")
214
def test_ptable(self):
215
print("test_ptable does not work for Trusty")
218
class TrustyHWEXTestMirrorbootPartitions(relbase.trusty_hwe_x,
219
TrustyTestMirrorbootPartitions):
220
# This tests kernel upgrade in target
224
class XenialTestMirrorbootPartitions(relbase.xenial,
225
TestMirrorbootPartitionsAbs):
229
class ZestyTestMirrorbootPartitions(relbase.zesty,
230
TestMirrorbootPartitionsAbs):
234
class ArtfulTestMirrorbootPartitions(relbase.artful,
235
TestMirrorbootPartitionsAbs):
239
class BionicTestMirrorbootPartitions(relbase.bionic,
240
TestMirrorbootPartitionsAbs):
244
class TestMirrorbootPartitionsUEFIAbs(TestMdadmAbs):
245
# alternative config for more complex setup
246
conf_file = "examples/tests/mirrorboot-uefi.yaml"
247
# initialize secondary disk
248
extra_disks = ['10G']
249
disk_to_check = [('main_disk', 2),
259
class TrustyTestMirrorbootPartitionsUEFI(relbase.trusty,
260
TestMirrorbootPartitionsUEFIAbs):
263
# FIXME(LP: #1523037): dname does not work on trusty
264
# when dname works on trusty, then we need to re-enable by removing line.
265
def test_dname(self):
266
print("test_dname does not work for Trusty")
268
def test_ptable(self):
269
print("test_ptable does not work for Trusty")
272
class XenialTestMirrorbootPartitionsUEFI(relbase.xenial,
273
TestMirrorbootPartitionsUEFIAbs):
277
class ZestyTestMirrorbootPartitionsUEFI(relbase.zesty,
278
TestMirrorbootPartitionsUEFIAbs):
282
class ArtfulTestMirrorbootPartitionsUEFI(relbase.artful,
283
TestMirrorbootPartitionsUEFIAbs):
287
class BionicTestMirrorbootPartitionsUEFI(relbase.bionic,
288
TestMirrorbootPartitionsUEFIAbs):
292
class TestRaid5bootAbs(TestMdadmAbs):
293
# alternative config for more complex setup
294
conf_file = "examples/tests/raid5boot.yaml"
295
# initialize secondary disk
296
extra_disks = ['4G', '4G']
297
disk_to_check = [('main_disk', 1),
304
class TrustyTestRaid5Boot(relbase.trusty, TestRaid5bootAbs):
307
# FIXME(LP: #1523037): dname does not work on trusty
308
# when dname works on trusty, then we need to re-enable by removing line.
309
def test_dname(self):
310
print("test_dname does not work for Trusty")
312
def test_ptable(self):
313
print("test_ptable does not work for Trusty")
316
class TrustyHWEXTestRaid5Boot(relbase.trusty_hwe_x, TrustyTestRaid5Boot):
317
# This tests kernel upgrade in target
321
class XenialTestRaid5boot(relbase.xenial, TestRaid5bootAbs):
325
class ZestyTestRaid5boot(relbase.zesty, TestRaid5bootAbs):
329
class ArtfulTestRaid5boot(relbase.artful, TestRaid5bootAbs):
333
class BionicTestRaid5boot(relbase.bionic, TestRaid5bootAbs):
337
class TestRaid6bootAbs(TestMdadmAbs):
338
# alternative config for more complex setup
339
conf_file = "examples/tests/raid6boot.yaml"
340
# initialize secondary disk
341
extra_disks = ['4G', '4G', '4G']
342
disk_to_check = [('main_disk', 1),
348
collect_scripts = TestMdadmAbs.collect_scripts + [textwrap.dedent("""
350
mdadm --detail --scan > mdadm_detail
353
def test_raid6_output_files_exist(self):
354
self.output_files_exist(
357
def test_mdadm_custom_name(self):
358
# the raid6boot.yaml sets this name, check if it was set
359
self.check_file_regex("mdadm_detail", r"ubuntu:foobar")
362
class TrustyTestRaid6boot(relbase.trusty, TestRaid6bootAbs):
365
# FIXME(LP: #1523037): dname does not work on trusty
366
# when dname works on trusty, then we need to re-enable by removing line.
367
def test_dname(self):
368
print("test_dname does not work for Trusty")
370
def test_ptable(self):
371
print("test_ptable does not work for Trusty")
374
class TrustyHWEXTestRaid6boot(relbase.trusty_hwe_x, TrustyTestRaid6boot):
378
class XenialTestRaid6boot(relbase.xenial, TestRaid6bootAbs):
382
class ZestyTestRaid6boot(relbase.zesty, TestRaid6bootAbs):
386
class ArtfulTestRaid6boot(relbase.artful, TestRaid6bootAbs):
390
class BionicTestRaid6boot(relbase.bionic, TestRaid6bootAbs):
394
class TestRaid10bootAbs(TestMdadmAbs):
395
# alternative config for more complex setup
396
conf_file = "examples/tests/raid10boot.yaml"
397
# initialize secondary disk
398
extra_disks = ['4G', '4G', '4G']
399
disk_to_check = [('main_disk', 1),
407
class TrustyTestRaid10boot(relbase.trusty, TestRaid10bootAbs):
410
# FIXME(LP: #1523037): dname does not work on trusty
411
# when dname works on trusty, then we need to re-enable by removing line.
412
def test_dname(self):
413
print("test_dname does not work for Trusty")
415
def test_ptable(self):
416
print("test_ptable does not work for Trusty")
419
class TrustyHWEXTestRaid10boot(relbase.trusty_hwe_x, TrustyTestRaid10boot):
423
class XenialTestRaid10boot(relbase.xenial, TestRaid10bootAbs):
427
class ZestyTestRaid10boot(relbase.zesty, TestRaid10bootAbs):
431
class ArtfulTestRaid10boot(relbase.artful, TestRaid10bootAbs):
435
class BionicTestRaid10boot(relbase.bionic, TestRaid10bootAbs):
439
class TestAllindataAbs(TestMdadmAbs):
440
# more complex, needs more time
441
# alternative config for more complex setup
442
conf_file = "examples/tests/allindata.yaml"
443
# we have to avoid a systemd hang due to the way it handles dmcrypt
444
extra_kern_args = "--- luks=no"
446
# running in dirty mode catches some race/errors with mdadm_stop
449
# initialize secondary disk
450
extra_disks = ['5G', '5G', '5G']
451
disk_to_check = [('main_disk', 1),
475
collect_scripts = TestMdadmAbs.collect_scripts + [textwrap.dedent("""
477
pvdisplay -C --separator = -o vg_name,pv_name --noheadings > pvs
478
lvdisplay -C --separator = -o lv_name,vg_name --noheadings > lvs
479
cat /etc/crypttab > crypttab
480
yes "testkey" | cryptsetup open /dev/vg1/lv3 dmcrypt0 --type luks
481
ls -laF /dev/mapper/dmcrypt0 > mapper
482
mkdir -p /tmp/xfstest
483
mount /dev/mapper/dmcrypt0 /tmp/xfstest
484
xfs_info /tmp/xfstest/ > xfs_info
487
'/dev/vg1/lv1': '/srv/data',
488
'/dev/vg1/lv2': '/srv/backup',
491
def test_output_files_exist(self):
492
self.output_files_exist(["pvs", "lvs", "crypttab", "mapper",
496
self.check_file_strippedline("lvs", "lv1=vg1")
497
self.check_file_strippedline("lvs", "lv2=vg1")
498
self.check_file_strippedline("lvs", "lv3=vg1")
501
self.check_file_strippedline("pvs", "vg1=/dev/md0")
502
self.check_file_strippedline("pvs", "vg1=/dev/md1")
503
self.check_file_strippedline("pvs", "vg1=/dev/md2")
504
self.check_file_strippedline("pvs", "vg1=/dev/md3")
506
def test_dmcrypt(self):
507
self.check_file_regex("crypttab", r"dmcrypt0.*luks")
508
self.check_file_regex("mapper", r"^lrwxrwxrwx.*/dev/mapper/dmcrypt0")
509
self.check_file_regex("xfs_info", r"^meta-data=/dev/mapper/dmcrypt0")
512
class TrustyTestAllindata(relbase.trusty, TestAllindataAbs):
513
__test__ = False # luks=no does not disable mounting of device
515
# FIXME(LP: #1523037): dname does not work on trusty
516
# when dname works on trusty, then we need to re-enable by removing line.
517
def test_dname(self):
518
print("test_dname does not work for Trusty")
520
def test_ptable(self):
521
print("test_ptable does not work for Trusty")
524
class TrustyHWEXTestAllindata(relbase.trusty_hwe_x, TrustyTestAllindata):
525
__test__ = False # lukes=no does not disable mounting of device
528
class XenialTestAllindata(relbase.xenial, TestAllindataAbs):
532
class ZestyTestAllindata(relbase.zesty, TestAllindataAbs):
536
class ArtfulTestAllindata(relbase.artful, TestAllindataAbs):
540
class BionicTestAllindata(relbase.bionic, TestAllindataAbs):