aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2017-11-30 14:11:52 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-11-30 14:11:52 +0000
commit4047bc91468525ca4f46c63d74dbe9fc9521e49f (patch)
tree12fadce8948e109188a971c9a9403ba1fd03b7ad
parentc38d87b9a57466a5663395926a576a87623eb2f4 (diff)
parent8b21d5190469230644506ec561762d452a46b933 (diff)
Merge "Stop updating test_db_url in config file by env var"
-rw-r--r--functest/ci/run_tests.py13
-rw-r--r--functest/tests/unit/ci/test_run_tests.py34
-rw-r--r--functest/utils/functest_utils.py5
3 files changed, 6 insertions, 46 deletions
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index 03d62d992..d476bded8 100644
--- a/functest/ci/run_tests.py
+++ b/functest/ci/run_tests.py
@@ -93,9 +93,6 @@ class Runner(object):
if pod_arch and pod_arch in arch_filter:
Runner.patch_file(CONFIG_AARCH64_PATCH_PATH)
- if "TEST_DB_URL" in os.environ:
- Runner.update_db_url()
-
@staticmethod
def patch_file(patch_file_path):
logger.debug('Updating file: %s', patch_file_path)
@@ -115,16 +112,6 @@ class Runner(object):
f.write(yaml.dump(new_functest_yaml, default_style='"'))
@staticmethod
- def update_db_url():
- with open(CONFIG_FUNCTEST_PATH) as f:
- functest_yaml = yaml.safe_load(f)
-
- with open(CONFIG_FUNCTEST_PATH, "w") as f:
- functest_yaml["results"]["test_db_url"] = os.environ.get(
- 'TEST_DB_URL')
- f.write(yaml.dump(functest_yaml, default_style='"'))
-
- @staticmethod
def source_rc_file():
rc_file = CONST.__getattribute__('openstack_creds')
if not os.path.isfile(rc_file):
diff --git a/functest/tests/unit/ci/test_run_tests.py b/functest/tests/unit/ci/test_run_tests.py
index fc689452d..b5af18c97 100644
--- a/functest/tests/unit/ci/test_run_tests.py
+++ b/functest/tests/unit/ci/test_run_tests.py
@@ -7,7 +7,6 @@
import logging
import unittest
-import os
import mock
@@ -72,19 +71,9 @@ class RunTestsTesting(unittest.TestCase):
'openstack': {'image_name': 'test_image_name_3'}}}}
@mock.patch('functest.ci.run_tests.Runner.patch_file')
- @mock.patch('functest.ci.run_tests.Runner.update_db_url')
- def test_update_config_file_default(self, *mock_methods):
+ def test_update_config_file_default(self, mock_patch):
self.runner.update_config_file()
- mock_methods[1].assert_called()
- mock_methods[0].assert_not_called()
-
- @mock.patch('functest.ci.run_tests.Runner.patch_file')
- @mock.patch('functest.ci.run_tests.Runner.update_db_url')
- @mock.patch.dict(os.environ, {'TEST_DB_URL': 'somevalue'})
- def test_update_config_file_update_db(self, *mock_methods):
- self.runner.update_config_file()
- mock_methods[1].assert_called()
- mock_methods[0].assert_called()
+ mock_patch.assert_called()
def test_patch_file_missing_file(self):
patch_file_path = "unexisting_file"
@@ -119,25 +108,6 @@ class RunTestsTesting(unittest.TestCase):
mock_methods[1].assert_called()
mock_methods[0].assert_called()
- def test_update_db_url_missing_file(self):
- run_tests.CONFIG_FUNCTEST_PATH = "unexisting_file"
- with self.assertRaises(IOError):
- self.runner.update_db_url()
-
- @mock.patch('functest.ci.run_tests.yaml.safe_load')
- @mock.patch('functest.ci.run_tests.ft_utils.get_functest_yaml')
- @mock.patch.dict(os.environ, {'TEST_DB_URL': 'url2'})
- def test_update_db_url_default(self, *mock_methods):
- with mock.patch(
- 'six.moves.builtins.open', mock.mock_open()), mock.patch(
- 'functest.ci.run_tests.yaml.safe_load') as yaml1:
- yaml1.return_value = self.config_file_yaml
- self.runner.update_db_url()
- self.assertEqual(
- yaml1.return_value['results']['test_db_url'], 'url2')
- mock_methods[0].assert_not_called()
- mock_methods[1].assert_not_called()
-
@mock.patch('functest.ci.run_tests.logger.error')
def test_source_rc_file_missing_file(self, mock_logger_error):
with mock.patch('functest.ci.run_tests.os.path.isfile',
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py
index f07f59d7f..bbb6b631a 100644
--- a/functest/utils/functest_utils.py
+++ b/functest/utils/functest_utils.py
@@ -130,7 +130,10 @@ def push_results_to_db(project, case_name,
POST results to the Result target DB
"""
# Retrieve params from CI and conf
- url = CONST.__getattribute__("results_test_db_url")
+ if (hasattr(CONST, 'TEST_DB_URL')):
+ url = CONST.__getattribute__('TEST_DB_URL')
+ else:
+ url = CONST.__getattribute__("results_test_db_url")
try:
installer = os.environ['INSTALLER_TYPE']