aboutsummaryrefslogtreecommitdiffstats
path: root/functest
diff options
context:
space:
mode:
Diffstat (limited to 'functest')
-rw-r--r--functest/ci/config_functest.yaml6
-rwxr-xr-xfunctest/ci/prepare_env.py2
-rw-r--r--functest/core/feature.py18
-rw-r--r--functest/tests/unit/ci/test_prepare_env.py8
-rw-r--r--functest/tests/unit/core/test_feature.py23
5 files changed, 42 insertions, 15 deletions
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index 60270b6c..623092a5 100644
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -62,9 +62,9 @@ general:
snaps:
use_keystone: True
use_floating_ips: True
-# images:
-# cirros:
-# disk_url: http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img
+ images:
+ cirros:
+ disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img
# ARM
# disk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-disk.img
# kernel_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-kernel
diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py
index 5326c50b..64fcc925 100755
--- a/functest/ci/prepare_env.py
+++ b/functest/ci/prepare_env.py
@@ -366,7 +366,6 @@ def main(**kwargs):
elif kwargs['action'] == "start":
logger.info("######### Preparing Functest environment #########\n")
check_env_variables()
- get_deployment_handler()
create_directories()
source_rc_file()
update_config_file()
@@ -377,7 +376,6 @@ def main(**kwargs):
with open(CONST.__getattribute__('env_active'), "w") as env_file:
env_file.write("1")
check_environment()
- print_deployment_info()
elif kwargs['action'] == "check":
check_environment()
except Exception as e:
diff --git a/functest/core/feature.py b/functest/core/feature.py
index d53eb7d0..010ff4bc 100644
--- a/functest/core/feature.py
+++ b/functest/core/feature.py
@@ -33,6 +33,24 @@ class Feature(base.TestCase):
super(Feature, self).__init__(**kwargs)
self.result_file = "{}/{}.log".format(
CONST.__getattribute__('dir_results'), self.case_name)
+ try:
+ module = kwargs['run']['module']
+ self.logger = logging.getLogger(module)
+ except KeyError:
+ self.__logger.warning(
+ "Cannot get module name %s. Using %s as fallback",
+ kwargs, self.case_name)
+ self.logger = logging.getLogger(self.case_name)
+ handler = logging.StreamHandler()
+ handler.setLevel(logging.WARN)
+ self.logger.addHandler(handler)
+ handler = logging.FileHandler(self.result_file)
+ handler.setLevel(logging.DEBUG)
+ self.logger.addHandler(handler)
+ formatter = logging.Formatter(
+ '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+ handler.setFormatter(formatter)
+ self.logger.addHandler(handler)
def execute(self, **kwargs):
"""Execute the Python method.
diff --git a/functest/tests/unit/ci/test_prepare_env.py b/functest/tests/unit/ci/test_prepare_env.py
index f3e15a01..69abd643 100644
--- a/functest/tests/unit/ci/test_prepare_env.py
+++ b/functest/tests/unit/ci/test_prepare_env.py
@@ -424,7 +424,6 @@ class PrepareEnvTesting(unittest.TestCase):
mock_logger_info.assert_any_call("Functest environment"
" is installed.")
- @mock.patch('functest.ci.prepare_env.print_deployment_info')
@mock.patch('functest.ci.prepare_env.check_environment')
@mock.patch('functest.ci.prepare_env.create_flavor')
@mock.patch('functest.ci.prepare_env.install_tempest')
@@ -433,21 +432,19 @@ class PrepareEnvTesting(unittest.TestCase):
@mock.patch('functest.ci.prepare_env.update_config_file')
@mock.patch('functest.ci.prepare_env.source_rc_file')
@mock.patch('functest.ci.prepare_env.create_directories')
- @mock.patch('functest.ci.prepare_env.get_deployment_handler')
@mock.patch('functest.ci.prepare_env.check_env_variables')
@mock.patch('functest.ci.prepare_env.logger.info')
- def test_main_start(self, mock_logger_info, mock_env_var, mock_dep_handler,
+ def test_main_start(self, mock_logger_info, mock_env_var,
mock_create_dir, mock_source_rc, mock_update_config,
mock_verify_depl, mock_install_rally,
mock_install_temp, mock_create_flavor,
- mock_check_env, mock_print_info):
+ mock_check_env):
with mock.patch("__builtin__.open", mock.mock_open()) as m:
args = {'action': 'start'}
self.assertEqual(prepare_env.main(**args), 0)
mock_logger_info.assert_any_call("######### Preparing Functest "
"environment #########\n")
self.assertTrue(mock_env_var.called)
- self.assertTrue(mock_dep_handler.called)
self.assertTrue(mock_create_dir.called)
self.assertTrue(mock_source_rc.called)
self.assertTrue(mock_update_config.called)
@@ -458,7 +455,6 @@ class PrepareEnvTesting(unittest.TestCase):
m.assert_called_once_with(
CONST.__getattribute__('env_active'), "w")
self.assertTrue(mock_check_env.called)
- self.assertTrue(mock_print_info.called)
@mock.patch('functest.ci.prepare_env.check_environment')
def test_main_check(self, mock_check_env):
diff --git a/functest/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py
index 0160c8e1..988981ef 100644
--- a/functest/tests/unit/core/test_feature.py
+++ b/functest/tests/unit/core/test_feature.py
@@ -38,12 +38,26 @@ class FeatureTestingBase(unittest.TestCase):
self.assertEqual(self.feature.start_time, 1)
self.assertEqual(self.feature.stop_time, 2)
+ def test_logger_module_ko(self):
+ with mock.patch('six.moves.builtins.open'):
+ self.feature = feature.Feature(
+ project_name=self._project_name, case_name=self._case_name)
+ self.assertEqual(self.feature.logger.name, self._case_name)
+
+ def test_logger_module(self):
+ with mock.patch('six.moves.builtins.open'):
+ self.feature = feature.Feature(
+ project_name=self._project_name, case_name=self._case_name,
+ run={'module': 'bar'})
+ self.assertEqual(self.feature.logger.name, 'bar')
+
class FeatureTesting(FeatureTestingBase):
def setUp(self):
- self.feature = feature.Feature(
- project_name=self._project_name, case_name=self._case_name)
+ with mock.patch('six.moves.builtins.open'):
+ self.feature = feature.Feature(
+ project_name=self._project_name, case_name=self._case_name)
def test_run_exc(self):
# pylint: disable=bad-continuation
@@ -60,8 +74,9 @@ class FeatureTesting(FeatureTestingBase):
class BashFeatureTesting(FeatureTestingBase):
def setUp(self):
- self.feature = feature.BashFeature(
- project_name=self._project_name, case_name=self._case_name)
+ with mock.patch('six.moves.builtins.open'):
+ self.feature = feature.BashFeature(
+ project_name=self._project_name, case_name=self._case_name)
@mock.patch("functest.utils.functest_utils.execute_command")
def test_run_no_cmd(self, mock_method=None):