aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/api/resources/v1/creds.py4
-rw-r--r--functest/api/resources/v1/tasks.py2
-rw-r--r--functest/api/resources/v1/testcases.py10
-rw-r--r--functest/opnfv_tests/openstack/refstack_client/refstack_client.py11
-rw-r--r--functest/opnfv_tests/openstack/refstack_client/tempest_conf.py1
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py26
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py11
-rw-r--r--functest/tests/unit/openstack/refstack_client/test_refstack_client.py8
-rw-r--r--functest/tests/unit/openstack/tempest/test_conf_utils.py5
9 files changed, 42 insertions, 36 deletions
diff --git a/functest/api/resources/v1/creds.py b/functest/api/resources/v1/creds.py
index fefbbaa9..25c0fd24 100644
--- a/functest/api/resources/v1/creds.py
+++ b/functest/api/resources/v1/creds.py
@@ -39,7 +39,7 @@ class V1Creds(ApiResource):
endpoint='{0}/credentials'.format(ENDPOINT_CREDS))
def get(self): # pylint: disable=no-self-use
""" Get credentials """
- run_tests.Runner.source_envfile(CONST.__getattribute__('env_file'))
+ run_tests.Runner.source_envfile(getattr(CONST, 'env_file'))
credentials_show = OpenStack.show_credentials()
return jsonify(credentials_show)
@@ -65,7 +65,7 @@ class V1Creds(ApiResource):
lines = ['export {}={}\n'.format(k, v) for k, v in openrc_vars.items()]
- rc_file = CONST.__getattribute__('env_file')
+ rc_file = getattr(CONST, 'env_file')
with open(rc_file, 'w') as creds_file:
creds_file.writelines(lines)
diff --git a/functest/api/resources/v1/tasks.py b/functest/api/resources/v1/tasks.py
index 6bf625a8..5af8a678 100644
--- a/functest/api/resources/v1/tasks.py
+++ b/functest/api/resources/v1/tasks.py
@@ -85,7 +85,7 @@ class V1TaskLog(ApiResource):
except ValueError:
return api_utils.result_handler(status=1, data='No such task id')
- task_log_dir = CONST.__getattribute__('dir_results')
+ task_log_dir = getattr(CONST, 'dir_results')
# pylint: disable=maybe-no-member
index = int(self._get_args().get('index', 0))
diff --git a/functest/api/resources/v1/testcases.py b/functest/api/resources/v1/testcases.py
index 01571548..bc21c6fa 100644
--- a/functest/api/resources/v1/testcases.py
+++ b/functest/api/resources/v1/testcases.py
@@ -127,10 +127,10 @@ class V1Testcase(ApiResource):
result = 'FAIL'
env_info = {
- 'installer': CONST.__getattribute__('INSTALLER_TYPE'),
- 'scenario': CONST.__getattribute__('DEPLOY_SCENARIO'),
- 'build_tag': CONST.__getattribute__('BUILD_TAG'),
- 'ci_loop': CONST.__getattribute__('CI_LOOP')
+ 'installer': os.environ.get('INSTALLER_TYPE', None),
+ 'scenario': os.environ.get('DEPLOY_SCENARIO', None),
+ 'build_tag': os.environ.get('BUILD_TAG', None),
+ 'ci_loop': os.environ.get('CI_LOOP', 'daily')
}
result = {
'task_id': args.get('task_id'),
@@ -146,7 +146,7 @@ class V1Testcase(ApiResource):
config = ConfigParser.RawConfigParser()
config.read(
pkg_resources.resource_filename('functest', 'ci/logging.ini'))
- log_path = os.path.join(CONST.__getattribute__('dir_results'),
+ log_path = os.path.join(getattr(CONST, 'dir_results'),
'{}.log'.format(task_id))
config.set('handler_file', 'args', '("{}",)'.format(log_path))
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index 4e8f58b6..cb2ba220 100644
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -26,7 +26,6 @@ from functest.energy import energy
from functest.opnfv_tests.openstack.refstack_client.tempest_conf \
import TempestConf
from functest.opnfv_tests.openstack.tempest import conf_utils
-from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
__author__ = ("Matthew Li <matthew.lijun@huawei.com>,"
@@ -58,8 +57,8 @@ class RefstackClient(testcase.TestCase):
'functest', 'opnfv_tests/openstack/refstack_client/defcore.txt')
self.testlist = None
self.insecure = ''
- if ('https' in CONST.__getattribute__('OS_AUTH_URL') and
- CONST.__getattribute__('OS_INSECURE').lower() == 'true'):
+ if ('https' in os.environ['OS_AUTH_URL'] and
+ os.getenv('OS_INSECURE', '').lower() == 'true'):
self.insecure = '-k'
def generate_conf(self):
@@ -89,9 +88,9 @@ class RefstackClient(testcase.TestCase):
f_env.write(
("Refstack environment:\n"
" SUT: {}\n Scenario: {}\n Node: {}\n Date: {}\n")
- .format(CONST.__getattribute__('INSTALLER_TYPE'),
- CONST.__getattribute__('DEPLOY_SCENARIO'),
- CONST.__getattribute__('NODE_NAME'),
+ .format(os.getenv('INSTALLER_TYPE', None),
+ os.getenv('DEPLOY_SCENARIO', None),
+ os.getenv('NODE_NAME', 'unknown_pod'),
time.strftime("%a %b %d %H:%M:%S %Z %Y")))
with open(os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
index 44d0a18b..73a2685c 100644
--- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
+++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
@@ -38,6 +38,7 @@ class TempestConf(object):
use_custom_flavors=True)
conf_utils.configure_tempest_defcore(
self.deployment_dir,
+ network_name=resources.get("network_name"),
image_id=resources.get("image_id"),
flavor_id=resources.get("flavor_id"),
image_id_alt=resources.get("image_id_alt"),
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index 6b35b96e..efcbe7fd 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -184,25 +184,27 @@ def backup_tempest_config(conf_file):
os.path.join(TEMPEST_RESULTS_DIR, 'tempest.conf'))
-def configure_tempest(deployment_dir, image_id=None, flavor_id=None,
- compute_cnt=None):
+def configure_tempest(deployment_dir, network_name=None, image_id=None,
+ flavor_id=None, compute_cnt=None):
"""
Calls rally verify and updates the generated tempest.conf with
given parameters
"""
conf_file = configure_verifier(deployment_dir)
- configure_tempest_update_params(conf_file, image_id, flavor_id,
- compute_cnt)
+ configure_tempest_update_params(conf_file, network_name, image_id,
+ flavor_id, compute_cnt)
-def configure_tempest_defcore(deployment_dir, image_id, flavor_id,
- image_id_alt, flavor_id_alt, tenant_id):
+def configure_tempest_defcore(deployment_dir, network_name, image_id,
+ flavor_id, image_id_alt, flavor_id_alt,
+ tenant_id):
# pylint: disable=too-many-arguments
"""
Add/update needed parameters into tempest.conf file
"""
conf_file = configure_verifier(deployment_dir)
- configure_tempest_update_params(conf_file, image_id, flavor_id)
+ configure_tempest_update_params(conf_file, network_name, image_id,
+ flavor_id)
LOGGER.debug("Updating selected tempest.conf parameters for defcore...")
config = ConfigParser.RawConfigParser()
@@ -266,18 +268,16 @@ def update_tempest_conf_file(conf_file, config):
config.write(config_file)
-def configure_tempest_update_params(tempest_conf_file, image_id=None,
- flavor_id=None, compute_cnt=1):
+def configure_tempest_update_params(tempest_conf_file, network_name=None,
+ image_id=None, flavor_id=None,
+ compute_cnt=1):
"""
Add/update needed parameters into tempest.conf file
"""
LOGGER.debug("Updating selected tempest.conf parameters...")
config = ConfigParser.RawConfigParser()
config.read(tempest_conf_file)
- config.set(
- 'compute',
- 'fixed_network_name',
- CONST.__getattribute__('tempest_private_net_name'))
+ config.set('compute', 'fixed_network_name', network_name)
config.set('compute', 'volume_device_name',
CONST.__getattribute__('tempest_volume_device_name'))
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index c5ad4ecb..01caf4ff 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -257,6 +257,7 @@ class TempestCommon(testcase.TestCase):
self.resources.os_creds)
conf_utils.configure_tempest(
self.deployment_dir,
+ network_name=resources.get("network_name"),
image_id=resources.get("image_id"),
flavor_id=resources.get("flavor_id"),
compute_cnt=compute_cnt)
@@ -380,10 +381,12 @@ class TempestResourcesManager(object):
tempest_segmentation_id = CONST.__getattribute__(
'tempest_segmentation_id')
+ tempest_net_name = CONST.__getattribute__(
+ 'tempest_private_net_name') + self.guid
+
network_creator = deploy_utils.create_network(
self.os_creds, NetworkConfig(
- name=CONST.__getattribute__(
- 'tempest_private_net_name') + self.guid,
+ name=tempest_net_name,
project_name=project_name,
network_type=tempest_network_type,
physical_network=tempest_physical_network,
@@ -397,6 +400,7 @@ class TempestResourcesManager(object):
if network_creator is None or network_creator.get_network() is None:
raise Exception("Failed to create private network")
self.creators.append(network_creator)
+ return tempest_net_name
def _create_image(self, name):
"""Create image for tests"""
@@ -433,6 +437,7 @@ class TempestResourcesManager(object):
create_project=False):
"""Create resources for Tempest test suite."""
result = {
+ 'tempest_net_name': None,
'image_id': None,
'image_id_alt': None,
'flavor_id': None,
@@ -449,7 +454,7 @@ class TempestResourcesManager(object):
result['tenant_id'] = result['project_id'] # for compatibility
LOGGER.debug("Creating private network for Tempest suite")
- self._create_network(project_name)
+ result['tempest_net_name'] = self._create_network(project_name)
LOGGER.debug("Creating image for Tempest suite")
image_name = CONST.__getattribute__('openstack_image_name') + self.guid
diff --git a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
index a7a914cb..e2e7dceb 100644
--- a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
+++ b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
@@ -10,6 +10,7 @@
# pylint: disable=missing-docstring
import logging
+import os
import unittest
import mock
@@ -18,7 +19,6 @@ import pkg_resources
from functest.core import testcase
from functest.opnfv_tests.openstack.refstack_client.refstack_client import \
RefstackClient, RefstackClientParser
-from functest.utils.constants import CONST
from snaps.openstack.os_credentials import OSCreds
@@ -39,8 +39,8 @@ class OSRefstackClientTesting(unittest.TestCase):
def setUp(self):
self.default_args = {'config': self._config,
'testlist': self._testlist}
- CONST.__setattr__('OS_AUTH_URL', 'https://ip:5000/v3')
- CONST.__setattr__('OS_INSECURE', 'true')
+ os.environ['OS_AUTH_URL'] = 'https://ip:5000/v3'
+ os.environ['OS_INSECURE'] = 'true'
self.case_name = 'refstack_defcore'
self.result = 0
self.os_creds = OSCreds(
@@ -70,7 +70,7 @@ class OSRefstackClientTesting(unittest.TestCase):
m_cmd.assert_any_call(cmd)
def test_run_defcore(self):
- CONST.__setattr__('OS_AUTH_URL', 'http://ip:5000/v3')
+ os.environ['OS_AUTH_URL'] = 'http://ip:5000/v3'
insecure = ''
config = 'tempest.conf'
testlist = 'testlist'
diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py
index 5fed742c..323a1ee0 100644
--- a/functest/tests/unit/openstack/tempest/test_conf_utils.py
+++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py
@@ -259,8 +259,9 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
mock.patch('functest.opnfv_tests.openstack.tempest.'
'conf_utils.shutil.copyfile'):
conf_utils.configure_tempest_defcore(
- 'test_dep_dir', 'test_image_id', 'test_flavor_id',
- 'test_image_alt_id', 'test_flavor_alt_id', 'test_tenant_id')
+ 'test_dep_dir', 'test_network_name', 'test_image_id',
+ 'test_flavor_id', 'test_image_alt_id', 'test_flavor_alt_id',
+ 'test_tenant_id')
mset.assert_any_call('compute', 'image_ref', 'test_image_id')
mset.assert_any_call('compute', 'image_ref_alt',
'test_image_alt_id')