From 9ac735bb8c0dec5628a33d907adb3fc02fd902e8 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 21 Nov 2017 14:23:36 -0500 Subject: tests: Use apt-get to install a deb so that depends get resolved. Instead of using 'dpkg -i' to install a package and then running apt-get -f install, to hope that it would install needed dependencies we can just use 'apt-get' directly to do the install. The 'dpkg/apt-get -f' path was a problem if the installed deb was older than the available deb. In that case it would get replaced. --- tests/cloud_tests/setup_image.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/cloud_tests') diff --git a/tests/cloud_tests/setup_image.py b/tests/cloud_tests/setup_image.py index 6672ffb3..179f40db 100644 --- a/tests/cloud_tests/setup_image.py +++ b/tests/cloud_tests/setup_image.py @@ -50,9 +50,9 @@ def install_deb(args, image): LOG.debug(msg) remote_path = os.path.join('/tmp', os.path.basename(args.deb)) image.push_file(args.deb, remote_path) - cmd = 'dpkg -i {}; apt-get install --yes -f'.format(remote_path) - image.execute(cmd, description=msg) - + image.execute( + ['apt-get', 'install', '--allow-downgrades', '--assume-yes', + remote_path], description=msg) # check installed deb version matches package fmt = ['-W', "--showformat=${Version}"] (out, err, exit) = image.execute(['dpkg-deb'] + fmt + [remote_path]) -- cgit v1.2.3 From 4964fb38f11c15ed119ff4c7f4379ae3c8785a9a Mon Sep 17 00:00:00 2001 From: Joshua Powers Date: Wed, 22 Nov 2017 11:12:05 -0800 Subject: tests: Enable bionic in integration tests. --- tests/cloud_tests/releases.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/cloud_tests') diff --git a/tests/cloud_tests/releases.yaml b/tests/cloud_tests/releases.yaml index ec7e2d5b..e5933802 100644 --- a/tests/cloud_tests/releases.yaml +++ b/tests/cloud_tests/releases.yaml @@ -122,6 +122,22 @@ features: releases: # UBUNTU ================================================================= + bionic: + # EOL: Apr 2023 + default: + enabled: true + release: bionic + version: 18.04 + family: ubuntu + feature_groups: + - base + - debian_base + - ubuntu_specific + lxd: + sstreams_server: https://cloud-images.ubuntu.com/daily + alias: bionic + setup_overrides: null + override_templates: false artful: # EOL: Jul 2018 default: -- cgit v1.2.3 From 88368f9851b29dddb5a12e4b21868cbdef906c5c Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 29 Nov 2017 15:26:38 -0500 Subject: tests: NoCloudKVMImage do not modify the original local cache image. The NoCloudKVMImage.execute() would modify the image in /srv/citest that meant that after the first time you ran a test, the image was dirty. The change here is to make the image operate on a qcow backed image. Also modify Snapshot to then copy the qcow rather than creating another chained qcow. The reason being that the image might go away or change after the snapshot has been returned. Also * drop use of 'override_templates' which was only relevant to LXD. * NoCloudKVM.create_image() returned an instance before now it has create_instance which creates an instance. * NoCloudKVMInstance has a 'disk' attribute separate from 'name' --- tests/cloud_tests/images/nocloudkvm.py | 22 +++++++++++++++------- tests/cloud_tests/instances/nocloudkvm.py | 8 +++++--- tests/cloud_tests/platforms/nocloudkvm.py | 21 +++++++++++---------- tests/cloud_tests/snapshots/nocloudkvm.py | 17 +++++++++++------ 4 files changed, 42 insertions(+), 26 deletions(-) (limited to 'tests/cloud_tests') diff --git a/tests/cloud_tests/images/nocloudkvm.py b/tests/cloud_tests/images/nocloudkvm.py index 1e7962cb..8678b07f 100644 --- a/tests/cloud_tests/images/nocloudkvm.py +++ b/tests/cloud_tests/images/nocloudkvm.py @@ -4,6 +4,10 @@ from cloudinit import util as c_util +import os +import shutil +import tempfile + from tests.cloud_tests.images import base from tests.cloud_tests.snapshots import nocloudkvm as nocloud_kvm_snapshot @@ -13,7 +17,7 @@ class NoCloudKVMImage(base.Image): platform_name = "nocloud-kvm" - def __init__(self, platform, config, img_path): + def __init__(self, platform, config, orig_img_path): """Set up image. @param platform: platform object @@ -21,7 +25,13 @@ class NoCloudKVMImage(base.Image): @param img_path: path to the image """ self.modified = False - self._img_path = img_path + self._workd = tempfile.mkdtemp(prefix='NoCloudKVMImage') + self._orig_img_path = orig_img_path + self._img_path = os.path.join(self._workd, + os.path.basename(self._orig_img_path)) + + c_util.subp(['qemu-img', 'create', '-f', 'qcow2', + '-b', orig_img_path, self._img_path]) super(NoCloudKVMImage, self).__init__(platform, config) @@ -61,13 +71,9 @@ class NoCloudKVMImage(base.Image): if not self._img_path: raise RuntimeError() - instance = self.platform.create_image( - self.properties, self.config, self.features, - self._img_path, image_desc=str(self), use_desc='snapshot') - return nocloud_kvm_snapshot.NoCloudKVMSnapshot( self.platform, self.properties, self.config, - self.features, instance) + self.features, self._img_path) def destroy(self): """Unset path to signal image is no longer used. @@ -77,6 +83,8 @@ class NoCloudKVMImage(base.Image): framework decide whether to keep or destroy everything. """ self._img_path = None + shutil.rmtree(self._workd) + super(NoCloudKVMImage, self).destroy() # vi: ts=4 expandtab diff --git a/tests/cloud_tests/instances/nocloudkvm.py b/tests/cloud_tests/instances/nocloudkvm.py index cc825800..bc06a79e 100644 --- a/tests/cloud_tests/instances/nocloudkvm.py +++ b/tests/cloud_tests/instances/nocloudkvm.py @@ -25,12 +25,13 @@ class NoCloudKVMInstance(base.Instance): platform_name = "nocloud-kvm" _ssh_client = None - def __init__(self, platform, name, properties, config, features, - user_data, meta_data): + def __init__(self, platform, name, image_path, properties, config, + features, user_data, meta_data): """Set up instance. @param platform: platform object @param name: image path + @param image_path: path to disk image to boot. @param properties: dictionary of properties @param config: dictionary of configuration values @param features: dictionary of supported feature flags @@ -43,6 +44,7 @@ class NoCloudKVMInstance(base.Instance): self.pid = None self.pid_file = None self.console_file = None + self.disk = image_path super(NoCloudKVMInstance, self).__init__( platform, name, properties, config, features) @@ -145,7 +147,7 @@ class NoCloudKVMInstance(base.Instance): self.ssh_port = self.get_free_port() cmd = ['./tools/xkvm', - '--disk', '%s,cache=unsafe' % self.name, + '--disk', '%s,cache=unsafe' % self.disk, '--disk', '%s,cache=unsafe' % seed, '--netdev', ','.join(['user', 'hostfwd=tcp::%s-:22' % self.ssh_port, diff --git a/tests/cloud_tests/platforms/nocloudkvm.py b/tests/cloud_tests/platforms/nocloudkvm.py index f1f81877..76cd83ad 100644 --- a/tests/cloud_tests/platforms/nocloudkvm.py +++ b/tests/cloud_tests/platforms/nocloudkvm.py @@ -55,19 +55,20 @@ class NoCloudKVMPlatform(base.Platform): for fname in glob.iglob(search_d, recursive=True): images.append(fname) - if len(images) != 1: - raise Exception('No unique images found') + if len(images) < 1: + raise RuntimeError("No images found under '%s'" % search_d) + if len(images) > 1: + raise RuntimeError( + "Multiple images found in '%s': %s" % (search_d, + ' '.join(images))) image = nocloud_kvm_image.NoCloudKVMImage(self, img_conf, images[0]) - if img_conf.get('override_templates', False): - image.update_templates(self.config.get('template_overrides', {}), - self.config.get('template_files', {})) return image - def create_image(self, properties, config, features, - src_img_path, image_desc=None, use_desc=None, - user_data=None, meta_data=None): - """Create an image + def create_instance(self, properties, config, features, + src_img_path, image_desc=None, use_desc=None, + user_data=None, meta_data=None): + """Create an instance @param src_img_path: image path to launch from @param properties: image properties @@ -82,7 +83,7 @@ class NoCloudKVMPlatform(base.Platform): c_util.subp(['qemu-img', 'create', '-f', 'qcow2', '-b', src_img_path, img_path]) - return nocloud_kvm_instance.NoCloudKVMInstance(self, img_path, + return nocloud_kvm_instance.NoCloudKVMInstance(self, name, img_path, properties, config, features, user_data, meta_data) diff --git a/tests/cloud_tests/snapshots/nocloudkvm.py b/tests/cloud_tests/snapshots/nocloudkvm.py index 09998349..21e908da 100644 --- a/tests/cloud_tests/snapshots/nocloudkvm.py +++ b/tests/cloud_tests/snapshots/nocloudkvm.py @@ -2,6 +2,8 @@ """Base NoCloud KVM snapshot.""" import os +import shutil +import tempfile from tests.cloud_tests.snapshots import base @@ -11,16 +13,19 @@ class NoCloudKVMSnapshot(base.Snapshot): platform_name = "nocloud-kvm" - def __init__(self, platform, properties, config, features, - instance): + def __init__(self, platform, properties, config, features, image_path): """Set up snapshot. @param platform: platform object @param properties: image properties @param config: image config @param features: supported feature flags + @param image_path: image file to snapshot. """ - self.instance = instance + self._workd = tempfile.mkdtemp(prefix='NoCloudKVMSnapshot') + snapshot = os.path.join(self._workd, 'snapshot') + shutil.copyfile(image_path, snapshot) + self._image_path = snapshot super(NoCloudKVMSnapshot, self).__init__( platform, properties, config, features) @@ -40,9 +45,9 @@ class NoCloudKVMSnapshot(base.Snapshot): self.platform.config['public_key']) user_data = self.inject_ssh_key(user_data, key_file) - instance = self.platform.create_image( + instance = self.platform.create_instance( self.properties, self.config, self.features, - self.instance.name, image_desc=str(self), use_desc=use_desc, + self._image_path, image_desc=str(self), use_desc=use_desc, user_data=user_data, meta_data=meta_data) if start: @@ -68,7 +73,7 @@ class NoCloudKVMSnapshot(base.Snapshot): def destroy(self): """Clean up snapshot data.""" - self.instance.destroy() + shutil.rmtree(self._workd) super(NoCloudKVMSnapshot, self).destroy() # vi: ts=4 expandtab -- cgit v1.2.3