summaryrefslogtreecommitdiff
diff options
authorJeff Lane <jeffrey.lane@canonical.com>2017-04-03 11:16:36 -0400
committerJeff Lane <jeffrey.lane@canonical.com>2017-04-03 11:16:36 -0400
commitf951c8c83f95ae71141e9999f0826843b59a9d72 (patch)
tree2025e7285e67214da8b13c32fb33f3f5363e5cf9
parentadfec3866c718ce3382aa1ce7626475e1c5d6226 (diff)
Fixed bug where the test would fail if LXD_TEMPLATE and LXD_ROOTFS were not set in the conf file. LP: #1679213
-rwxr-xr-xbin/virtualization19
-rw-r--r--jobs/virtualization.txt.in2
2 files changed, 18 insertions, 3 deletions
diff --git a/bin/virtualization b/bin/virtualization
index 438a1a2..d79926c 100755
--- a/bin/virtualization
+++ b/bin/virtualization
@@ -620,7 +620,7 @@ class LXDTest(object):
self.rootfs_tarball = filename
# Insert images
- if result is True:
+ if self.template_url is not None and self.rootfs_url is not None:
logging.debug("Importing images into LXD")
cmd = 'lxc image import {} rootfs {} --alias {}'.format(
self.template_tarball, self.rootfs_tarball,
@@ -707,7 +707,22 @@ class LXDTest(object):
def test_lxd(args):
logging.debug("Executing LXD Test")
- lxd_test = LXDTest(args.template, args.rootfs)
+ template = None
+ rootfs = None
+
+ # First in priority are environment variables.
+ if 'LXD_TEMPLATE' in os.environ:
+ template = os.environ['LXD_TEMPLATE']
+ if 'LXD_ROOTFS' in os.environ:
+ rootfs = os.environ['LXD_ROOTFS']
+
+ # Finally, highest-priority are command line arguments.
+ if args.template:
+ template = args.template
+ if args.rootfs:
+ rootfs = args.rootfs
+
+ lxd_test = LXDTest(template, rootfs)
result = lxd_test.start()
lxd_test.cleanup()
diff --git a/jobs/virtualization.txt.in b/jobs/virtualization.txt.in
index 2a466af..f31f948 100644
--- a/jobs/virtualization.txt.in
+++ b/jobs/virtualization.txt.in
@@ -24,7 +24,7 @@ estimated_duration: 30.0
requires:
package.name == 'lxd-client'
package.name == 'lxd'
-command: virtualization lxd --template $LXD_TEMPLATE --rootfs $LXD_ROOTFS
+command: virtualization --debug lxd
_description:
Verifies that an LXD container can be created and launched
_summary: