From bc437b2bc76839ae7872bdefe39e7e39b54b1194 Mon Sep 17 00:00:00 2001 From: Cristina Pauna Date: Tue, 7 Mar 2017 16:52:35 +0200 Subject: Adapt integration tests to use custom image config This fix uses the possibility to pass custom imformation about the image via image_metadata variable. In the integration tests it checks for this info and creates a 3-part image if the kernel_url and ramdisk_url are set. The fix also allows the default url to be overriden as well as passing extra-properties. All the metadata info comes from the app. The part in functest where the custom config is set for creating a 3-part image is https://gerrit.opnfv.org/gerrit/29987 Change-Id: Ib2ad823705dbea68d672514c7c89b150c9c6dc63 Signed-off-by: Cristina Pauna --- snaps/openstack/tests/create_image_tests.py | 206 +++++++++++++++--- snaps/openstack/tests/create_instance_tests.py | 273 +++++++++++++++++++----- snaps/provisioning/tests/ansible_utils_tests.py | 36 +++- snaps/test_suite_builder.py | 48 +++-- 4 files changed, 450 insertions(+), 113 deletions(-) diff --git a/snaps/openstack/tests/create_image_tests.py b/snaps/openstack/tests/create_image_tests.py index 753e83f..c74846c 100644 --- a/snaps/openstack/tests/create_image_tests.py +++ b/snaps/openstack/tests/create_image_tests.py @@ -197,6 +197,7 @@ class CreateImageSuccessTests(OSIntegrationTestCase): self.nova = nova_utils.nova_client(self.os_creds) self.glance = glance_utils.glance_client(self.os_creds) + self.image_creators = list() self.tmp_dir = 'tmp/' + str(guid) if not os.path.exists(self.tmp_dir): @@ -206,8 +207,10 @@ class CreateImageSuccessTests(OSIntegrationTestCase): """ Cleans the image and downloaded image file """ - if self.image_creator: - self.image_creator.clean() + if self.image_creators: + while self.image_creators: + self.image_creators[-1].clean() + self.image_creators.pop() if os.path.exists(self.tmp_dir) and os.path.isdir(self.tmp_dir): shutil.rmtree(self.tmp_dir) @@ -219,10 +222,32 @@ class CreateImageSuccessTests(OSIntegrationTestCase): Tests the creation of an OpenStack image from a URL. """ # Create Image + # Set the default image settings, then set any custom parameters sent from the app os_image_settings = openstack_tests.cirros_url_image(name=self.image_name) - self.image_creator = create_image.OpenStackImage(self.os_creds, os_image_settings) + if self.image_metadata: + if self.image_metadata['disk_url']: + os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + os_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=self.image_name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=self.image_name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id - created_image = self.image_creator.create() + self.image_creators.append(create_image.OpenStackImage(self.os_creds, os_image_settings)) + created_image = self.image_creators[-1].create() self.assertIsNotNone(created_image) retrieved_image = glance_utils.get_image(self.nova, self.glance, os_image_settings.name) @@ -235,16 +260,37 @@ class CreateImageSuccessTests(OSIntegrationTestCase): """ Tests the creation of an OpenStack image from a URL and set properties. """ - # Set properties - properties = {} - properties['hw_video_model'] = 'vga' - # Create Image + # Set the default image settings, then set any custom parameters sent from the app os_image_settings = openstack_tests.cirros_url_image(name=self.image_name) - os_image_settings.extra_properties = properties - self.image_creator = create_image.OpenStackImage(self.os_creds, os_image_settings) + # Set properties + os_image_settings.extra_properties = {'hw_video_model' : 'vga'} + + if self.image_metadata: + if self.image_metadata['disk_url']: + os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + os_image_settings.extra_properties = dict(os_image_settings.extra_properties.items() + + self.image_metadata['extra_properties'].items()) + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=self.image_name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=self.image_name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id - created_image = self.image_creator.create() + self.image_creators.append(create_image.OpenStackImage(self.os_creds, os_image_settings)) + created_image = self.image_creators[-1].create() self.assertIsNotNone(created_image) retrieved_image = glance_utils.get_image(self.nova, self.glance, os_image_settings.name) @@ -258,17 +304,45 @@ class CreateImageSuccessTests(OSIntegrationTestCase): """ Tests the creation of an OpenStack image from a file. """ + + # Create Image + # Set the default image settings, then set any custom parameters sent from the app url_image_settings = openstack_tests.cirros_url_image('foo') + if self.image_metadata: + if self.image_metadata['disk_url']: + url_image_settings.url = self.image_metadata['disk_url'] + + # Download the file of the image image_file = file_utils.download(url_image_settings.url, self.tmp_dir) file_image_settings = openstack_tests.file_image_test_settings(name=self.image_name, file_path=image_file.name) - self.image_creator = create_image.OpenStackImage(self.os_creds, file_image_settings) - self.image = self.image_creator.create() - self.assertIsNotNone(self.image) - self.assertEqual(self.image_name, self.image.name) + # Set extra properties sent from the app (if any) + if self.image_metadata: + if self.image_metadata['extra_properties']: + file_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_file = file_utils.download(self.image_metadata['kernel_url'], self.tmp_dir) + kernel_image_settings = openstack_tests.file_image_test_settings( + name=self.image_name+'_kernel', file_path=kernel_image_file.name) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + file_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_file = file_utils.download(self.image_metadata['ramdisk_url'], self.tmp_dir) + ramdisk_image_settings = openstack_tests.file_image_test_settings( + name=self.image_name+'_ramdisk', file_path=ramdisk_image_file.name) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + file_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id - created_image = self.image_creator.create() + self.image_creators.append(create_image.OpenStackImage(self.os_creds, file_image_settings)) + created_image = self.image_creators[-1].create() self.assertIsNotNone(created_image) + self.assertEqual(self.image_name, created_image.name) retrieved_image = glance_utils.get_image(self.nova, self.glance, file_image_settings.name) self.assertIsNotNone(retrieved_image) @@ -281,28 +355,76 @@ class CreateImageSuccessTests(OSIntegrationTestCase): Tests the creation then deletion of an OpenStack image to ensure clean() does not raise an Exception. """ # Create Image + # Set the default image settings, then set any custom parameters sent from the app os_image_settings = openstack_tests.cirros_url_image(name=self.image_name) - self.image_creator = create_image.OpenStackImage(self.os_creds, os_image_settings) - created_image = self.image_creator.create() + if self.image_metadata: + if self.image_metadata['disk_url']: + os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + os_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=self.image_name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=self.image_name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id + + self.image_creators.append(create_image.OpenStackImage(self.os_creds, os_image_settings)) + created_image = self.image_creators[-1].create() self.assertIsNotNone(created_image) # Delete Image manually glance_utils.delete_image(self.glance, created_image) - self.assertIsNone(glance_utils.get_image(self.nova, self.glance, self.image_creator.image_settings.name)) + self.assertIsNone(glance_utils.get_image(self.nova, self.glance, self.image_creators[-1].image_settings.name)) # Must not throw an exception when attempting to cleanup non-existent image - self.image_creator.clean() - self.assertIsNone(self.image_creator.get_image()) + self.image_creators[-1].clean() + self.assertIsNone(self.image_creators[-1].get_image()) + self.image_creators.pop() def test_create_same_image(self): """ Tests the creation of an OpenStack image when the image already exists. """ # Create Image + # Set the default image settings, then set any custom parameters sent from the app os_image_settings = openstack_tests.cirros_url_image(name=self.image_name) - self.image_creator = create_image.OpenStackImage(self.os_creds, os_image_settings) - image1 = self.image_creator.create() + if self.image_metadata: + if self.image_metadata['disk_url']: + os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + os_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=self.image_name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=self.image_name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id + + self.image_creators.append(create_image.OpenStackImage(self.os_creds, os_image_settings)) + image1 = self.image_creators[-1].create() + # Should be retrieving the instance data os_image_2 = create_image.OpenStackImage(self.os_creds, os_image_settings) image2 = os_image_2.create() @@ -437,8 +559,8 @@ class CreateMultiPartImageTests(OSIntegrationTestCase): Cleans the images and downloaded image file """ while self.image_creators: - self.image_creators[0].clean() - self.image_creators.pop(0) + self.image_creators[-1].clean() + self.image_creators.pop() if os.path.exists(self.tmp_dir) and os.path.isdir(self.tmp_dir): shutil.rmtree(self.tmp_dir) @@ -451,10 +573,14 @@ class CreateMultiPartImageTests(OSIntegrationTestCase): """ # Set properties properties = {} + if self.image_metadata and self.image_metadata['extra_properties']: + properties = self.image_metadata['extra_properties'] # Create the kernel image kernel_image_settings = openstack_tests.cirros_url_image(name=self.image_name+'_kernel', url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-kernel') + if self.image_metadata and self.image_metadata['kernel_url']: + kernel_image_settings.url = self.image_metadata['kernel_url'] self.image_creators.append(create_image.OpenStackImage(self.os_creds, kernel_image_settings)) kernel_image = self.image_creators[-1].create() self.assertIsNotNone(kernel_image) @@ -462,6 +588,8 @@ class CreateMultiPartImageTests(OSIntegrationTestCase): # Create the ramdisk image ramdisk_image_settings = openstack_tests.cirros_url_image(name=self.image_name+'_ramdisk', url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-initramfs') + if self.image_metadata and self.image_metadata['ramdisk_url']: + ramdisk_image_settings.url = self.image_metadata['ramdisk_url'] self.image_creators.append(create_image.OpenStackImage(self.os_creds, ramdisk_image_settings)) ramdisk_image = self.image_creators[-1].create() self.assertIsNotNone(ramdisk_image) @@ -469,9 +597,13 @@ class CreateMultiPartImageTests(OSIntegrationTestCase): # Create the main image os_image_settings = openstack_tests.cirros_url_image(name=self.image_name, url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img') + if self.image_metadata and self.image_metadata['disk_url']: + os_image_settings.url = self.image_metadata['disk_url'] + properties['kernel_id'] = kernel_image.id properties['ramdisk_id'] = ramdisk_image.id os_image_settings.extra_properties = properties + self.image_creators.append(create_image.OpenStackImage(self.os_creds, os_image_settings)) created_image = self.image_creators[-1].create() self.assertIsNotNone(created_image) @@ -490,11 +622,13 @@ class CreateMultiPartImageTests(OSIntegrationTestCase): """ # Set properties properties = {} - + if self.image_metadata and self.image_metadata['extra_properties']: + properties = self.image_metadata['extra_properties'] # Create the kernel image - url_image_settings = openstack_tests.cirros_url_image('foo_kernel', - url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-kernel') - kernel_image_file = file_utils.download(url_image_settings.url, self.tmp_dir) + kernel_url = 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-kernel' + if self.image_metadata and self.image_metadata['kernel_url']: + kernel_url = self.image_metadata['kernel_url'] + kernel_image_file = file_utils.download(kernel_url, self.tmp_dir) kernel_file_image_settings = openstack_tests.file_image_test_settings( name=self.image_name+'_kernel', file_path=kernel_image_file.name) self.image_creators.append(create_image.OpenStackImage(self.os_creds, kernel_file_image_settings)) @@ -502,9 +636,10 @@ class CreateMultiPartImageTests(OSIntegrationTestCase): self.assertIsNotNone(kernel_image) # Create the ramdisk image - url_image_settings = openstack_tests.cirros_url_image('foo_ramdisk', - url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-initramfs') - ramdisk_image_file = file_utils.download(url_image_settings.url, self.tmp_dir) + ramdisk_url = 'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-initramfs' + if self.image_metadata and self.image_metadata['ramdisk_url']: + ramdisk_url = self.image_metadata['ramdisk_url'] + ramdisk_image_file = file_utils.download(ramdisk_url, self.tmp_dir) ramdisk_file_image_settings = openstack_tests.file_image_test_settings( name=self.image_name+'_ramdisk', file_path=ramdisk_image_file.name) self.image_creators.append(create_image.OpenStackImage(self.os_creds, ramdisk_file_image_settings)) @@ -512,9 +647,10 @@ class CreateMultiPartImageTests(OSIntegrationTestCase): self.assertIsNotNone(ramdisk_image) # Create the main image - url_image_settings = openstack_tests.cirros_url_image('foo', - url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img') - image_file = file_utils.download(url_image_settings.url, self.tmp_dir) + image_url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img' + if self.image_metadata and self.image_metadata['disk_url']: + umage_url = self.image_metadata['disk_url'] + image_file = file_utils.download(image_url, self.tmp_dir) file_image_settings = openstack_tests.file_image_test_settings(name=self.image_name, file_path=image_file.name) properties['kernel_id'] = kernel_image.id properties['ramdisk_id'] = ramdisk_image.id diff --git a/snaps/openstack/tests/create_instance_tests.py b/snaps/openstack/tests/create_instance_tests.py index 9a02765..d32dcf6 100644 --- a/snaps/openstack/tests/create_instance_tests.py +++ b/snaps/openstack/tests/create_instance_tests.py @@ -253,7 +253,8 @@ class SimpleHealthCheck(OSIntegrationTestCase): self.port_settings = PortSettings( name=self.port_1_name, network_name=self.priv_net_config.network_settings.name) - # set the default image settings, then set any custom parameters sent from the app + # Create Image + # Set the default image settings, then set any custom parameters sent from the app self.os_image_settings = openstack_tests.cirros_url_image(name=guid + '-image') if self.image_metadata: @@ -263,7 +264,7 @@ class SimpleHealthCheck(OSIntegrationTestCase): self.os_image_settings.extra_properties = self.image_metadata['extra_properties'] try: - # Create Image; if this is a 3-part image create the kernel and ramdisk images first + # If this is a 3-part image create the kernel and ramdisk images first if self.image_metadata: if self.image_metadata['kernel_url']: kernel_image_settings = openstack_tests.cirros_url_image( @@ -384,7 +385,7 @@ class CreateInstanceSimpleTests(OSIntegrationTestCase): router_name=guid + '-pub-router', external_net=self.ext_net_name) # Initialize for tearDown() - self.image_creator = None + self.image_creators = list() self.flavor_creator = None self.net_creator = None @@ -392,8 +393,31 @@ class CreateInstanceSimpleTests(OSIntegrationTestCase): try: # Create Image - self.image_creator = OpenStackImage(self.os_creds, self.os_image_settings) - self.image_creator.create() + # Set any custom parameters sent from the app + if self.image_metadata: + if self.image_metadata['disk_url']: + self.os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + self.os_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id + + self.image_creators.append(OpenStackImage(self.os_creds, self.os_image_settings)) + self.image_creators[-1].create() # Create Flavor self.flavor_creator = OpenStackFlavor( @@ -434,9 +458,11 @@ class CreateInstanceSimpleTests(OSIntegrationTestCase): except Exception as e: logger.error('Unexpected exception cleaning network with message - ' + e.message) - if self.image_creator: + if self.image_creators: try: - self.image_creator.clean() + while self.image_creators: + self.image_creators[-1].clean() + self.image_creators.pop() except Exception as e: logger.error('Unexpected exception cleaning image with message - ' + e.message) @@ -450,7 +476,7 @@ class CreateInstanceSimpleTests(OSIntegrationTestCase): port_settings=[self.port_settings]) self.inst_creator = OpenStackVmInstance( - self.os_creds, instance_settings, self.image_creator.image_settings) + self.os_creds, instance_settings, self.image_creators[-1].image_settings) vm_inst = self.inst_creator.create() self.assertEquals(1, len(nova_utils.get_servers_by_name(self.nova, instance_settings.name))) @@ -487,7 +513,7 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase): self.floating_ip_name = guid + 'fip1' # Initialize for tearDown() - self.image_creator = None + self.image_creators = list() self.network_creator = None self.router_creator = None self.flavor_creator = None @@ -501,8 +527,31 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase): try: # Create Image - self.image_creator = OpenStackImage(self.os_creds, self.os_image_settings) - self.image_creator.create() + # Set any custom parameters sent from the app + if self.image_metadata: + if self.image_metadata['disk_url']: + self.os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + self.os_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id + + self.image_creators.append(OpenStackImage(self.os_creds, self.os_image_settings)) + self.image_creators[-1].create() # Create Network self.network_creator = OpenStackNetwork(self.os_creds, self.pub_net_config.network_settings) @@ -567,9 +616,11 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase): except Exception as e: logger.error('Unexpected exception cleaning network with message - ' + e.message) - if self.image_creator: + if self.image_creators: try: - self.image_creator.clean() + while self.image_creators: + self.image_creators[-1].clean() + self.image_creators.pop() except Exception as e: logger.error('Unexpected exception cleaning image with message - ' + e.message) @@ -592,7 +643,7 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase): router_name=self.pub_net_config.router_settings.name)]) inst_creator = OpenStackVmInstance( - self.os_creds, instance_settings, self.image_creator.image_settings, + self.os_creds, instance_settings, self.image_creators[-1].image_settings, keypair_settings=self.keypair_creator.keypair_settings) self.inst_creators.append(inst_creator) vm_inst = inst_creator.create() @@ -615,7 +666,7 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase): router_name=self.pub_net_config.router_settings.name)]) inst_creator = OpenStackVmInstance( - self.os_creds, instance_settings, self.image_creator.image_settings, + self.os_creds, instance_settings, self.image_creators[-1].image_settings, keypair_settings=self.keypair_creator.keypair_settings) self.inst_creators.append(inst_creator) vm_inst = inst_creator.create() @@ -640,7 +691,7 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase): router_name=self.pub_net_config.router_settings.name)]) inst_creator = OpenStackVmInstance( - self.os_creds, instance_settings, self.image_creator.image_settings, + self.os_creds, instance_settings, self.image_creators[-1].image_settings, keypair_settings=self.keypair_creator.keypair_settings) self.inst_creators.append(inst_creator) @@ -669,7 +720,7 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase): # router_name=self.pub_net_config.router_settings.name)]) # # inst_creator_1 = OpenStackVmInstance( - # self.os_creds, instance_settings_1, self.image_creator.image_settings, + # self.os_creds, instance_settings_1, self.image_creators[-1].image_settings, # keypair_settings=self.keypair_creator.keypair_settings) # self.inst_creators.append(inst_creator_1) # @@ -687,7 +738,7 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase): # router_name=self.pub_net_config.router_settings.name)]) # # inst_creator_1 = OpenStackVmInstance( - # self.os_creds, instance_settings_1, self.image_creator.image_settings, + # self.os_creds, instance_settings_1, self.image_creators[-1].image_settings, # keypair_settings=self.keypair_creator.keypair_settings) # self.inst_creators.append(inst_creator_1) # inst_creator_1.create(block=True) @@ -710,7 +761,7 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase): # port_settings=[port_settings_2]) # # inst_creator_2 = OpenStackVmInstance( - # self.os_creds, instance_settings_2, self.image_creator.image_settings) + # self.os_creds, instance_settings_2, self.image_creators[-1].image_settings) # self.inst_creators.append(inst_creator_2) # inst_creator_2.create(block=True) # @@ -728,7 +779,7 @@ class CreateInstanceSingleNetworkTests(OSIntegrationTestCase): # port_settings=[port_settings_3]) # # inst_creator_3 = OpenStackVmInstance( - # self.os_creds, instance_settings_3, self.image_creator.image_settings) + # self.os_creds, instance_settings_3, self.image_creators[-1].image_settings) # self.inst_creators.append(inst_creator_3) # inst_creator_3.create(block=True) # @@ -757,7 +808,7 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): self.floating_ip_name = guid + 'fip1' # Initialize for tearDown() - self.image_creator = None + self.image_creators = list() self.network_creator = None self.flavor_creator = None self.inst_creator = None @@ -769,8 +820,31 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): try: # Create Image - self.image_creator = OpenStackImage(self.os_creds, self.os_image_settings) - self.image_creator.create() + # Set any custom parameters sent from the app + if self.image_metadata: + if self.image_metadata['disk_url']: + self.os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + self.os_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id + + self.image_creators.append(OpenStackImage(self.os_creds, self.os_image_settings)) + self.image_creators[-1].create() # Create Network self.network_creator = OpenStackNetwork(self.os_creds, self.net_config.network_settings) @@ -807,9 +881,11 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): except Exception as e: logger.error('Unexpected exception cleaning network with message - ' + e.message) - if self.image_creator: + if self.image_creators: try: - self.image_creator.clean() + while self.image_creators: + self.image_creators[-1].clean() + self.image_creators.pop() except Exception as e: logger.error('Unexpected exception cleaning image with message - ' + e.message) @@ -827,7 +903,7 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) self.inst_creator.create() self.assertEquals(ip, self.inst_creator.get_port_ip( @@ -845,7 +921,7 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) with self.assertRaises(Exception): self.inst_creator.create() @@ -861,7 +937,7 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) self.inst_creator.create() self.assertEquals(mac_addr, self.inst_creator.get_port_mac(self.port_1_name)) @@ -878,7 +954,7 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[port_settings]) self.inst_creator = OpenStackVmInstance( - self.os_creds, instance_settings, self.image_creator.image_settings) + self.os_creds, instance_settings, self.image_creators[-1].image_settings) with self.assertRaises(Exception): self.inst_creator.create() @@ -896,7 +972,7 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) self.inst_creator.create() self.assertEquals(ip, self.inst_creator.get_port_ip( @@ -916,7 +992,7 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) self.inst_creator.create() port = self.inst_creator.get_port_by_name(port_settings.name) @@ -941,7 +1017,7 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) with self.assertRaises(Exception): self.inst_creator.create() @@ -961,7 +1037,7 @@ class CreateInstancePortManipulationTests(OSIntegrationTestCase): instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) with self.assertRaises(Exception): self.inst_creator.create() @@ -983,7 +1059,7 @@ class CreateInstanceOnComputeHost(OSIntegrationTestCase): self.port_base_name = guid + 'port' # Initialize for tearDown() - self.image_creator = None + self.image_creators = list() self.flavor_creator = None self.network_creator = None self.inst_creators = list() @@ -1005,8 +1081,31 @@ class CreateInstanceOnComputeHost(OSIntegrationTestCase): self.flavor_creator.create() # Create Image - self.image_creator = OpenStackImage(self.admin_os_creds, self.os_image_settings) - self.image_creator.create() + # Set any custom parameters sent from the app + if self.image_metadata: + if self.image_metadata['disk_url']: + self.os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + self.os_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id + + self.image_creators.append(OpenStackImage(self.os_creds, self.os_image_settings)) + self.image_creators[-1].create() except Exception as e: self.tearDown() @@ -1034,9 +1133,11 @@ class CreateInstanceOnComputeHost(OSIntegrationTestCase): except Exception as e: logger.error('Unexpected exception cleaning network with message - ' + e.message) - if self.image_creator: + if self.image_creators: try: - self.image_creator.clean() + while self.image_creators: + self.image_creators[-1].clean() + self.image_creators.pop() except Exception as e: logger.error('Unexpected exception cleaning image with message - ' + e.message) @@ -1062,7 +1163,7 @@ class CreateInstanceOnComputeHost(OSIntegrationTestCase): name=inst_name, flavor=self.flavor_creator.flavor_settings.name, availability_zone=zone, port_settings=[port_settings]) inst_creator = OpenStackVmInstance( - self.admin_os_creds, instance_settings, self.image_creator.image_settings) + self.admin_os_creds, instance_settings, self.image_creators[-1].image_settings) self.inst_creators.append(inst_creator) inst_creator.create() @@ -1092,7 +1193,7 @@ class CreateInstancePubPrivNetTests(OSIntegrationTestCase): super(self.__class__, self).__start__() # Initialize for tearDown() - self.image_creator = None + self.image_creators = list() self.network_creators = list() self.router_creators = list() self.flavor_creator = None @@ -1118,8 +1219,31 @@ class CreateInstancePubPrivNetTests(OSIntegrationTestCase): try: # Create Image - self.image_creator = OpenStackImage(self.os_creds, self.os_image_settings) - self.image_creator.create() + # Set any custom parameters sent from the app + if self.image_metadata: + if self.image_metadata['disk_url']: + self.os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + self.os_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id + + self.image_creators.append(OpenStackImage(self.os_creds, self.os_image_settings)) + self.image_creators[-1].create() # First network is public self.network_creators.append(OpenStackNetwork(self.os_creds, self.pub_net_config.network_settings)) @@ -1192,9 +1316,11 @@ class CreateInstancePubPrivNetTests(OSIntegrationTestCase): except Exception as e: logger.error('Unexpected exception cleaning network with message - ' + e.message) - if self.image_creator: + if self.image_creators: try: - self.image_creator.clean() + while self.image_creators: + self.image_creators[-1].clean() + self.image_creators.pop() except Exception as e: logger.error('Unexpected exception cleaning image with message - ' + e.message) @@ -1226,7 +1352,7 @@ class CreateInstancePubPrivNetTests(OSIntegrationTestCase): router_name=self.pub_net_config.router_settings.name)]) self.inst_creator = OpenStackVmInstance( - self.os_creds, instance_settings, self.image_creator.image_settings, + self.os_creds, instance_settings, self.image_creators[-1].image_settings, keypair_settings=self.keypair_creator.keypair_settings) vm_inst = self.inst_creator.create(block=True) @@ -1273,7 +1399,7 @@ class InstanceSecurityGroupTests(OSIntegrationTestCase): router_name=self.guid + '-pub-router', external_net=self.ext_net_name) # Initialize for tearDown() - self.image_creator = None + self.image_creators = list() self.flavor_creator = None self.network_creator = None self.router_creator = None @@ -1282,8 +1408,31 @@ class InstanceSecurityGroupTests(OSIntegrationTestCase): try: # Create Image - self.image_creator = OpenStackImage(self.os_creds, self.os_image_settings) - self.image_creator.create() + # Set any custom parameters sent from the app + if self.image_metadata: + if self.image_metadata['disk_url']: + self.os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + self.os_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=self.os_image_settings.name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + self.os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id + + self.image_creators.append(OpenStackImage(self.os_creds, self.os_image_settings)) + self.image_creators[-1].create() # Create Network self.network_creator = OpenStackNetwork(self.os_creds, net_config.network_settings) @@ -1330,9 +1479,11 @@ class InstanceSecurityGroupTests(OSIntegrationTestCase): except Exception as e: logger.error('Unexpected exception cleaning network with message - ' + e.message) - if self.image_creator: + if self.image_creators: try: - self.image_creator.clean() + while self.image_creators: + self.image_creators[-1].clean() + self.image_creators.pop() except Exception as e: logger.error('Unexpected exception cleaning image with message - ' + e.message) @@ -1345,7 +1496,7 @@ class InstanceSecurityGroupTests(OSIntegrationTestCase): # Create instance instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[self.port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) vm_inst = self.inst_creator.create(block=True) self.assertIsNotNone(vm_inst) @@ -1371,7 +1522,7 @@ class InstanceSecurityGroupTests(OSIntegrationTestCase): # Create instance instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[self.port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) vm_inst = self.inst_creator.create(block=True) self.assertIsNotNone(vm_inst) @@ -1405,7 +1556,7 @@ class InstanceSecurityGroupTests(OSIntegrationTestCase): instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, security_group_names=[sec_grp_settings.name], port_settings=[self.port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) vm_inst = self.inst_creator.create(block=True) self.assertIsNotNone(vm_inst) @@ -1431,7 +1582,7 @@ class InstanceSecurityGroupTests(OSIntegrationTestCase): # Create instance instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, port_settings=[self.port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) vm_inst = self.inst_creator.create(block=True) self.assertIsNotNone(vm_inst) @@ -1458,7 +1609,7 @@ class InstanceSecurityGroupTests(OSIntegrationTestCase): instance_settings = VmInstanceSettings( name=self.vm_inst_name, flavor=self.flavor_creator.flavor_settings.name, security_group_names=[sec_grp_settings.name], port_settings=[self.port_settings]) - self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creator.image_settings) + self.inst_creator = OpenStackVmInstance(self.os_creds, instance_settings, self.image_creators[-1].image_settings) vm_inst = self.inst_creator.create(block=True) self.assertIsNotNone(vm_inst) @@ -1542,10 +1693,17 @@ class CreateInstanceFromThreePartImage(OSIntegrationTestCase): try: # Create Images + # Set properties + properties = {} + if self.image_metadata and self.image_metadata['extra_properties']: + properties = self.image_metadata['extra_properties'] + # Create the kernel image kernel_image_settings = openstack_tests.cirros_url_image( name=self.image_name+'_kernel', url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-kernel') + if self.image_metadata and self.image_metadata['kernel_url']: + kernel_url = self.image_metadata['kernel_url'] self.image_creators.append(OpenStackImage(self.os_creds, kernel_image_settings)) kernel_image = self.image_creators[-1].create() @@ -1553,6 +1711,8 @@ class CreateInstanceFromThreePartImage(OSIntegrationTestCase): ramdisk_image_settings = openstack_tests.cirros_url_image( name=self.image_name+'_ramdisk', url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-initramfs') + if self.image_metadata and self.image_metadata['ramdisk_url']: + ramdisk_url = self.image_metadata['ramdisk_url'] self.image_creators.append(OpenStackImage(self.os_creds, ramdisk_image_settings)) ramdisk_image = self.image_creators[-1].create() self.assertIsNotNone(ramdisk_image) @@ -1561,7 +1721,8 @@ class CreateInstanceFromThreePartImage(OSIntegrationTestCase): os_image_settings = openstack_tests.cirros_url_image( name=self.image_name, url='http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img') - properties = dict() + if self.image_metadata and self.image_metadata['disk_url']: + umage_url = self.image_metadata['disk_url'] properties['kernel_id'] = kernel_image.id properties['ramdisk_id'] = ramdisk_image.id os_image_settings.extra_properties = properties diff --git a/snaps/provisioning/tests/ansible_utils_tests.py b/snaps/provisioning/tests/ansible_utils_tests.py index 552171f..92a56dc 100644 --- a/snaps/provisioning/tests/ansible_utils_tests.py +++ b/snaps/provisioning/tests/ansible_utils_tests.py @@ -62,13 +62,35 @@ class AnsibleProvisioningTests(OSIntegrationTestCase): self.flavor_creator = None self.router_creator = None self.network_creator = None - self.image_creator = None + self.image_creators = list() try: # Create Image os_image_settings = openstack_tests.ubuntu_url_image(name=guid + '-' + '-image') - self.image_creator = create_image.OpenStackImage(self.os_creds, os_image_settings) - self.image_creator.create() + if self.image_metadata: + if self.image_metadata['disk_url']: + os_image_settings.url = self.image_metadata['disk_url'] + if self.image_metadata['extra_properties']: + os_image_settings.extra_properties = self.image_metadata['extra_properties'] + + # If this is a 3-part image create the kernel and ramdisk images first + if self.image_metadata: + if self.image_metadata['kernel_url']: + kernel_image_settings = openstack_tests.cirros_url_image( + name=os_image_settings.name+'_kernel', url=self.image_metadata['kernel_url']) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, kernel_image_settings)) + kernel_image = self.image_creators[-1].create() + os_image_settings.extra_properties['kernel_id'] = kernel_image.id + + if self.image_metadata['ramdisk_url']: + ramdisk_image_settings = openstack_tests.cirros_url_image( + name=os_image_settings.name+'_ramdisk', url=self.image_metadata['ramdisk_url']) + self.image_creators.append(create_image.OpenStackImage(self.os_creds, ramdisk_image_settings)) + ramdisk_image = self.image_creators[-1].create() + os_image_settings.extra_properties['ramdisk_id'] = ramdisk_image.id + + self.image_creators.append(create_image.OpenStackImage(self.os_creds, os_image_settings)) + self.image_creators[-1].create() # First network is public self.pub_net_config = openstack_tests.get_pub_net_config( @@ -109,7 +131,7 @@ class AnsibleProvisioningTests(OSIntegrationTestCase): router_name=self.pub_net_config.router_settings.name)]) self.inst_creator = create_instance.OpenStackVmInstance( - self.os_creds, instance_settings, self.image_creator.image_settings, + self.os_creds, instance_settings, self.image_creators[-1].image_settings, keypair_settings=self.keypair_creator.keypair_settings) except Exception as e: self.tearDown() @@ -140,8 +162,10 @@ class AnsibleProvisioningTests(OSIntegrationTestCase): if self.network_creator: self.network_creator.clean() - if self.image_creator: - self.image_creator.clean() + if self.image_creators: + while self.image_creators: + self.image_creators[-1].clean() + self.image_creators.pop() if os.path.isfile(self.test_file_local_path): os.remove(self.test_file_local_path) diff --git a/snaps/test_suite_builder.py b/snaps/test_suite_builder.py index 2800d04..bf4bcdb 100644 --- a/snaps/test_suite_builder.py +++ b/snaps/test_suite_builder.py @@ -161,28 +161,36 @@ def add_openstack_integration_tests(suite, source_filename, ext_net_name, proxy_ # Creator Object tests suite.addTest(OSIntegrationTestCase.parameterize(CreateSecurityGroupTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateImageSuccessTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateImageNegativeTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateMultiPartImageTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateKeypairsTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateNetworkSuccessTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateRouterSuccessTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateRouterNegativeTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) # VM Instances suite.addTest(OSIntegrationTestCase.parameterize(SimpleHealthCheck, source_filename, ext_net_name, @@ -191,33 +199,41 @@ def add_openstack_integration_tests(suite, source_filename, ext_net_name, proxy_ log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateInstanceSimpleTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateInstancePortManipulationTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(InstanceSecurityGroupTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateInstanceOnComputeHost, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateInstanceFromThreePartImage, source_filename, ext_net_name, http_proxy_str=proxy_settings, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) if use_floating_ips: suite.addTest(OSIntegrationTestCase.parameterize(CreateInstanceSingleNetworkTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, ssh_proxy_cmd=ssh_proxy_cmd, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(CreateInstancePubPrivNetTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, ssh_proxy_cmd=ssh_proxy_cmd, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) suite.addTest(OSIntegrationTestCase.parameterize(AnsibleProvisioningTests, source_filename, ext_net_name, http_proxy_str=proxy_settings, ssh_proxy_cmd=ssh_proxy_cmd, use_keystone=use_keystone, - flavor_metadata=flavor_metadata, log_level=log_level)) + flavor_metadata=flavor_metadata, image_metadata=image_metadata, + log_level=log_level)) def add_openstack_staging_tests(suite, source_filename, ext_net_name, proxy_settings=None, log_level=logging.INFO): -- cgit 1.2.3-korg