Create 2 images and flavors for tempest tests 13/53613/8
authorLinda Wang <wangwulin@huawei.com>
Tue, 13 Mar 2018 01:36:40 +0000 (01:36 +0000)
committerLinda Wang <wangwulin@huawei.com>
Thu, 15 Mar 2018 03:50:30 +0000 (03:50 +0000)
Also
1. remove the obsolete function: generate_test_accounts_file
2. Use patch mechanism to get config

Change-Id: I455ac37de71519bcaf9a51e5f1de1b9bc83b9ba6
Signed-off-by: Linda Wang <wangwulin@huawei.com>
functest/ci/config_patch.yaml
functest/opnfv_tests/openstack/rally/rally.py
functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
functest/opnfv_tests/openstack/tempest/conf_utils.py
functest/opnfv_tests/openstack/tempest/tempest.py
functest/opnfv_tests/openstack/vping/vping_base.py
functest/tests/unit/openstack/tempest/test_conf_utils.py

index 32b6705..dfd441b 100644 (file)
@@ -10,11 +10,11 @@ fdio:
     general:
         flavor_extra_specs: {'hw:mem_page_size':'large'}
         image_properties: {'hw_mem_page_size':'large'}
-    tempest:
-        use_custom_flavors: 'True'
+        openstack:
+            flavor_ram: 1024
 ovs:
     general:
         flavor_extra_specs: {'hw:mem_page_size':'large'}
         image_properties: {'hw_mem_page_size':'large'}
-    tempest:
-        use_custom_flavors: 'True'
+        openstack:
+            flavor_ram: 1024
index 1502d58..5b6a76f 100644 (file)
@@ -53,7 +53,7 @@ class RallyBase(testcase.TestCase):
     GLANCE_IMAGE_FORMAT = getattr(config.CONF, 'openstack_image_disk_format')
     GLANCE_IMAGE_USERNAME = getattr(config.CONF, 'openstack_image_username')
     GLANCE_IMAGE_EXTRA_PROPERTIES = getattr(
-        config.CONF, 'openstack_extra_properties', {})
+        config.CONF, 'image_properties', {})
     FLAVOR_NAME = getattr(config.CONF, 'rally_flavor_name')
     FLAVOR_ALT_NAME = getattr(config.CONF, 'rally_flavor_alt_name')
     FLAVOR_RAM = 512
index c7329f3..7b111ed 100644 (file)
 
 import logging
 
-from snaps.openstack import create_flavor
 from xtesting.core import unit
 
 from functest.opnfv_tests.openstack.snaps import snaps_utils
 from functest.utils import config
-from functest.utils import env
 
 
 class SnapsTestRunner(unit.Suite):
@@ -45,12 +43,8 @@ class SnapsTestRunner(unit.Suite):
             getattr(config.CONF, 'snaps_use_floating_ips') == 'True')
         self.use_keystone = (
             getattr(config.CONF, 'snaps_use_keystone') == 'True')
-        scenario = env.get('DEPLOY_SCENARIO')
-
-        self.flavor_metadata = None
-        if 'ovs' in scenario or 'fdio' in scenario:
-            self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
 
+        self.flavor_metadata = getattr(config.CONF, 'flavor_extra_specs', None)
         self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)
 
         self.image_metadata = None
index 8832a48..d6b1eb4 100644 (file)
@@ -39,9 +39,6 @@ TEMPEST_BLACKLIST = pkg_resources.resource_filename(
     'functest', 'opnfv_tests/openstack/tempest/custom_tests/blacklist.txt')
 TEMPEST_CONF_YAML = pkg_resources.resource_filename(
     'functest', 'opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml')
-TEST_ACCOUNTS_FILE = pkg_resources.resource_filename(
-    'functest',
-    'opnfv_tests/openstack/tempest/custom_tests/test_accounts.yaml')
 
 CI_INSTALLER_TYPE = env.get('INSTALLER_TYPE')
 
@@ -173,26 +170,6 @@ def backup_tempest_config(conf_file, res_dir):
                     os.path.join(res_dir, 'tempest.conf'))
 
 
-def generate_test_accounts_file(tenant_id):
-    """
-    Add needed tenant and user params into test_accounts.yaml
-    """
-
-    LOGGER.debug("Add needed params into test_accounts.yaml...")
-    accounts_list = [
-        {
-            'tenant_name': getattr(
-                config.CONF, 'tempest_identity_tenant_name'),
-            'tenant_id': str(tenant_id),
-            'username': getattr(config.CONF, 'tempest_identity_user_name'),
-            'password': getattr(config.CONF, 'tempest_identity_user_password')
-        }
-    ]
-
-    with open(TEST_ACCOUNTS_FILE, "w") as tfile:
-        yaml.dump(accounts_list, tfile, default_flow_style=False)
-
-
 def update_tempest_conf_file(conf_file, rconfig):
     """Update defined paramters into tempest config file"""
     with open(TEMPEST_CONF_YAML) as yfile:
index acab29d..8d47ddb 100644 (file)
@@ -24,7 +24,6 @@ from snaps.config.flavor import FlavorConfig
 from snaps.config.network import NetworkConfig, SubnetConfig
 from snaps.config.project import ProjectConfig
 from snaps.config.user import UserConfig
-from snaps.openstack import create_flavor
 from snaps.openstack.create_flavor import OpenStackFlavor
 from snaps.openstack.tests import openstack_tests
 from snaps.openstack.utils import deploy_utils
@@ -435,10 +434,7 @@ class TempestResourcesManager(object):
 
     def _create_flavor(self, name):
         """Create flavor for tests."""
-        scenario = env.get('DEPLOY_SCENARIO')
-        flavor_metadata = None
-        if 'ovs' in scenario or 'fdio' in scenario:
-            flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
+        flavor_metadata = getattr(config.CONF, 'flavor_extra_specs', None)
         flavor_creator = OpenStackFlavor(
             self.os_creds, FlavorConfig(
                 name=name,
@@ -452,8 +448,7 @@ class TempestResourcesManager(object):
         self.creators.append(flavor_creator)
         return flavor.id
 
-    def create(self, use_custom_images=False, use_custom_flavors=False,
-               create_project=False):
+    def create(self, create_project=False):
         """Create resources for Tempest test suite."""
         result = {
             'tempest_net_name': None,
@@ -475,30 +470,20 @@ class TempestResourcesManager(object):
         LOGGER.debug("Creating private network for Tempest suite")
         result['tempest_net_name'] = self._create_network(project_name)
 
-        LOGGER.debug("Creating image for Tempest suite")
+        LOGGER.debug("Creating two images for Tempest suite")
         image_name = getattr(config.CONF, 'openstack_image_name') + self.guid
         result['image_id'] = self._create_image(image_name)
+        image_name = getattr(
+            config.CONF, 'openstack_image_name_alt') + self.guid
+        result['image_id_alt'] = self._create_image(image_name)
 
-        if use_custom_images:
-            LOGGER.debug("Creating 2nd image for Tempest suite")
-            image_name = getattr(
-                config.CONF, 'openstack_image_name_alt') + self.guid
-            result['image_id_alt'] = self._create_image(image_name)
-
-        if (getattr(config.CONF, 'tempest_use_custom_flavors') == 'True' or
-                use_custom_flavors):
-            LOGGER.info("Creating flavor for Tempest suite")
-            name = getattr(config.CONF, 'openstack_flavor_name') + self.guid
-            result['flavor_id'] = self._create_flavor(name)
-
-        if use_custom_flavors:
-            LOGGER.info("Creating 2nd flavor for Tempest suite")
-            scenario = env.get('DEPLOY_SCENARIO')
-            if 'ovs' in scenario or 'fdio' in scenario:
-                setattr(config.CONF, 'openstack_flavor_ram', 1024)
-            name = getattr(
-                config.CONF, 'openstack_flavor_name_alt') + self.guid
-            result['flavor_id_alt'] = self._create_flavor(name)
+        LOGGER.info("Creating two flavors for Tempest suite")
+        name = getattr(config.CONF, 'openstack_flavor_name') + self.guid
+        result['flavor_id'] = self._create_flavor(name)
+
+        name = getattr(
+            config.CONF, 'openstack_flavor_name_alt') + self.guid
+        result['flavor_id_alt'] = self._create_flavor(name)
 
         return result
 
index edc7848..152f69d 100644 (file)
@@ -18,7 +18,6 @@ import uuid
 from snaps.config.flavor import FlavorConfig
 from snaps.config.network import NetworkConfig, SubnetConfig
 from snaps.config.router import RouterConfig
-from snaps.openstack import create_flavor
 from snaps.openstack.create_flavor import OpenStackFlavor
 from snaps.openstack.tests import openstack_tests
 from snaps.openstack.utils import deploy_utils
@@ -144,12 +143,9 @@ class VPingBase(testcase.TestCase):
 
         self.logger.info(
             "Creating flavor with name: '%s'", self.flavor_name)
-        scenario = env.get('DEPLOY_SCENARIO')
-        flavor_metadata = None
-        flavor_ram = 512
-        if 'ovs' in scenario or 'fdio' in scenario:
-            flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
-            flavor_ram = 1024
+        flavor_ram = getattr(config.CONF, 'openstack_flavor_ram')
+        flavor_metadata = getattr(config.CONF, 'flavor_extra_specs', None)
+
         flavor_creator = OpenStackFlavor(
             self.os_creds,
             FlavorConfig(name=self.flavor_name, ram=flavor_ram, disk=1,
index fa53b57..ee22f7f 100644 (file)
@@ -76,19 +76,11 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
         # pylint: disable=unused-argument
         tempest_resources = tempest.TempestResourcesManager(
             os_creds=self.os_creds)
-
-        setattr(config.CONF, 'tempest_use_custom_flavors', 'True')
         with self.assertRaises(Exception) as context:
             tempest_resources.create()
         msg = 'Failed to create flavor'
         self.assertTrue(msg in context.exception, msg=str(context.exception))
 
-        setattr(config.CONF, 'tempest_use_custom_flavors', 'False')
-        with self.assertRaises(Exception) as context:
-            tempest_resources.create(use_custom_flavors=True)
-        msg = 'Failed to create flavor'
-        self.assertTrue(msg in context.exception, msg=str(context.exception))
-
     @staticmethod
     @mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils'
                 '.LOGGER.info')
@@ -233,13 +225,6 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
                 'test_conf_file', res_dir='test_dir')
             self.assertTrue(mock_copyfile.called)
 
-    def test_gen_test_accounts_file_def(self):
-        with mock.patch("__builtin__.open", mock.mock_open()), \
-            mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.'
-                       'yaml.dump') as mock_dump:
-            conf_utils.generate_test_accounts_file('test_tenant_id')
-            self.assertTrue(mock_dump.called)
-
     def _test_missing_param(self, params, image_id, flavor_id):
         with mock.patch('functest.opnfv_tests.openstack.tempest.'
                         'conf_utils.ConfigParser.RawConfigParser.'