diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cloud_tests/bddeb.py | 3 | ||||
-rw-r--r-- | tests/cloud_tests/collect.py | 8 | ||||
-rw-r--r-- | tests/cloud_tests/images/__init__.py | 10 | ||||
-rw-r--r-- | tests/cloud_tests/instances/__init__.py | 10 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/__init__.py | 20 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/images.py (renamed from tests/cloud_tests/images/base.py) | 0 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/instances.py (renamed from tests/cloud_tests/instances/base.py) | 0 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/lxd/image.py (renamed from tests/cloud_tests/images/lxd.py) | 11 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/lxd/instance.py (renamed from tests/cloud_tests/instances/lxd.py) | 6 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/lxd/platform.py (renamed from tests/cloud_tests/platforms/lxd.py) | 14 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/lxd/snapshot.py (renamed from tests/cloud_tests/snapshots/lxd.py) | 4 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/nocloudkvm/image.py (renamed from tests/cloud_tests/images/nocloudkvm.py) | 11 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/nocloudkvm/instance.py (renamed from tests/cloud_tests/instances/nocloudkvm.py) | 4 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/nocloudkvm/platform.py (renamed from tests/cloud_tests/platforms/nocloudkvm.py) | 16 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/nocloudkvm/snapshot.py (renamed from tests/cloud_tests/snapshots/nocloudkvm.py) | 4 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/platforms.py (renamed from tests/cloud_tests/platforms/base.py) | 0 | ||||
-rw-r--r-- | tests/cloud_tests/platforms/snapshots.py (renamed from tests/cloud_tests/snapshots/base.py) | 0 | ||||
-rw-r--r-- | tests/cloud_tests/snapshots/__init__.py | 10 |
18 files changed, 57 insertions, 74 deletions
diff --git a/tests/cloud_tests/bddeb.py b/tests/cloud_tests/bddeb.py index fba8a0c7..c259dfea 100644 --- a/tests/cloud_tests/bddeb.py +++ b/tests/cloud_tests/bddeb.py @@ -8,7 +8,8 @@ import tempfile from cloudinit import util as c_util from tests.cloud_tests import (config, LOG) -from tests.cloud_tests import (platforms, images, snapshots, instances) +from tests.cloud_tests.platforms import (platforms, images, snapshots, + instances) from tests.cloud_tests.stage import (PlatformComponent, run_stage, run_single) pre_reqs = ['devscripts', 'equivs', 'git', 'tar'] diff --git a/tests/cloud_tests/collect.py b/tests/cloud_tests/collect.py index 71ee7645..db5ee99f 100644 --- a/tests/cloud_tests/collect.py +++ b/tests/cloud_tests/collect.py @@ -8,7 +8,7 @@ import os from cloudinit import util as c_util from tests.cloud_tests import (config, LOG, setup_image, util) from tests.cloud_tests.stage import (PlatformComponent, run_stage, run_single) -from tests.cloud_tests import (platforms, images, snapshots, instances) +from tests.cloud_tests import platforms def collect_script(instance, base_dir, script, script_name): @@ -77,7 +77,7 @@ def collect_test_data(args, snapshot, os_name, test_name): # create test instance component = PlatformComponent( - partial(instances.get_instance, snapshot, user_data, + partial(platforms.get_instance, snapshot, user_data, block=True, start=False, use_desc=test_name)) LOG.info('collecting test data for test: %s', test_name) @@ -108,7 +108,7 @@ def collect_snapshot(args, image, os_name): """ res = ({}, 1) - component = PlatformComponent(partial(snapshots.get_snapshot, image)) + component = PlatformComponent(partial(platforms.get_snapshot, image)) LOG.debug('creating snapshot for %s', os_name) with component as snapshot: @@ -136,7 +136,7 @@ def collect_image(args, platform, os_name): feature_overrides=args.feature_override) LOG.debug('os config: %s', os_config) component = PlatformComponent( - partial(images.get_image, platform, os_config)) + partial(platforms.get_image, platform, os_config)) LOG.info('acquiring image for os: %s', os_name) with component as image: diff --git a/tests/cloud_tests/images/__init__.py b/tests/cloud_tests/images/__init__.py deleted file mode 100644 index 106c59f3..00000000 --- a/tests/cloud_tests/images/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# This file is part of cloud-init. See LICENSE file for license information. - -"""Main init.""" - - -def get_image(platform, config): - """Get image from platform object using os_name.""" - return platform.get_image(config) - -# vi: ts=4 expandtab diff --git a/tests/cloud_tests/instances/__init__.py b/tests/cloud_tests/instances/__init__.py deleted file mode 100644 index fc2e9cbc..00000000 --- a/tests/cloud_tests/instances/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# This file is part of cloud-init. See LICENSE file for license information. - -"""Main init.""" - - -def get_instance(snapshot, *args, **kwargs): - """Get instance from snapshot.""" - return snapshot.launch(*args, **kwargs) - -# vi: ts=4 expandtab diff --git a/tests/cloud_tests/platforms/__init__.py b/tests/cloud_tests/platforms/__init__.py index 3490fe87..92ed1627 100644 --- a/tests/cloud_tests/platforms/__init__.py +++ b/tests/cloud_tests/platforms/__init__.py @@ -2,8 +2,8 @@ """Main init.""" -from tests.cloud_tests.platforms import lxd -from tests.cloud_tests.platforms import nocloudkvm +from .lxd import platform as lxd +from .nocloudkvm import platform as nocloudkvm PLATFORMS = { 'nocloud-kvm': nocloudkvm.NoCloudKVMPlatform, @@ -11,6 +11,16 @@ PLATFORMS = { } +def get_image(platform, config): + """Get image from platform object using os_name.""" + return platform.get_image(config) + + +def get_instance(snapshot, *args, **kwargs): + """Get instance from snapshot.""" + return snapshot.launch(*args, **kwargs) + + def get_platform(platform_name, config): """Get the platform object for 'platform_name' and init.""" platform_cls = PLATFORMS.get(platform_name) @@ -18,4 +28,10 @@ def get_platform(platform_name, config): raise ValueError('invalid platform name: {}'.format(platform_name)) return platform_cls(config) + +def get_snapshot(image): + """Get snapshot from image.""" + return image.snapshot() + + # vi: ts=4 expandtab diff --git a/tests/cloud_tests/images/base.py b/tests/cloud_tests/platforms/images.py index d503108a..d503108a 100644 --- a/tests/cloud_tests/images/base.py +++ b/tests/cloud_tests/platforms/images.py diff --git a/tests/cloud_tests/instances/base.py b/tests/cloud_tests/platforms/instances.py index 8c59d62c..8c59d62c 100644 --- a/tests/cloud_tests/instances/base.py +++ b/tests/cloud_tests/platforms/instances.py diff --git a/tests/cloud_tests/images/lxd.py b/tests/cloud_tests/platforms/lxd/image.py index 5caeba41..b5de1f52 100644 --- a/tests/cloud_tests/images/lxd.py +++ b/tests/cloud_tests/platforms/lxd/image.py @@ -6,13 +6,13 @@ import os import shutil import tempfile +from ..images import Image +from .snapshot import LXDSnapshot from cloudinit import util as c_util -from tests.cloud_tests.images import base -from tests.cloud_tests.snapshots import lxd as lxd_snapshot from tests.cloud_tests import util -class LXDImage(base.Image): +class LXDImage(Image): """LXD backed image.""" platform_name = "lxd" @@ -182,9 +182,8 @@ class LXDImage(base.Image): instance.run_script(self.config.get('boot_clean_script')) # freeze current instance and return snapshot instance.freeze() - return lxd_snapshot.LXDSnapshot( - self.platform, self.properties, self.config, - self.features, instance) + return LXDSnapshot(self.platform, self.properties, self.config, + self.features, instance) def destroy(self): """Clean up data associated with image.""" diff --git a/tests/cloud_tests/instances/lxd.py b/tests/cloud_tests/platforms/lxd/instance.py index 3b035d86..0d697c05 100644 --- a/tests/cloud_tests/instances/lxd.py +++ b/tests/cloud_tests/platforms/lxd/instance.py @@ -2,14 +2,14 @@ """Base LXD instance.""" -from . import base - import os import shutil from tempfile import mkdtemp +from ..instances import Instance + -class LXDInstance(base.Instance): +class LXDInstance(Instance): """LXD container backed instance.""" platform_name = "lxd" diff --git a/tests/cloud_tests/platforms/lxd.py b/tests/cloud_tests/platforms/lxd/platform.py index ead0955b..6a016929 100644 --- a/tests/cloud_tests/platforms/lxd.py +++ b/tests/cloud_tests/platforms/lxd/platform.py @@ -4,15 +4,15 @@ from pylxd import (Client, exceptions) -from tests.cloud_tests.images import lxd as lxd_image -from tests.cloud_tests.instances import lxd as lxd_instance -from tests.cloud_tests.platforms import base +from ..platforms import Platform +from .image import LXDImage +from .instance import LXDInstance from tests.cloud_tests import util DEFAULT_SSTREAMS_SERVER = "https://images.linuxcontainers.org:8443" -class LXDPlatform(base.Platform): +class LXDPlatform(Platform): """LXD test platform.""" platform_name = 'lxd' @@ -33,7 +33,7 @@ class LXDPlatform(base.Platform): pylxd_image = self.client.images.create_from_simplestreams( img_conf.get('sstreams_server', DEFAULT_SSTREAMS_SERVER), img_conf['alias']) - image = lxd_image.LXDImage(self, img_conf, pylxd_image) + image = LXDImage(self, img_conf, pylxd_image) if img_conf.get('override_templates', False): image.update_templates(self.config.get('template_overrides', {}), self.config.get('template_files', {})) @@ -69,8 +69,8 @@ class LXDPlatform(base.Platform): 'source': ({'type': 'image', 'fingerprint': image} if image else {'type': 'copy', 'source': container}) }, wait=block) - return lxd_instance.LXDInstance(self, container.name, properties, - config, features, container) + return LXDInstance(self, container.name, properties, config, features, + container) def container_exists(self, container_name): """Check if container with name 'container_name' exists. diff --git a/tests/cloud_tests/snapshots/lxd.py b/tests/cloud_tests/platforms/lxd/snapshot.py index 39c55c5e..b524644f 100644 --- a/tests/cloud_tests/snapshots/lxd.py +++ b/tests/cloud_tests/platforms/lxd/snapshot.py @@ -2,10 +2,10 @@ """Base LXD snapshot.""" -from tests.cloud_tests.snapshots import base +from ..snapshots import Snapshot -class LXDSnapshot(base.Snapshot): +class LXDSnapshot(Snapshot): """LXD image copy backed snapshot.""" platform_name = "lxd" diff --git a/tests/cloud_tests/images/nocloudkvm.py b/tests/cloud_tests/platforms/nocloudkvm/image.py index 8678b07f..09ff2a3b 100644 --- a/tests/cloud_tests/images/nocloudkvm.py +++ b/tests/cloud_tests/platforms/nocloudkvm/image.py @@ -8,11 +8,11 @@ import os import shutil import tempfile -from tests.cloud_tests.images import base -from tests.cloud_tests.snapshots import nocloudkvm as nocloud_kvm_snapshot +from ..images import Image +from .snapshot import NoCloudKVMSnapshot -class NoCloudKVMImage(base.Image): +class NoCloudKVMImage(Image): """NoCloud KVM backed image.""" platform_name = "nocloud-kvm" @@ -71,9 +71,8 @@ class NoCloudKVMImage(base.Image): if not self._img_path: raise RuntimeError() - return nocloud_kvm_snapshot.NoCloudKVMSnapshot( - self.platform, self.properties, self.config, - self.features, self._img_path) + return NoCloudKVMSnapshot(self.platform, self.properties, self.config, + self.features, self._img_path) def destroy(self): """Unset path to signal image is no longer used. diff --git a/tests/cloud_tests/instances/nocloudkvm.py b/tests/cloud_tests/platforms/nocloudkvm/instance.py index bc06a79e..a87d76a6 100644 --- a/tests/cloud_tests/instances/nocloudkvm.py +++ b/tests/cloud_tests/platforms/nocloudkvm/instance.py @@ -8,8 +8,8 @@ import socket import subprocess import time +from ..instances import Instance from cloudinit import util as c_util -from tests.cloud_tests.instances import base from tests.cloud_tests import util # This domain contains reverse lookups for hostnames that are used. @@ -19,7 +19,7 @@ from tests.cloud_tests import util CI_DOMAIN = "i9n.cloud-init.io" -class NoCloudKVMInstance(base.Instance): +class NoCloudKVMInstance(Instance): """NoCloud KVM backed instance.""" platform_name = "nocloud-kvm" diff --git a/tests/cloud_tests/platforms/nocloudkvm.py b/tests/cloud_tests/platforms/nocloudkvm/platform.py index 76cd83ad..85933463 100644 --- a/tests/cloud_tests/platforms/nocloudkvm.py +++ b/tests/cloud_tests/platforms/nocloudkvm/platform.py @@ -9,14 +9,14 @@ from simplestreams import mirrors from simplestreams import objectstores from simplestreams import util as s_util +from ..platforms import Platform +from .image import NoCloudKVMImage +from .instance import NoCloudKVMInstance from cloudinit import util as c_util -from tests.cloud_tests.images import nocloudkvm as nocloud_kvm_image -from tests.cloud_tests.instances import nocloudkvm as nocloud_kvm_instance -from tests.cloud_tests.platforms import base from tests.cloud_tests import util -class NoCloudKVMPlatform(base.Platform): +class NoCloudKVMPlatform(Platform): """NoCloud KVM test platform.""" platform_name = 'nocloud-kvm' @@ -62,7 +62,7 @@ class NoCloudKVMPlatform(base.Platform): "Multiple images found in '%s': %s" % (search_d, ' '.join(images))) - image = nocloud_kvm_image.NoCloudKVMImage(self, img_conf, images[0]) + image = NoCloudKVMImage(self, img_conf, images[0]) return image def create_instance(self, properties, config, features, @@ -83,9 +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, name, img_path, - properties, config, - features, user_data, - meta_data) + return NoCloudKVMInstance(self, name, img_path, properties, config, + features, user_data, meta_data) # vi: ts=4 expandtab diff --git a/tests/cloud_tests/snapshots/nocloudkvm.py b/tests/cloud_tests/platforms/nocloudkvm/snapshot.py index 21e908da..0005e1f2 100644 --- a/tests/cloud_tests/snapshots/nocloudkvm.py +++ b/tests/cloud_tests/platforms/nocloudkvm/snapshot.py @@ -5,10 +5,10 @@ import os import shutil import tempfile -from tests.cloud_tests.snapshots import base +from ..snapshots import Snapshot -class NoCloudKVMSnapshot(base.Snapshot): +class NoCloudKVMSnapshot(Snapshot): """NoCloud KVM image copy backed snapshot.""" platform_name = "nocloud-kvm" diff --git a/tests/cloud_tests/platforms/base.py b/tests/cloud_tests/platforms/platforms.py index 28975368..28975368 100644 --- a/tests/cloud_tests/platforms/base.py +++ b/tests/cloud_tests/platforms/platforms.py diff --git a/tests/cloud_tests/snapshots/base.py b/tests/cloud_tests/platforms/snapshots.py index 94328982..94328982 100644 --- a/tests/cloud_tests/snapshots/base.py +++ b/tests/cloud_tests/platforms/snapshots.py diff --git a/tests/cloud_tests/snapshots/__init__.py b/tests/cloud_tests/snapshots/__init__.py deleted file mode 100644 index 93a54f5e..00000000 --- a/tests/cloud_tests/snapshots/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# This file is part of cloud-init. See LICENSE file for license information. - -"""Main init.""" - - -def get_snapshot(image): - """Get snapshot from image.""" - return image.snapshot() - -# vi: ts=4 expandtab |