1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
from . import VMBaseClass
from .releases import base_vm_classes as relbase
import textwrap
class TestMdadmAbs(VMBaseClass):
interactive = False
extra_disks = []
active_mdadm = "1"
collect_scripts = [textwrap.dedent("""
cd OUTPUT_COLLECT_D
cat /etc/fstab > fstab
mdadm --detail --scan > mdadm_status
mdadm --detail --scan | grep -c ubuntu > mdadm_active1
grep -c active /proc/mdstat > mdadm_active2
ls /dev/disk/by-dname > ls_dname
find /etc/network/interfaces.d > find_interfacesd
""")]
def test_mdadm_output_files_exist(self):
self.output_files_exist(
["fstab", "mdadm_status", "mdadm_active1", "mdadm_active2",
"ls_dname"])
def test_mdadm_status(self):
# ubuntu:<ID> is the name assigned to the md array
self.check_file_regex("mdadm_status", r"ubuntu:[0-9]*")
self.check_file_strippedline("mdadm_active1", self.active_mdadm)
self.check_file_strippedline("mdadm_active2", self.active_mdadm)
class TestMdadmBcacheAbs(TestMdadmAbs):
arch_skip = [
"s390x", # lp:1565029
]
conf_file = "examples/tests/mdadm_bcache.yaml"
disk_to_check = [('main_disk', 1),
('main_disk', 2),
('main_disk', 3),
('main_disk', 4),
('main_disk', 5),
('main_disk', 6),
('md0', 0),
('cached_array', 0),
('cached_array_2', 0)]
extra_disks = ['4G', '4G']
collect_scripts = TestMdadmAbs.collect_scripts + [textwrap.dedent("""
cd OUTPUT_COLLECT_D
bcache-super-show /dev/vda6 > bcache_super_vda6
bcache-super-show /dev/vda7 > bcache_super_vda7
bcache-super-show /dev/md0 > bcache_super_md0
ls /sys/fs/bcache > bcache_ls
cat /sys/block/bcache0/bcache/cache_mode > bcache_cache_mode
cat /sys/block/bcache1/bcache/cache_mode >> bcache_cache_mode
cat /sys/block/bcache2/bcache/cache_mode >> bcache_cache_mode
cat /proc/mounts > proc_mounts
find /etc/network/interfaces.d > find_interfacesd
""")]
fstab_expected = {
'/dev/vda1': '/media/sda1',
'/dev/vda7': '/boot',
'/dev/bcache1': '/media/data',
'/dev/bcache0': '/media/bcache_normal',
'/dev/bcache2': '/media/bcachefoo_fulldiskascache_storage'
}
def test_bcache_output_files_exist(self):
self.output_files_exist(["bcache_super_vda6",
"bcache_super_vda7",
"bcache_super_md0",
"bcache_ls",
"bcache_cache_mode"])
def test_bcache_status(self):
bcache_supers = [
"bcache_super_vda6",
"bcache_super_vda7",
"bcache_super_md0",
]
bcache_cset_uuid = None
found = {}
for bcache_super in bcache_supers:
for line in self.load_collect_file(bcache_super).splitlines():
if line != "" and line.split()[0] == "cset.uuid":
bcache_cset_uuid = line.split()[-1].rstrip()
if bcache_cset_uuid in found:
found[bcache_cset_uuid].append(bcache_super)
else:
found[bcache_cset_uuid] = [bcache_super]
self.assertIsNotNone(bcache_cset_uuid)
self.assertTrue(bcache_cset_uuid in
self.load_collect_file("bcache_ls").splitlines())
# one cset.uuid for all devices
self.assertEqual(len(found), 1)
# three devices with same cset.uuid
self.assertEqual(len(found[bcache_cset_uuid]), 3)
# check the cset.uuid in the dict
self.assertEqual(list(found.keys()).pop(),
bcache_cset_uuid)
def test_bcache_cachemode(self):
# definition is on order 0->back,1->through,2->around
# but after reboot it can be anything since order is not guaranteed
# until we find a way to redetect the order we just check that all
# three are there
self.check_file_regex("bcache_cache_mode", r"\[writeback\]")
self.check_file_regex("bcache_cache_mode", r"\[writethrough\]")
self.check_file_regex("bcache_cache_mode", r"\[writearound\]")
class TrustyTestMdadmBcache(relbase.trusty, TestMdadmBcacheAbs):
__test__ = True
# FIXME(LP: #1523037): dname does not work on trusty
# when dname works on trusty, then we need to re-enable by removing line.
def test_dname(self):
print("test_dname does not work for Trusty")
def test_ptable(self):
print("test_ptable does not work for Trusty")
class TrustyHWEUTestMdadmBcache(relbase.trusty_hwe_u, TrustyTestMdadmBcache):
__test__ = True
class WilyTestMdadmBcache(relbase.wily, TestMdadmBcacheAbs):
# EOL - 2016-07-28
__test__ = False
class XenialTestMdadmBcache(relbase.xenial, TestMdadmBcacheAbs):
__test__ = True
class YakketyTestMdadmBcache(relbase.yakkety, TestMdadmBcacheAbs):
__test__ = True
class TestMirrorbootAbs(TestMdadmAbs):
# alternative config for more complex setup
conf_file = "examples/tests/mirrorboot.yaml"
# initialize secondary disk
extra_disks = ['4G']
disk_to_check = [('main_disk', 1),
('main_disk', 2),
('second_disk', 1),
('md0', 0)]
class TrustyTestMirrorboot(relbase.trusty, TestMirrorbootAbs):
__test__ = True
# FIXME(LP: #1523037): dname does not work on trusty
# when dname works on trusty, then we need to re-enable by removing line.
def test_dname(self):
print("test_dname does not work for Trusty")
def test_ptable(self):
print("test_ptable does not work for Trusty")
class TrustyHWEUTestMirrorboot(relbase.trusty_hwe_u, TrustyTestMirrorboot):
# This tests kernel upgrade in target
__test__ = True
class WilyTestMirrorboot(relbase.wily, TestMirrorbootAbs):
# EOL - 2016-07-28
__test__ = False
class XenialTestMirrorboot(relbase.xenial, TestMirrorbootAbs):
__test__ = True
class YakketyTestMirrorboot(relbase.yakkety, TestMirrorbootAbs):
__test__ = True
class TestMirrorbootPartitionsAbs(TestMdadmAbs):
# alternative config for more complex setup
conf_file = "examples/tests/mirrorboot-msdos-partition.yaml"
# initialize secondary disk
extra_disks = ['10G']
disk_to_check = [('main_disk', 1),
('second_disk', 1),
('md0', 2)]
class TrustyTestMirrorbootPartitions(relbase.trusty,
TestMirrorbootPartitionsAbs):
__test__ = True
# FIXME(LP: #1523037): dname does not work on trusty
# when dname works on trusty, then we need to re-enable by removing line.
def test_dname(self):
print("test_dname does not work for Trusty")
def test_ptable(self):
print("test_ptable does not work for Trusty")
class TrustyHWEUTestMirrorbootPartitions(relbase.trusty_hwe_u,
TrustyTestMirrorbootPartitions):
# This tests kernel upgrade in target
__test__ = True
class XenialTestMirrorbootPartitions(relbase.xenial,
TestMirrorbootPartitionsAbs):
__test__ = True
class YakketyTestMirrorbootPartitions(relbase.yakkety,
TestMirrorbootPartitionsAbs):
__test__ = True
class TestRaid5bootAbs(TestMdadmAbs):
# alternative config for more complex setup
conf_file = "examples/tests/raid5boot.yaml"
# initialize secondary disk
extra_disks = ['4G', '4G']
disk_to_check = [('main_disk', 1),
('main_disk', 2),
('second_disk', 1),
('third_disk', 1),
('md0', 0)]
class TrustyTestRaid5Boot(relbase.trusty, TestRaid5bootAbs):
__test__ = True
# FIXME(LP: #1523037): dname does not work on trusty
# when dname works on trusty, then we need to re-enable by removing line.
def test_dname(self):
print("test_dname does not work for Trusty")
def test_ptable(self):
print("test_ptable does not work for Trusty")
class TrustyHWEUTestRaid5Boot(relbase.trusty_hwe_u, TrustyTestRaid5Boot):
# This tests kernel upgrade in target
__test__ = True
class WilyTestRaid5boot(relbase.wily, TestRaid5bootAbs):
# EOL - 2016-07-28
__test__ = False
class XenialTestRaid5boot(relbase.xenial, TestRaid5bootAbs):
__test__ = True
class YakketyTestRaid5boot(relbase.yakkety, TestRaid5bootAbs):
__test__ = True
class TestRaid6bootAbs(TestMdadmAbs):
# alternative config for more complex setup
conf_file = "examples/tests/raid6boot.yaml"
# initialize secondary disk
extra_disks = ['4G', '4G', '4G']
disk_to_check = [('main_disk', 1),
('main_disk', 2),
('second_disk', 1),
('third_disk', 1),
('fourth_disk', 1),
('md0', 0)]
collect_scripts = TestMdadmAbs.collect_scripts + [textwrap.dedent("""
cd OUTPUT_COLLECT_D
mdadm --detail --scan > mdadm_detail
""")]
def test_raid6_output_files_exist(self):
self.output_files_exist(
["mdadm_detail"])
def test_mdadm_custom_name(self):
# the raid6boot.yaml sets this name, check if it was set
self.check_file_regex("mdadm_detail", r"ubuntu:foobar")
class TrustyTestRaid6boot(relbase.trusty, TestRaid6bootAbs):
__test__ = True
# FIXME(LP: #1523037): dname does not work on trusty
# when dname works on trusty, then we need to re-enable by removing line.
def test_dname(self):
print("test_dname does not work for Trusty")
def test_ptable(self):
print("test_ptable does not work for Trusty")
class TrustyHWEUTestRaid6boot(relbase.trusty_hwe_u, TrustyTestRaid6boot):
__test__ = True
class WilyTestRaid6boot(relbase.wily, TestRaid6bootAbs):
# EOL - 2016-07-28
__test__ = False
class XenialTestRaid6boot(relbase.xenial, TestRaid6bootAbs):
__test__ = True
class YakketyTestRaid6boot(relbase.yakkety, TestRaid6bootAbs):
__test__ = True
class TestRaid10bootAbs(TestMdadmAbs):
# alternative config for more complex setup
conf_file = "examples/tests/raid10boot.yaml"
# initialize secondary disk
extra_disks = ['4G', '4G', '4G']
disk_to_check = [('main_disk', 1),
('main_disk', 2),
('second_disk', 1),
('third_disk', 1),
('fourth_disk', 1),
('md0', 0)]
class TrustyTestRaid10boot(relbase.trusty, TestRaid10bootAbs):
__test__ = True
# FIXME(LP: #1523037): dname does not work on trusty
# when dname works on trusty, then we need to re-enable by removing line.
def test_dname(self):
print("test_dname does not work for Trusty")
def test_ptable(self):
print("test_ptable does not work for Trusty")
class TrustyHWEUTestRaid10boot(relbase.trusty_hwe_u, TrustyTestRaid10boot):
__test__ = True
class WilyTestRaid10boot(relbase.wily, TestRaid10bootAbs):
# EOL - 2016-07-28
__test__ = False
class XenialTestRaid10boot(relbase.xenial, TestRaid10bootAbs):
__test__ = True
class YakketyTestRaid10boot(relbase.yakkety, TestRaid10bootAbs):
__test__ = True
class TestAllindataAbs(TestMdadmAbs):
# more complex, needs more time
# alternative config for more complex setup
conf_file = "examples/tests/allindata.yaml"
# we have to avoid a systemd hang due to the way it handles dmcrypt
extra_kern_args = "--- luks=no"
active_mdadm = "4"
# initialize secondary disk
extra_disks = ['5G', '5G', '5G']
disk_to_check = [('main_disk', 1),
('main_disk', 2),
('main_disk', 3),
('main_disk', 4),
('main_disk', 5),
('second_disk', 1),
('second_disk', 2),
('second_disk', 3),
('second_disk', 4),
('third_disk', 1),
('third_disk', 2),
('third_disk', 3),
('third_disk', 4),
('fourth_disk', 1),
('fourth_disk', 2),
('fourth_disk', 3),
('fourth_disk', 4),
('md0', 0),
('md1', 0),
('md2', 0),
('md3', 0),
('vg1-lv1', 0),
('vg1-lv2', 0)]
collect_scripts = TestMdadmAbs.collect_scripts + [textwrap.dedent("""
cd OUTPUT_COLLECT_D
pvdisplay -C --separator = -o vg_name,pv_name --noheadings > pvs
lvdisplay -C --separator = -o lv_name,vg_name --noheadings > lvs
cat /etc/crypttab > crypttab
yes "testkey" | cryptsetup open /dev/vg1/lv3 dmcrypt0 --type luks
ls -laF /dev/mapper/dmcrypt0 > mapper
mkdir -p /tmp/xfstest
mount /dev/mapper/dmcrypt0 /tmp/xfstest
xfs_info /tmp/xfstest/ > xfs_info
""")]
fstab_expected = {
'/dev/vg1/lv1': '/srv/data',
'/dev/vg1/lv2': '/srv/backup',
}
def test_output_files_exist(self):
self.output_files_exist(["pvs", "lvs", "crypttab", "mapper",
"xfs_info"])
def test_lvs(self):
self.check_file_strippedline("lvs", "lv1=vg1")
self.check_file_strippedline("lvs", "lv2=vg1")
self.check_file_strippedline("lvs", "lv3=vg1")
def test_pvs(self):
self.check_file_strippedline("pvs", "vg1=/dev/md0")
self.check_file_strippedline("pvs", "vg1=/dev/md1")
self.check_file_strippedline("pvs", "vg1=/dev/md2")
self.check_file_strippedline("pvs", "vg1=/dev/md3")
def test_dmcrypt(self):
self.check_file_regex("crypttab", r"dmcrypt0.*luks")
self.check_file_regex("mapper", r"^lrwxrwxrwx.*/dev/mapper/dmcrypt0")
self.check_file_regex("xfs_info", r"^meta-data=/dev/mapper/dmcrypt0")
class TrustyTestAllindata(relbase.trusty, TestAllindataAbs):
__test__ = False # luks=no does not disable mounting of device
# FIXME(LP: #1523037): dname does not work on trusty
# when dname works on trusty, then we need to re-enable by removing line.
def test_dname(self):
print("test_dname does not work for Trusty")
def test_ptable(self):
print("test_ptable does not work for Trusty")
class TrustyHWEUTestAllindata(relbase.trusty_hwe_u, TrustyTestAllindata):
__test__ = False # lukes=no does not disable mounting of device
class WilyTestAllindata(relbase.wily, TestAllindataAbs):
# EOL - 2016-07-28
__test__ = False
class XenialTestAllindata(relbase.xenial, TestAllindataAbs):
__test__ = True
class YakketyTestAllindata(relbase.yakkety, TestAllindataAbs):
__test__ = True
|