From f951c8c83f95ae71141e9999f0826843b59a9d72 Mon Sep 17 00:00:00 2001 From: Jeff Lane Date: Mon, 3 Apr 2017 11:16:36 -0400 Subject: Fixed bug where the test would fail if LXD_TEMPLATE and LXD_ROOTFS were not set in the conf file. LP: #1679213 --- bin/virtualization | 19 +++++++++++++++++-- jobs/virtualization.txt.in | 2 +- 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: -- cgit v1.2.3