diff options
Diffstat (limited to 'functest/opnfv_tests/openstack/rally/rally.py')
-rw-r--r-- | functest/opnfv_tests/openstack/rally/rally.py | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index 5aba3882..e92639b2 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -29,6 +29,7 @@ from functest.energy import energy from functest.opnfv_tests.openstack.snaps import snaps_utils from functest.utils.constants import CONST +from snaps.openstack.create_flavor import FlavorSettings, OpenStackFlavor from snaps.openstack.create_image import ImageSettings from snaps.openstack.create_network import NetworkSettings, SubnetSettings from snaps.openstack.create_router import RouterSettings @@ -54,7 +55,11 @@ class RallyBase(testcase.TestCase): if hasattr(CONST, 'openstack_extra_properties'): GLANCE_IMAGE_EXTRA_PROPERTIES = CONST.__getattribute__( 'openstack_extra_properties') - FLAVOR_NAME = "m1.tiny" + FLAVOR_NAME = CONST.__getattribute__('rally_flavor_name') + FLAVOR_ALT_NAME = CONST.__getattribute__('rally_flavor_alt_name') + FLAVOR_EXTRA_SPECS = None + if hasattr(CONST, 'flavor_extra_specs'): + FLAVOR_EXTRA_SPECS = CONST.__getattribute__('flavor_extra_specs') RALLY_DIR = pkg_resources.resource_filename( 'functest', 'opnfv_tests/openstack/rally') @@ -102,8 +107,11 @@ class RallyBase(testcase.TestCase): self.mode = '' self.summary = [] self.scenario_dir = '' + self.image_name = None self.ext_net_name = None self.priv_net_id = None + self.flavor_name = None + self.flavor_alt_name = None self.smoke = None self.test_name = None self.start_time = None @@ -112,8 +120,9 @@ class RallyBase(testcase.TestCase): def _build_task_args(self, test_file_name): task_args = {'service_list': [test_file_name]} - task_args['image_name'] = self.GLANCE_IMAGE_NAME - task_args['flavor_name'] = self.FLAVOR_NAME + task_args['image_name'] = self.image_name + task_args['flavor_name'] = self.flavor_name + task_args['flavor_alt_name'] = self.flavor_alt_name task_args['glance_image_location'] = self.GLANCE_IMAGE_PATH task_args['glance_image_format'] = self.GLANCE_IMAGE_FORMAT task_args['tmpl_dir'] = self.TEMPLATE_DIR @@ -467,24 +476,25 @@ class RallyBase(testcase.TestCase): if self.test_name not in self.TESTS: raise Exception("Test name '%s' is invalid" % self.test_name) - image_name = self.GLANCE_IMAGE_NAME + self.guid network_name = self.RALLY_PRIVATE_NET_NAME + self.guid subnet_name = self.RALLY_PRIVATE_SUBNET_NAME + self.guid router_name = self.RALLY_ROUTER_NAME + self.guid + self.image_name = self.GLANCE_IMAGE_NAME + self.guid + self.flavor_name = self.FLAVOR_NAME + self.guid + self.flavor_alt_name = self.FLAVOR_ALT_NAME + self.guid self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds) - LOGGER.debug('Getting or creating image...') + LOGGER.debug("Creating image '%s'...", self.image_name) image_creator = deploy_utils.create_image( self.os_creds, ImageSettings( - name=image_name, + name=self.image_name, image_file=self.GLANCE_IMAGE_PATH, img_format=self.GLANCE_IMAGE_FORMAT, image_user=self.GLANCE_IMAGE_USERNAME, public=True, extra_properties=self.GLANCE_IMAGE_EXTRA_PROPERTIES)) if image_creator is None: - raise Exception("Failed to get or create image '%s'" % - image_name) + raise Exception("Failed to create image") self.creators.append(image_creator) LOGGER.debug("Creating network '%s'...", network_name) @@ -511,6 +521,24 @@ class RallyBase(testcase.TestCase): raise Exception("Failed to create router") self.creators.append(router_creator) + LOGGER.debug("Creating flavor '%s'...", self.flavor_name) + flavor_creator = OpenStackFlavor( + self.os_creds, FlavorSettings( + name=self.flavor_name, ram=512, disk=1, vcpus=1, + metadata=self.FLAVOR_EXTRA_SPECS)) + if flavor_creator is None or flavor_creator.create() is None: + raise Exception("Failed to create flavor") + self.creators.append(flavor_creator) + + LOGGER.debug("Creating flavor '%s'...", self.flavor_alt_name) + flavor_alt_creator = OpenStackFlavor( + self.os_creds, FlavorSettings( + name=self.flavor_alt_name, ram=1024, disk=1, vcpus=1, + metadata=self.FLAVOR_EXTRA_SPECS)) + if flavor_alt_creator is None or flavor_alt_creator.create() is None: + raise Exception("Failed to create flavor") + self.creators.append(flavor_alt_creator) + def _run_tests(self): if self.test_name == 'all': for test in self.TESTS: |