diff --git a/.zuul.yaml b/.zuul.yaml index 6e50b40e..3a4a5a12 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -69,6 +69,7 @@ WHITEBOX_CPU_TOPOLOGY: "0: [0,1,2,3,4,5,6,7]" WHITEBOX_DEDICATED_CPUS_PER_NUMA: 3 NOVA_CONSOLE_PROXY_COMPUTE_TLS: True + IMAGE_URLS: http://download.cirros-cloud.net/0.6.2/cirros-0.6.2-x86_64-disk.img, http://download.cirros-cloud.net/0.6.1/cirros-0.6.1-x86_64-disk.img, http://tinycorelinux.net/14.x/x86/archive/14.0/Core-14.0.iso devstack_local_conf: test-config: $TEMPEST_CONFIG: diff --git a/whitebox_tempest_plugin/api/compute/base.py b/whitebox_tempest_plugin/api/compute/base.py index 4301fe80..b5c285e4 100644 --- a/whitebox_tempest_plugin/api/compute/base.py +++ b/whitebox_tempest_plugin/api/compute/base.py @@ -75,6 +75,16 @@ class BaseWhiteboxComputeTest(base.BaseV2ComputeAdminTest): **extra_specs) return flavor + def create_keypair(self, **kwargs): + """Creates keypair""" + if not kwargs.get('name'): + kwargs['name'] = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name=self.__class__.__name__) + body = self.keypairs_client.create_keypair(**kwargs) + self.addCleanup(self.keypairs_client.delete_keypair, kwargs['name']) + return body['keypair'] + def reboot_server(self, server_id, type): """Reboot a server and wait for it to be ACTIVE.""" self.servers_client.reboot_server(server_id, type=type) diff --git a/whitebox_tempest_plugin/api/compute/test_iso_image.py b/whitebox_tempest_plugin/api/compute/test_iso_image.py new file mode 100644 index 00000000..aa05b1d3 --- /dev/null +++ b/whitebox_tempest_plugin/api/compute/test_iso_image.py @@ -0,0 +1,82 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import os + +from oslo_log import log as logging + +from tempest.common import utils +from tempest import config +from tempest.lib.common.utils import data_utils + +from whitebox_tempest_plugin.api.compute import base + +CONF = config.CONF +LOG = logging.getLogger(__name__) + + +class TestIsoImage(base.BaseWhiteboxComputeTest): + + @classmethod + def skip_checks(cls): + super(TestIsoImage, cls).skip_checks() + if 'iso' not in CONF.image.disk_formats: + raise cls.skipException('iso disk format is not configured.') + cls.img_file = CONF.whitebox.http_iso_image + if not os.path.exists(cls.img_file): + raise cls.skipException('iso image is not configured.') + + def store_iso_image_in_glance(self): + name = data_utils.rand_name( + prefix=CONF.resource_name_prefix, + name="-iso-image") + params = { + 'name': name, + 'container_format': CONF.image.container_formats[0], + 'disk_format': 'iso', + } + image = self.images_client.create_image(**params) + self.addCleanup(self.images_client.delete_image, image['id']) + with open(self.img_file, 'rb') as image_file: + self.images_client.store_image_file(image['id'], image_file) + return image['id'] + + @utils.services('compute', 'image', 'network') + def test_boot_server_from_iso_image(self): + """Test booting server from iso image and perform basic operations. + + Steps: + 1. Create and store iso image in glance + 2. Create keypair + 3. Boot instance from iso image and with keypair + 4. Check if server booted from iso image is via cdrom + 5. Reboot instance + 6. Check if server booted from iso image is via cdrom + """ + image_id = self.store_iso_image_in_glance() + keypair = self.create_keypair() + server = self.create_test_server( + image_id=image_id, + key_name=keypair['name'], + wait_until="ACTIVE") + domain_xml = self.get_server_xml(server['id']) + boot_from_cdrom = domain_xml.find("./devices/disk[@device='cdrom']") + msg = ("Server %s booted from iso image is not via cdrom: %s", + server['id'], domain_xml) + self.assertIsNotNone(boot_from_cdrom, msg) + + self.reboot_server(server['id'], type='HARD') + domain_xml = self.get_server_xml(server['id']) + boot_from_cdrom = domain_xml.find("./devices/disk[@device='cdrom']") + msg = ("Server %s rebooted from iso image is not via cdrom: %s", + server['id'], domain_xml) + self.assertIsNotNone(boot_from_cdrom, msg) diff --git a/whitebox_tempest_plugin/config.py b/whitebox_tempest_plugin/config.py index 2516b4cf..de0a68d6 100644 --- a/whitebox_tempest_plugin/config.py +++ b/whitebox_tempest_plugin/config.py @@ -139,6 +139,11 @@ general_opts = [ default=64, help="RAM size in MB to use when launching the guests backed " "by hugepages."), + cfg.StrOpt( + 'http_iso_image', + default='/opt/stack/devstack/files/Core-14.0.iso', + help='http iso image which will be used to create image in ' + 'glance and boot server from iso format image.'), ] nova_compute_group = cfg.OptGroup(