Merge lp:~raharper/curtin/trunk.vmtest-tar-sparse-disks into lp:~curtin-dev/curtin/trunk

Proposed by Ryan Harper
Status: Merged
Approved by: Scott Moser
Approved revision: 532
Merged at revision: 527
Proposed branch: lp:~raharper/curtin/trunk.vmtest-tar-sparse-disks
Merge into: lp:~curtin-dev/curtin/trunk
Diff against target: 74 lines (+27/-1)
3 files modified
doc/topics/integration-testing.rst (+6/-0)
tests/vmtests/__init__.py (+20/-1)
tools/jenkins-runner (+1/-0)
To merge this branch: bzr merge lp:~raharper/curtin/trunk.vmtest-tar-sparse-disks
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
Scott Moser (community) Approve
Review via email: mp+331512@code.launchpad.net

Description of the change

vmtests: add option to tar disk images after test run

vmtests may create a number of disk image files for use, these
are all sparse disks which report a size larger than the actual
space they occupy. In some cases someone copying files may
not be aware of the sparseness and expand the images instead.
Setting CURTIN_VMTEST_TAR_DISKS=1 will trigger vmtest to tar
sparsely the files and write out a .tar file in the same path.

This flag is disabled by default.

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

Add docs for CURTIN_VMTEST_TAR_DISKS

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) wrote :

nits. but approve with those changes.

review: Approve
529. By Ryan Harper

Reduce vertical space used

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

Drop quotes from CURTIN_VMTEST_TAR_DISKS variable

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

Change language around values that trigger behavior

532. By Ryan Harper

Grammar fix

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-05-19 20:26:31 +0000
3+++ doc/topics/integration-testing.rst 2017-09-28 21:15:09 +0000
4@@ -161,6 +161,12 @@
5 - ``logs``: install and boot logs
6 - ``collect``: data collected by the boot phase
7
8+- ``CURTIN_VMTEST_TAR_DISKS``: default 0
9+
10+ Vmtest writes out disk image files sparsely into a disks directory
11+ If this flag is set to a non-zero number, vmtest will tar all disks in
12+ the directory into a single disks.tar and remove the sparse disk files.
13+
14 - ``CURTIN_VMTEST_TOPDIR``: default $TMPDIR/vmtest-<timestamp>
15
16 Vmtest puts all test data under this value. By default, it creates
17
18=== modified file 'tests/vmtests/__init__.py'
19--- tests/vmtests/__init__.py 2017-09-01 21:57:13 +0000
20+++ tests/vmtests/__init__.py 2017-09-28 21:15:09 +0000
21@@ -38,6 +38,7 @@
22 CURTIN_VMTEST_IMAGE_SYNC = os.environ.get("CURTIN_VMTEST_IMAGE_SYNC", "1")
23 IMAGE_SYNCS = []
24 TARGET_IMAGE_FORMAT = "raw"
25+TAR_DISKS = bool(int(os.environ.get("CURTIN_VMTEST_TAR_DISKS", "0")))
26
27
28 DEFAULT_BRIDGE = os.environ.get("CURTIN_VMTEST_BRIDGE", "user")
29@@ -938,7 +939,8 @@
30 clean_working_dir(cls.td.tmpdir, success,
31 keep_pass=KEEP_DATA['pass'],
32 keep_fail=KEEP_DATA['fail'])
33-
34+ if TAR_DISKS:
35+ tar_disks(cls.td.tmpdir)
36 cls.cleanIscsiState(success,
37 keep_pass=KEEP_DATA['pass'],
38 keep_fail=KEEP_DATA['fail'])
39@@ -1424,6 +1426,23 @@
40 KEEP_DATA.update(data)
41
42
43+def tar_disks(tmpdir, outfile="disks.tar", diskmatch=".img"):
44+ """ Tar up files in ``tmpdir``/disks that ends with the pattern supplied"""
45+
46+ disks_dir = os.path.join(tmpdir, "disks")
47+ if os.path.exists(disks_dir):
48+ outfile = os.path.join(disks_dir, outfile)
49+ disks = [os.path.join(disks_dir, disk) for disk in
50+ os.listdir(disks_dir) if disk.endswith(diskmatch)]
51+ cmd = ["tar", "--create", "--file=%s" % outfile,
52+ "--verbose", "--remove-files", "--sparse"]
53+ cmd.extend(disks)
54+ logger.info('Taring %s disks sparsely to %s', len(disks), outfile)
55+ util.subp(cmd, capture=True)
56+ else:
57+ logger.error('Failed to find "disks" dir under tmpdir: %s', tmpdir)
58+
59+
60 def boot_log_wrap(name, func, cmd, console_log, timeout, purpose):
61 logger.debug("%s[%s]: booting with timeout=%s log=%s cmd: %s",
62 name, purpose, timeout, console_log, ' '.join(cmd))
63
64=== modified file 'tools/jenkins-runner'
65--- tools/jenkins-runner 2017-08-03 15:36:52 +0000
66+++ tools/jenkins-runner 2017-09-28 21:15:09 +0000
67@@ -4,6 +4,7 @@
68 pkeep=${CURTIN_VMTEST_KEEP_DATA_PASS:-logs,collect}
69 fkeep=${CURTIN_VMTEST_KEEP_DATA_FAIL:-logs,collect}
70 reuse=${CURTIN_VMTEST_REUSE_TOPDIR:-0}
71+export CURTIN_VMTEST_TAR_DISKS=${CURTIN_VMTEST_TAR_DISKS:-0}
72 export CURTIN_VMTEST_REUSE_TOPDIR=$reuse
73 export CURTIN_VMTEST_IMAGE_SYNC=${CURTIN_VMTEST_IMAGE_SYNC:-0}
74 export CURTIN_VMTEST_KEEP_DATA_PASS=$pkeep

Subscribers

People subscribed via source and target branches