aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2017-08-10 02:37:56 +0000
committerLinda Wang <wangwulin@huawei.com>2017-08-10 04:01:10 +0000
commite18c6f652f2874fe1df2ed61972560b6e053d500 (patch)
tree46e9a5a3cbe07a8b41a3f843570a19b842de7ee8
parentcd4716eb5fa3a12e256fba8faa75780b7398ff68 (diff)
Add/Update tempest.conf via a specific file
Provides a convenient way to configure all params which users required. JIRA: FUNCTEST-860 Change-Id: Iadfb704285f94530e1023ee780138f22dd672d33 Signed-off-by: Linda Wang <wangwulin@huawei.com>
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py17
-rw-r--r--functest/opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml13
-rw-r--r--functest/tests/unit/openstack/tempest/test_conf_utils.py5
-rw-r--r--functest/tests/unit/vnf/ims/test_cloudify_ims.py9
-rw-r--r--functest/tests/unit/vnf/ims/test_orchestra_ims.py2
5 files changed, 42 insertions, 4 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index d494db5eb..2313ec04b 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -15,6 +15,8 @@ import re
import shutil
import subprocess
+import yaml
+
from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
@@ -38,6 +40,8 @@ TEMPEST_RAW_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_raw_list.txt')
TEMPEST_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_list.txt')
REFSTACK_RESULTS_DIR = os.path.join(CONST.__getattribute__('dir_results'),
'refstack')
+TEMPEST_CONF_YAML = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml')
CI_INSTALLER_TYPE = CONST.__getattribute__('INSTALLER_TYPE')
CI_INSTALLER_IP = CONST.__getattribute__('INSTALLER_IP')
@@ -328,6 +332,19 @@ def configure_tempest_update_params(tempest_conf_file,
config.set(service, 'endpoint_type',
CONST.__getattribute__('OS_ENDPOINT_TYPE'))
+ logger.debug('Add/Update required params defined in tempest_conf.yaml '
+ 'into tempest.conf file')
+ with open(TEMPEST_CONF_YAML) as f:
+ conf_yaml = yaml.safe_load(f)
+ if not conf_yaml:
+ sections = config.sections()
+ for section in conf_yaml:
+ if section not in sections:
+ config.add_section(section)
+ sub_conf = conf_yaml.get(section)
+ for key, value in sub_conf.items():
+ config.set(section, key, value)
+
with open(tempest_conf_file, 'wb') as config_file:
config.write(config_file)
diff --git a/functest/opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml b/functest/opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml
new file mode 100644
index 000000000..b47a9736a
--- /dev/null
+++ b/functest/opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml
@@ -0,0 +1,13 @@
+# This is an empty configuration file to be filled up with the desired options
+# to generate a custom tempest.conf
+# Examples:
+# network-feature-enabled:
+# port_security: True
+
+# volume-feature-enabled:
+# api_v1: False
+
+# validation:
+# image_ssh_user: root
+# ssh_timeout: 300
+
diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py
index 379049653..79ef99150 100644
--- a/functest/tests/unit/openstack/tempest/test_conf_utils.py
+++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py
@@ -261,8 +261,11 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
'write') as mwrite, \
mock.patch('__builtin__.open', mock.mock_open()), \
mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.backup_tempest_config'):
+ 'conf_utils.backup_tempest_config'), \
+ mock.patch('functest.utils.functest_utils.yaml.safe_load') \
+ as mock_yaml:
CONST.__setattr__('OS_ENDPOINT_TYPE', None)
+ mock_yaml.return_value = mock.Mock()
conf_utils.\
configure_tempest_update_params('test_conf_file',
IMAGE_ID=image_id,
diff --git a/functest/tests/unit/vnf/ims/test_cloudify_ims.py b/functest/tests/unit/vnf/ims/test_cloudify_ims.py
index 537c5146b..f0483c69f 100644
--- a/functest/tests/unit/vnf/ims/test_cloudify_ims.py
+++ b/functest/tests/unit/vnf/ims/test_cloudify_ims.py
@@ -13,6 +13,8 @@ import mock
from functest.core import vnf
from functest.opnfv_tests.vnf.ims import cloudify_ims
+from snaps.openstack.os_credentials import OSCreds
+
class CloudifyImsTesting(unittest.TestCase):
@@ -79,8 +81,11 @@ class CloudifyImsTesting(unittest.TestCase):
@mock.patch('snaps.openstack.create_image.OpenStackImage.create')
def test_prepare_bad_auth_url(self, *args):
with self.assertRaises(Exception):
- self.ims_vnf.prepare()
- args[0].assert_not_called()
+ self.ims_vnf.image_creator(
+ OSCreds(username='user', password='pass', auth_url='url',
+ project_name='project', identity_api_version=3),
+ mock.Mock())
+ args[0].assert_not_called()
def test_prepare_missing_param(self):
with self.assertRaises(vnf.VnfPreparationException):
diff --git a/functest/tests/unit/vnf/ims/test_orchestra_ims.py b/functest/tests/unit/vnf/ims/test_orchestra_ims.py
index 219997301..5a1efc7fd 100644
--- a/functest/tests/unit/vnf/ims/test_orchestra_ims.py
+++ b/functest/tests/unit/vnf/ims/test_orchestra_ims.py
@@ -154,7 +154,7 @@ class OrchestraImsTesting(unittest.TestCase):
"""Testing prepare function with bad auth url"""
with self.assertRaises(Exception):
self.ims_vnf.prepare()
- args[0].assert_not_called()
+ args[0].assert_not_called()
def test_prepare_missing_param(self):
"""Testing prepare function with missing param"""