Merge lp:~raharper/curtin/trunk.dirty-disks-in-early-command into lp:~curtin-dev/curtin/trunk

Proposed by Ryan Harper
Status: Merged
Merged at revision: 498
Proposed branch: lp:~raharper/curtin/trunk.dirty-disks-in-early-command
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 451 lines (+84/-16)
18 files modified
doc/topics/integration-testing.rst (+5/-0)
examples/tests/allindata.yaml (+4/-0)
examples/tests/basic.yaml (+1/-0)
examples/tests/bcache_basic.yaml (+1/-0)
examples/tests/dirty_disks_config.yaml (+10/-0)
examples/tests/lvm.yaml (+1/-0)
examples/tests/mdadm_bcache.yaml (+3/-0)
examples/tests/mdadm_bcache_complex.yaml (+3/-0)
examples/tests/mirrorboot-uefi.yaml (+0/-12)
examples/tests/mirrorboot.yaml (+2/-0)
examples/tests/raid10boot.yaml (+4/-0)
examples/tests/raid5boot.yaml (+3/-0)
examples/tests/raid6boot.yaml (+4/-0)
tests/vmtests/__init__.py (+30/-1)
tests/vmtests/test_basic.py (+2/-0)
tests/vmtests/test_bcache_basic.py (+2/-0)
tests/vmtests/test_mdadm_bcache.py (+2/-0)
tools/launch (+7/-3)
To merge this branch: bzr merge lp:~raharper/curtin/trunk.dirty-disks-in-early-command
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Scott Moser (community) Approve
Review via email: mp+323179@code.launchpad.net

Description of the change

vmtests: enable tests apply storage config to validate clear_holders path

Allow test classes with storage configurations to optionally run curtin
block-meta during the early stage to "dirty" the disks used in the
test-case. This exercises curtin's clear-holders path to closer match
MAAS redeploying systems with existing storage configurations. In some
cases, we need to run with multiple virtual processors to allow race
conditions to occur and exercise curtin's handling of these situations.

- Add class attribute 'nr_cpus' (integer) to control number of VCPUS used
  in the guest.
  Defaults to 1, allows CURTIN_VMTEST_NR_CPUS env to override for all tests.
- Add class attribute 'dirty_disks' (boolean) to control if a test class
  will enable running the early command.
  Defaults to False
- Add class attribute 'dirty_disk_config' (string) which is path to the
  generic early_command yaml blob used to run curtin block-meta with the
  test-case's storage config.
  Defaults to 'examples/tests/dirty_disks_config.yaml'
- tools/launch accepts --smp to control the number of VCPUS to use in the
  VM

To post a comment you must log in.
498. By Ryan Harper

Remove early_commands from bcache, enable via class attr, whitespace

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) :
review: Approve
499. By Ryan Harper

merge from trunk

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
500. By Ryan Harper

Add wipe: superblock to all storage configs

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
501. By Ryan Harper

Fix mising comma after smp entry in getops long_opts

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
502. By Ryan Harper

merge from trunk

503. By Ryan Harper

Use nr_cpus and dirty_disks to handle regression testing of mirrorboot-uefi

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
504. By Ryan Harper

merge from trunk

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'doc/topics/integration-testing.rst'
2--- doc/topics/integration-testing.rst 2017-04-21 18:09:54 +0000
3+++ doc/topics/integration-testing.rst 2017-05-15 15:58:10 +0000
4@@ -205,6 +205,11 @@
5 This modifies the invocation of nosetets to add '--processes' and other
6 necessary nose arguments (--process-timeout)
7
8+- ``CURTIN_VMTEST_NR_CPUS``: default ''
9+
10+ Allow environment to override the number of virtual cpus to allocate
11+ in the target virtual machines.
12+
13 - ``IMAGE_DIR``: default /srv/images
14
15 Vmtest keeps a mirror of maas ephemeral images in this directory.
16
17=== modified file 'examples/tests/allindata.yaml'
18--- examples/tests/allindata.yaml 2016-04-14 01:45:54 +0000
19+++ examples/tests/allindata.yaml 2017-05-15 15:58:10 +0000
20@@ -4,6 +4,7 @@
21 config:
22 - id: sda
23 type: disk
24+ wipe: superblock
25 ptable: gpt
26 model: QEMU HARDDISK
27 path: /dev/vdb
28@@ -42,6 +43,7 @@
29 number: 6 # XXX: we really need to stop using id with DiskPartnum
30 - id: sdb
31 type: disk
32+ wipe: superblock
33 ptable: gpt
34 model: QEMU HARDDISK
35 path: /dev/vdc
36@@ -64,6 +66,7 @@
37 device: sdb
38 - id: sdc
39 type: disk
40+ wipe: superblock
41 ptable: gpt
42 model: QEMU HARDDISK
43 path: /dev/vdd
44@@ -86,6 +89,7 @@
45 device: sdc
46 - id: sdd
47 type: disk
48+ wipe: superblock
49 ptable: gpt
50 model: QEMU HARDDISK
51 path: /dev/vde
52
53=== modified file 'examples/tests/basic.yaml'
54--- examples/tests/basic.yaml 2016-08-01 17:18:18 +0000
55+++ examples/tests/basic.yaml 2017-05-15 15:58:10 +0000
56@@ -25,6 +25,7 @@
57 type: format
58 fstype: ext4
59 volume: sda1
60+ label: 'cloudimg-rootfs'
61 - id: sda2_home
62 type: format
63 fstype: ext4
64
65=== modified file 'examples/tests/bcache_basic.yaml'
66--- examples/tests/bcache_basic.yaml 2016-04-04 16:03:32 +0000
67+++ examples/tests/bcache_basic.yaml 2017-05-15 15:58:10 +0000
68@@ -1,4 +1,5 @@
69 showtrace: true
70+
71 storage:
72 config:
73 - id: id_rotary0
74
75=== added file 'examples/tests/dirty_disks_config.yaml'
76--- examples/tests/dirty_disks_config.yaml 1970-01-01 00:00:00 +0000
77+++ examples/tests/dirty_disks_config.yaml 2017-05-15 15:58:10 +0000
78@@ -0,0 +1,10 @@
79+early_commands:
80+ # running block-meta custom from the install environment
81+ # inherits the CONFIG environment, so this works to actually prepare
82+ # the disks exactly as in this config before the rest of the install
83+ # will just blow it all away. We have clean out other environment
84+ # that could unintentionally mess things up.
85+ blockmeta: [env, -u, OUTPUT_FSTAB,
86+ TARGET_MOUNT_POINT=/tmp/my.bdir/target,
87+ WORKING_DIR=/tmp/my.bdir/work.d,
88+ curtin, --showtrace, -v, block-meta, --umount, custom]
89
90=== modified file 'examples/tests/lvm.yaml'
91--- examples/tests/lvm.yaml 2016-04-04 16:03:32 +0000
92+++ examples/tests/lvm.yaml 2017-05-15 15:58:10 +0000
93@@ -4,6 +4,7 @@
94 config:
95 - id: sda
96 type: disk
97+ wipe: superblock
98 ptable: msdos
99 model: QEMU HARDDISK
100 path: /dev/vdb
101
102=== modified file 'examples/tests/mdadm_bcache.yaml'
103--- examples/tests/mdadm_bcache.yaml 2016-04-17 22:35:20 +0000
104+++ examples/tests/mdadm_bcache.yaml 2017-05-15 15:58:10 +0000
105@@ -5,6 +5,7 @@
106 - grub_device: true
107 id: sda
108 type: disk
109+ wipe: superblock
110 ptable: gpt
111 model: QEMU HARDDISK
112 path: /dev/vdb
113@@ -53,11 +54,13 @@
114 uuid: deadbeef-dead-beef-dead-deadbeefaaa6
115 - id: sdb
116 type: disk
117+ wipe: superblock
118 model: QEMU HARDDISK
119 path: /dev/vdc
120 name: second_disk
121 - id: sdc
122 type: disk
123+ wipe: superblock
124 ptable: gpt
125 model: QEMU HARDDISK
126 path: /dev/vdd
127
128=== modified file 'examples/tests/mdadm_bcache_complex.yaml'
129--- examples/tests/mdadm_bcache_complex.yaml 2015-11-25 13:45:53 +0000
130+++ examples/tests/mdadm_bcache_complex.yaml 2017-05-15 15:58:10 +0000
131@@ -4,6 +4,7 @@
132 - grub_device: true
133 id: sda
134 type: disk
135+ wipe: superblock
136 ptable: gpt
137 model: QEMU HARDDISK
138 path: /dev/vdb
139@@ -43,11 +44,13 @@
140 device: sda
141 - id: sdb
142 type: disk
143+ wipe: superblock
144 model: QEMU HARDDISK
145 path: /dev/vdc
146 name: second_disk
147 - id: sdc
148 type: disk
149+ wipe: superblock
150 ptable: gpt
151 model: QEMU HARDDISK
152 path: /dev/vdd
153
154=== modified file 'examples/tests/mirrorboot-uefi.yaml'
155--- examples/tests/mirrorboot-uefi.yaml 2017-05-03 02:10:47 +0000
156+++ examples/tests/mirrorboot-uefi.yaml 2017-05-15 15:58:10 +0000
157@@ -1,16 +1,4 @@
158 showtrace: true
159-
160-early_commands:
161- # running block-meta custom from the install environment
162- # inherits the CONFIG environment, so this works to actually prepare
163- # the disks exactly as in this config before the rest of the install
164- # will just blow it all away. We have to clean out the other
165- # environment that could unintentionally mess things up.
166- blockmeta: [env, -u, OUTPUT_FSTAB,
167- TARGET_MOUNT_POINT=/tmp/my.bdir/target,
168- WORKING_DIR=/tmp/my.bdir/work.d,
169- curtin, --showtrace, -v, block-meta, --umount, custom]
170-
171 storage:
172 config:
173 - grub_device: true
174
175=== modified file 'examples/tests/mirrorboot.yaml'
176--- examples/tests/mirrorboot.yaml 2016-04-04 16:03:32 +0000
177+++ examples/tests/mirrorboot.yaml 2017-05-15 15:58:10 +0000
178@@ -4,6 +4,7 @@
179 config:
180 - id: sda
181 type: disk
182+ wipe: superblock
183 ptable: gpt
184 model: QEMU HARDDISK
185 path: /dev/vdb
186@@ -20,6 +21,7 @@
187 device: sda
188 - id: sdb
189 type: disk
190+ wipe: superblock
191 ptable: gpt
192 model: QEMU HARDDISK
193 path: /dev/vdc
194
195=== modified file 'examples/tests/raid10boot.yaml'
196--- examples/tests/raid10boot.yaml 2016-04-04 16:03:32 +0000
197+++ examples/tests/raid10boot.yaml 2017-05-15 15:58:10 +0000
198@@ -4,6 +4,7 @@
199 config:
200 - id: sda
201 type: disk
202+ wipe: superblock
203 ptable: gpt
204 model: QEMU HARDDISK
205 path: /dev/vdb
206@@ -20,6 +21,7 @@
207 device: sda
208 - id: sdb
209 type: disk
210+ wipe: superblock
211 ptable: gpt
212 model: QEMU HARDDISK
213 path: /dev/vdc
214@@ -30,6 +32,7 @@
215 device: sdb
216 - id: sdc
217 type: disk
218+ wipe: superblock
219 ptable: gpt
220 model: QEMU HARDDISK
221 path: /dev/vdd
222@@ -40,6 +43,7 @@
223 device: sdc
224 - id: sdd
225 type: disk
226+ wipe: superblock
227 ptable: gpt
228 model: QEMU HARDDISK
229 path: /dev/vde
230
231=== modified file 'examples/tests/raid5boot.yaml'
232--- examples/tests/raid5boot.yaml 2016-04-04 16:03:32 +0000
233+++ examples/tests/raid5boot.yaml 2017-05-15 15:58:10 +0000
234@@ -4,6 +4,7 @@
235 config:
236 - id: sda
237 type: disk
238+ wipe: superblock
239 ptable: gpt
240 model: QEMU HARDDISK
241 path: /dev/vdb
242@@ -20,6 +21,7 @@
243 device: sda
244 - id: sdb
245 type: disk
246+ wipe: superblock
247 ptable: gpt
248 model: QEMU HARDDISK
249 path: /dev/vdc
250@@ -30,6 +32,7 @@
251 device: sdb
252 - id: sdc
253 type: disk
254+ wipe: superblock
255 ptable: gpt
256 model: QEMU HARDDISK
257 path: /dev/vdd
258
259=== modified file 'examples/tests/raid6boot.yaml'
260--- examples/tests/raid6boot.yaml 2016-04-04 16:03:32 +0000
261+++ examples/tests/raid6boot.yaml 2017-05-15 15:58:10 +0000
262@@ -4,6 +4,7 @@
263 config:
264 - id: sda
265 type: disk
266+ wipe: superblock
267 ptable: gpt
268 model: QEMU HARDDISK
269 path: /dev/vdb
270@@ -20,6 +21,7 @@
271 device: sda
272 - id: sdb
273 type: disk
274+ wipe: superblock
275 ptable: gpt
276 model: QEMU HARDDISK
277 path: /dev/vdc
278@@ -30,6 +32,7 @@
279 device: sdb
280 - id: sdc
281 type: disk
282+ wipe: superblock
283 ptable: gpt
284 model: QEMU HARDDISK
285 path: /dev/vdd
286@@ -40,6 +43,7 @@
287 device: sdc
288 - id: sdd
289 type: disk
290+ wipe: superblock
291 ptable: gpt
292 model: QEMU HARDDISK
293 path: /dev/vde
294
295=== modified file 'tests/vmtests/__init__.py'
296--- tests/vmtests/__init__.py 2017-04-21 20:08:30 +0000
297+++ tests/vmtests/__init__.py 2017-05-15 15:58:10 +0000
298@@ -333,6 +333,9 @@
299 boot_timeout = BOOT_TIMEOUT
300 collect_scripts = []
301 conf_file = "examples/tests/basic.yaml"
302+ nr_cpus = None
303+ dirty_disks = False
304+ dirty_disk_config = "examples/tests/dirty_disks_config.yaml"
305 disk_block_size = 512
306 disk_driver = 'virtio-blk'
307 disk_to_check = {}
308@@ -507,6 +510,26 @@
309 bugnum, clsname)
310
311 @classmethod
312+ def get_config_smp(cls):
313+ """Get number of cpus to use for guest"""
314+
315+ nr_cpus = None
316+ if cls.nr_cpus:
317+ nr_cpus = cls.nr_cpus
318+ logger.debug('Setting cpus from class value: %s', nr_cpus)
319+
320+ env_cpus = os.environ.get("CURTIN_VMTEST_NR_CPUS", None)
321+ if env_cpus:
322+ nr_cpus = env_cpus
323+ logger.debug('Setting cpus from '
324+ ' env["CURTIN_VMTEST_NR_CPUS"] value: %s', nr_cpus)
325+ if not nr_cpus:
326+ nr_cpus = 1
327+ logger.debug('Setting cpus to default value: %s', nr_cpus)
328+
329+ return str(nr_cpus)
330+
331+ @classmethod
332 def setUpClass(cls):
333 # check if we should skip due to host arch
334 if cls.arch in cls.arch_skip:
335@@ -535,7 +558,8 @@
336 dowait = "--dowait"
337
338 # create launch cmd
339- cmd = ["tools/launch", "--arch=" + cls.arch, "-v", dowait]
340+ cmd = ["tools/launch", "--arch=" + cls.arch, "-v", dowait,
341+ "--smp=" + cls.get_config_smp()]
342 if not cls.interactive:
343 cmd.extend(["--silent", "--power=off"])
344
345@@ -646,6 +670,10 @@
346 fp.write(json.dumps({'grub': {'update_nvram': True}}))
347 configs.append(grub_config)
348
349+ if cls.dirty_disks and storage_config:
350+ logger.debug("Injecting early_command to dirty storage devices")
351+ configs.append(cls.dirty_disk_config)
352+
353 excfg = os.environ.get("CURTIN_VMTEST_EXTRA_CONFIG", False)
354 if excfg:
355 configs.append(excfg)
356@@ -789,6 +817,7 @@
357 target_disks + extra_disks + nvme_disks +
358 ["--", "-drive",
359 "file=%s,if=virtio,media=cdrom" % cls.td.seed_disk,
360+ "-smp", cls.get_config_smp(),
361 "-m", "1024"])
362
363 if not cls.interactive:
364
365=== modified file 'tests/vmtests/test_basic.py'
366--- tests/vmtests/test_basic.py 2017-04-26 16:14:04 +0000
367+++ tests/vmtests/test_basic.py 2017-05-15 15:58:10 +0000
368@@ -8,6 +8,8 @@
369
370 class TestBasicAbs(VMBaseClass):
371 interactive = False
372+ nr_cpus = 2
373+ dirty_disks = True
374 conf_file = "examples/tests/basic.yaml"
375 extra_disks = ['128G', '128G', '4G']
376 nvme_disks = ['4G']
377
378=== modified file 'tests/vmtests/test_bcache_basic.py'
379--- tests/vmtests/test_bcache_basic.py 2017-04-26 16:14:04 +0000
380+++ tests/vmtests/test_bcache_basic.py 2017-05-15 15:58:10 +0000
381@@ -9,6 +9,8 @@
382 "s390x", # lp:1565029
383 ]
384 conf_file = "examples/tests/bcache_basic.yaml"
385+ nr_cpus = 2
386+ dirty_disks = True
387 extra_disks = ['2G']
388 collect_scripts = [textwrap.dedent("""
389 cd OUTPUT_COLLECT_D
390
391=== modified file 'tests/vmtests/test_mdadm_bcache.py'
392--- tests/vmtests/test_mdadm_bcache.py 2017-05-10 21:29:20 +0000
393+++ tests/vmtests/test_mdadm_bcache.py 2017-05-15 15:58:10 +0000
394@@ -262,6 +262,8 @@
395 ('md1', 0)]
396 active_mdadm = "2"
397 uefi = True
398+ nr_cpus = 2
399+ dirty_disks = True
400
401
402 class TrustyTestMirrorbootPartitionsUEFI(relbase.trusty,
403
404=== modified file 'tools/launch'
405--- tools/launch 2017-04-24 21:20:53 +0000
406+++ tools/launch 2017-05-15 15:58:10 +0000
407@@ -41,6 +41,7 @@
408 -n | --netdev netdev can be 'user' or a bridge
409 -p | --publish F make file 'F' available in web server
410 --silent use -nographic
411+ -s | --smp S use smp S for number of guest cpus (defaults to 2)
412 --vnc D use -vnc D (mutually exclusive with --silent)
413 directly through to qemu-system.
414 Note, qemu adds 5900 to port numbers. (:0 = port 5900)
415@@ -349,8 +350,9 @@
416 }
417
418 main() {
419- local short_opts="a:A:d:h:i:k:n:p:v"
420- local long_opts="add:,append:,arch:,bios:,disk:,dowait,help,initrd:,kernel:,mem:,netdev:,no-dowait,power:,publish:,root-arg:,silent,serial-log:,uefi-nvram:,verbose,vnc:"
421+ local short_opts="a:A:d:h:i:k:n:p:s:v"
422+ local
423+ long_opts="add:,append:,arch:,bios:,disk:,dowait,help,initrd:,kernel:,mem:,netdev:,no-dowait,power:,publish:,root-arg:,silent,serial-log:,smp:,uefi-nvram:,verbose,vnc:"
424 local getopt_out=""
425 getopt_out=$(getopt --name "${0##*/}" \
426 --options "${short_opts}" --long "${long_opts}" -- "$@") &&
427@@ -358,7 +360,7 @@
428 { bad_Usage; return 1; }
429
430 local seed=""
431- local bootimg="" bootimg_dist="" target="" mem="1024"
432+ local bootimg="" bootimg_dist="" target="" mem="1024" smp="2"
433 local udata="" ip="" http_port="${HTTP_PORT}" burl=""
434 local tmp="" top_d
435 local initrd="" kernel="" uappend="" iargs="" disk_args=""
436@@ -412,6 +414,7 @@
437 --root-arg) root_arg="$next";;
438 --serial-log) serial_log="$next"; shift;;
439 --silent) video="-nographic";;
440+ -s|--smp) smp="$next"; shift;;
441 --uefi-nvram|--bios)
442 # handle all --opt=* pass through here.
443 pt[${#pt[@]}]="$cur=$next";;
444@@ -725,6 +728,7 @@
445 # -monitor stdio
446 cmd=(
447 xkvm "${pt[@]}" "${netargs[@]}" --
448+ -smp ${smp}
449 -m ${mem} ${serial_args} ${video}
450 -drive "file=$bootimg,if=none,cache=unsafe,format=qcow2,id=boot,index=0"
451 -device "virtio-blk,drive=boot"

Subscribers

People subscribed via source and target branches