aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docker/Dockerfile13
-rwxr-xr-xfunctest/ci/config_functest.yaml1
-rwxr-xr-xfunctest/ci/exec_test.sh15
-rw-r--r--functest/ci/logging.json29
-rwxr-xr-xfunctest/ci/run_tests.py2
-rw-r--r--[-rwxr-xr-x]functest/core/pytest_suite_runner.py0
-rw-r--r--functest/core/testcase_base.py47
-rw-r--r--functest/core/vnf_base.py12
-rwxr-xr-xfunctest/opnfv_tests/features/copper.py2
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/openstack/vping/vping_base.py2
-rwxr-xr-xfunctest/opnfv_tests/sdn/odl/odl.py3
-rw-r--r--functest/opnfv_tests/vnf/aaa/aaa.py3
-rw-r--r--functest/opnfv_tests/vnf/ims/cloudify_ims.py3
-rw-r--r--functest/opnfv_tests/vnf/ims/opera_ims.py3
-rw-r--r--functest/opnfv_tests/vnf/ims/orchestra_ims.py3
-rw-r--r--functest/tests/unit/cli/commands/test_cli_env.py1
-rwxr-xr-x[-rw-r--r--]functest/tests/unit/core/test_testcase_base.py9
-rw-r--r--functest/tests/unit/odl/test_odl.py9
-rw-r--r--functest/tests/unit/test_logging.ini27
-rw-r--r--functest/tests/unit/utils/test_functest_utils.py1
-rw-r--r--functest/utils/functest_constants.py15
-rwxr-xr-x[-rw-r--r--]functest/utils/functest_logger.py60
-rw-r--r--functest/utils/functest_utils.py34
-rw-r--r--[-rwxr-xr-x]functest/utils/openstack_tacker.py0
-rw-r--r--[-rwxr-xr-x]requirements.txt0
-rwxr-xr-xrun_unit_tests.sh1
-rw-r--r--[-rwxr-xr-x]test-requirements.txt0
27 files changed, 211 insertions, 84 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
index d7fb550e..dce657e8 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -43,6 +43,7 @@ ARG FUNCTEST_RESULTS_DIR=${FUNCTEST_BASE_DIR}/results
ARG FUNCTEST_REPO_DIR=${REPOS_DIR}/functest
ARG FUNCTEST_TEST_DIR=${FUNCTEST_REPO_DIR}/functest/opnfv_tests
ARG RELENG_MODULE_DIR=${REPOS_DIR}/releng/modules
+ARG REPOS_VNFS_DIR=${REPOS_DIR}/vnfs
# Environment variables
ENV HOME /home/opnfv
@@ -81,7 +82,7 @@ wget \
RUN pip install --upgrade pip
RUN mkdir -p ${REPOS_DIR} \
- && mkdir -p ${REPOS_DIR}/vnfs \
+ && mkdir -p ${REPOS_VNFS_DIR} \
&& mkdir -p ${FUNCTEST_BASE_DIR}/results \
&& mkdir -p ${FUNCTEST_BASE_DIR}/conf \
&& mkdir -p /root/.ssh \
@@ -111,7 +112,7 @@ RUN git clone --depth 1 -b $TEMPEST_TAG https://github.com/openstack/tempest.git
# other repositories
RUN git clone --depth 1 -b $ODL_TAG https://git.opendaylight.org/gerrit/p/integration/test.git ${REPOS_DIR}/odl_test
-RUN git clone --depth 1 -b $VIMS_TAG https://github.com/boucherv-orange/clearwater-live-test ${REPOS_DIR}/vnfs/vims-test
+RUN git clone --depth 1 -b $VIMS_TAG https://github.com/boucherv-orange/clearwater-live-test ${REPOS_VNFS_DIR}/vims-test
RUN git clone --depth 1 https://github.com/wuwenbin2/OnosSystemTest.git ${REPOS_DIR}/onos
RUN cd ${FUNCTEST_REPO_DIR} \
@@ -154,16 +155,16 @@ RUN cd ${REPOS_DIR}/bgpvpn && pip install .
RUN cd ${REPOS_DIR}/moon/moonclient/ && python setup.py install
RUN /bin/bash -c ". /etc/profile.d/rvm.sh \
- && cd ${REPOS_DIR}/vims-test \
+ && cd ${REPOS_VNFS_DIR}/vims-test \
&& rvm autolibs enable"
RUN /bin/bash -c ". /etc/profile.d/rvm.sh \
- && cd ${REPOS_DIR}/vims-test \
+ && cd ${REPOS_VNFS_DIR}/vims-test \
&& rvm install 1.9.3"
RUN /bin/bash -c ". /etc/profile.d/rvm.sh \
- && cd ${REPOS_DIR}/vims-test \
+ && cd ${REPOS_VNFS_DIR}/vims-test \
&& rvm use 1.9.3"
RUN /bin/bash -c ". /etc/profile.d/rvm.sh \
- && cd ${REPOS_DIR}/vims-test \
+ && cd ${REPOS_VNFS_DIR}/vims-test \
&& bundle install"
RUN sh -c 'curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -' \
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index 25be1724..f1efd904 100755
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -30,6 +30,7 @@ general:
functest: /home/opnfv/functest
functest_test: /home/opnfv/repos/functest/functest/opnfv_tests
results: /home/opnfv/functest/results
+ functest_logging_cfg: /home/opnfv/repos/functest/functest/ci/logging.json
functest_conf: /home/opnfv/functest/conf
functest_data: /home/opnfv/functest/data
dir_vIMS_data: /home/opnfv/functest/data/vIMS/
diff --git a/functest/ci/exec_test.sh b/functest/ci/exec_test.sh
index 109de078..7c96d69c 100755
--- a/functest/ci/exec_test.sh
+++ b/functest/ci/exec_test.sh
@@ -47,11 +47,13 @@ function odl_tests(){
neutron_ip=$(openstack catalog show network | grep publicURL | cut -f3 -d"/" | cut -f1 -d":")
odl_ip=${neutron_ip}
odl_port=8080
+ odl_restport=8181
if [ "$INSTALLER_TYPE" == "fuel" ]; then
odl_port=8282
elif [ "$INSTALLER_TYPE" == "apex" ]; then
odl_ip=$SDN_CONTROLLER_IP
- odl_port=8181
+ odl_port=8081
+ odl_restport=8081
elif [ "$INSTALLER_TYPE" == "joid" ]; then
odl_ip=$SDN_CONTROLLER
elif [ "$INSTALLER_TYPE" == "compass" ]; then
@@ -78,10 +80,15 @@ function run_test(){
odl_tests
[[ "$report" == "-r" ]] && args=-p
${FUNCTEST_TEST_DIR}/sdn/odl/odl.py \
- --keystoneip $keystone_ip --neutronip $neutron_ip \
- --osusername ${OS_USERNAME} --ostenantname ${OS_TENANT_NAME} \
+ --keystoneip $keystone_ip \
+ --neutronip $neutron_ip \
+ --odlip $odl_ip \
+ --odlrestconfport $odl_restport \
+ --odlwebport $odl_port \
--ospassword ${OS_PASSWORD} \
- --odlip $odl_ip --odlwebport $odl_port ${args}
+ --ostenantname ${OS_TENANT_NAME} \
+ --osusername ${OS_USERNAME} \
+ ${args}
;;
"vims")
python ${FUNCTEST_TEST_DIR}/vnf/ims/vims.py $clean_flag $report
diff --git a/functest/ci/logging.json b/functest/ci/logging.json
new file mode 100644
index 00000000..3f454e8f
--- /dev/null
+++ b/functest/ci/logging.json
@@ -0,0 +1,29 @@
+{
+ "version": 1,
+ "disable_existing_loggers": false,
+ "formatters": {
+ "standard": {
+ "format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
+ }
+ },
+ "handlers": {
+ "console": {
+ "level": "INFO",
+ "class": "logging.StreamHandler",
+ "formatter": "standard"
+ },
+ "file": {
+ "level": "DEBUG",
+ "class": "logging.FileHandler",
+ "formatter": "standard",
+ "filename": "/home/opnfv/functest/results/functest.log"
+ }
+ },
+ "loggers": {
+ "": {
+ "handlers": ["console", "file"],
+ "level": "DEBUG",
+ "propagate": "yes"
+ }
+ }
+}
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index 10f1ac9a..a5f1ab9e 100755
--- a/functest/ci/run_tests.py
+++ b/functest/ci/run_tests.py
@@ -155,7 +155,7 @@ def run_test(test, tier_name, testcases=None):
result = test_case.run()
if result == testcase_base.TestcaseBase.EX_OK:
if GlobalVariables.REPORT_FLAG:
- test_case.push_to_db()
+ test_case.publish_report()
result = test_case.check_criteria()
except ImportError:
logger.exception("Cannot import module {}".format(
diff --git a/functest/core/pytest_suite_runner.py b/functest/core/pytest_suite_runner.py
index 1eed92b5..1eed92b5 100755..100644
--- a/functest/core/pytest_suite_runner.py
+++ b/functest/core/pytest_suite_runner.py
diff --git a/functest/core/testcase_base.py b/functest/core/testcase_base.py
index 838b6398..ec46bc64 100644
--- a/functest/core/testcase_base.py
+++ b/functest/core/testcase_base.py
@@ -9,6 +9,7 @@
import os
+from functest.utils.constants import CONST
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
@@ -17,7 +18,7 @@ class TestcaseBase(object):
EX_OK = os.EX_OK
EX_RUN_ERROR = os.EX_SOFTWARE
- EX_PUSH_TO_DB_ERROR = os.EX_SOFTWARE - 1
+ EX_PUBLISH_RESULT_FAILED = os.EX_SOFTWARE - 1
EX_TESTCASE_FAILED = os.EX_SOFTWARE - 2
logger = ft_logger.Logger(__name__).getLogger()
@@ -43,21 +44,45 @@ class TestcaseBase(object):
self.logger.error("Run must be implemented")
return TestcaseBase.EX_RUN_ERROR
- def push_to_db(self):
+ def publish_report(self):
+ if "RESULTS_STORE" in os.environ:
+ CONST.results_test_db_url = os.environ['RESULTS_STORE']
+
try:
assert self.project_name
assert self.case_name
assert self.criteria
assert self.start_time
assert self.stop_time
- if ft_utils.push_results_to_db(
- self.project_name, self.case_name, self.start_time,
- self.stop_time, self.criteria, self.details):
- self.logger.info("The results were successfully pushed to DB")
- return TestcaseBase.EX_OK
+ if CONST.results_test_db_url.lower().startswith(
+ ("http://", "https://")):
+ self.push_to_db()
+ elif CONST.results_test_db_url.lower().startswith("file://"):
+ self.write_to_file()
else:
- self.logger.error("The results cannot be pushed to DB")
- return TestcaseBase.EX_PUSH_TO_DB_ERROR
+ self.logger.error("Please check parameter test_db_url and "
+ "OS environ variable RESTULTS_STORE")
+ return TestcaseBase.EX_PUBLISH_RESULT_FAILED
except Exception:
- self.logger.exception("The results cannot be pushed to DB")
- return TestcaseBase.EX_PUSH_TO_DB_ERROR
+ self.logger.exception("The results cannot be stored")
+ return TestcaseBase.EX_PUBLISH_RESULT_FAILED
+
+ def write_to_file(self):
+ if ft_utils.write_results_to_file(
+ self.project_name, self.case_name, self.start_time,
+ self.stop_time, self.criteria, self.details):
+ self.logger.info("The results were successfully written to a file")
+ return TestcaseBase.EX_OK
+ else:
+ self.logger.error("write results to a file failed")
+ return TestcaseBase.EX_PUBLISH_RESULT_FAILED
+
+ def push_to_db(self):
+ if ft_utils.push_results_to_db(
+ self.project_name, self.case_name, self.start_time,
+ self.stop_time, self.criteria, self.details):
+ self.logger.info("The results were successfully pushed to DB")
+ return TestcaseBase.EX_OK
+ else:
+ self.logger.error("The results cannot be pushed to DB")
+ return TestcaseBase.EX_PUBLISH_RESULT_FAILED
diff --git a/functest/core/vnf_base.py b/functest/core/vnf_base.py
index 99520494..4d019858 100644
--- a/functest/core/vnf_base.py
+++ b/functest/core/vnf_base.py
@@ -35,6 +35,7 @@ class VnfOnBoardingBase(base.TestcaseBase):
self.details['orchestrator'] = {}
self.details['vnf'] = {}
self.details['test_vnf'] = {}
+ self.images = {}
try:
self.tenant_name = CONST.__getattribute__(
'vnf_{}_tenant_name'.format(self.case_name))
@@ -44,7 +45,7 @@ class VnfOnBoardingBase(base.TestcaseBase):
raise Exception("Unknown VNF case=" + self.case_name)
try:
- self.tenant_images = CONST.__getattribute__(
+ self.images = CONST.__getattribute__(
'vnf_{}_tenant_images'.format(self.case_name))
except:
self.logger.warn("No tenant image defined for this VNF")
@@ -152,14 +153,15 @@ class VnfOnBoardingBase(base.TestcaseBase):
self.logger.info("Update OpenStack creds informations")
self.creds.update({
- "username": self.tenant_name,
- "password": self.tenant_name,
"tenant": self.tenant_name,
})
- self.glance_client = os_utils.get_glance_client(self.creds)
self.neutron_client = os_utils.get_neutron_client(self.creds)
self.nova_client = os_utils.get_nova_client(self.creds)
-
+ self.creds.update({
+ "username": self.tenant_name,
+ "password": self.tenant_name,
+ })
+ self.glance_client = os_utils.get_glance_client(self.creds)
self.logger.info("Upload some OS images if it doesn't exist")
temp_dir = os.path.join(self.data_dir, "tmp/")
diff --git a/functest/opnfv_tests/features/copper.py b/functest/opnfv_tests/features/copper.py
index 204fa337..a10364e2 100755
--- a/functest/opnfv_tests/features/copper.py
+++ b/functest/opnfv_tests/features/copper.py
@@ -22,4 +22,4 @@ class Copper(base.FeatureBase):
super(Copper, self).__init__(project='copper',
case='copper-notification',
repo='dir_repo_copper')
- self.cmd = 'cd %s/tests && ./run.sh' % self.repo
+ self.cmd = 'bash %s/tests/run.sh' % self.repo
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py
index a5309bd4..8285d93f 100755..100644
--- a/functest/opnfv_tests/openstack/vping/vping_base.py
+++ b/functest/opnfv_tests/openstack/vping/vping_base.py
@@ -289,6 +289,6 @@ class VPingMain(object):
if result != VPingBase.EX_OK:
return result
if kwargs['report']:
- return self.vping.push_to_db()
+ return self.vping.publish_report()
except Exception:
return VPingBase.EX_RUN_ERROR
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index 606d59a1..339c305e 100755
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -162,6 +162,7 @@ class ODLTests(testcase_base.TestcaseBase):
elif installer_type == 'apex':
kwargs['odlip'] = os.environ['SDN_CONTROLLER_IP']
kwargs['odlwebport'] = '8081'
+ kwargs['odlrestconfport'] = '8081'
elif installer_type == 'joid':
kwargs['odlip'] = os.environ['SDN_CONTROLLER']
elif installer_type == 'compass':
@@ -231,6 +232,6 @@ if __name__ == '__main__':
if result != testcase_base.TestcaseBase.EX_OK:
sys.exit(result)
if args['pushtodb']:
- sys.exit(odl.push_to_db())
+ sys.exit(odl.publish_report())
except Exception:
sys.exit(testcase_base.TestcaseBase.EX_RUN_ERROR)
diff --git a/functest/opnfv_tests/vnf/aaa/aaa.py b/functest/opnfv_tests/vnf/aaa/aaa.py
index 8898b9fc..f1c265f4 100644
--- a/functest/opnfv_tests/vnf/aaa/aaa.py
+++ b/functest/opnfv_tests/vnf/aaa/aaa.py
@@ -21,8 +21,7 @@ class AaaVnf(vnf_base.VnfOnBoardingBase):
logger = ft_logger.Logger("VNF AAA").getLogger()
def __init__(self):
- super(AaaVnf, self).__init__()
- self.case_name = "aaa"
+ super(AaaVnf, self).__init__(case="aaa")
def deploy_orchestrator(self):
self.logger.info("No VNFM needed to deploy a free radius here")
diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
index e584519b..13a5af4f 100644
--- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py
+++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py
@@ -25,7 +25,8 @@ from orchestrator_cloudify import Orchestrator
class ImsVnf(vnf_base.VnfOnBoardingBase):
- def __init__(self, project='functest', case='', repo='', cmd=''):
+ def __init__(self, project='functest', case='cloudify_ims',
+ repo='', cmd=''):
super(ImsVnf, self).__init__(project, case, repo, cmd)
self.logger = ft_logger.Logger("vIMS").getLogger()
self.case_dir = os.path.join(CONST.functest_test, 'vnf/ims/')
diff --git a/functest/opnfv_tests/vnf/ims/opera_ims.py b/functest/opnfv_tests/vnf/ims/opera_ims.py
index fa8f9ec9..073a56c3 100644
--- a/functest/opnfv_tests/vnf/ims/opera_ims.py
+++ b/functest/opnfv_tests/vnf/ims/opera_ims.py
@@ -21,7 +21,8 @@ from functest.utils.constants import CONST
class ImsVnf(vnf_base.VnfOnBoardingBase):
- def __init__(self, project='functest', case='', repo='', cmd=''):
+ def __init__(self, project='functest', case='opera_ims',
+ repo='', cmd=''):
super(ImsVnf, self).__init__(project, case, repo, cmd)
self.logger = ft_logger.Logger("vIMS").getLogger()
self.case_dir = os.path.join(CONST.functest_test, 'vnf/ims/')
diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
index ebd6c9ba..28f37f05 100644
--- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
@@ -21,7 +21,8 @@ from functest.utils.constants import CONST
class ImsVnf(vnf_base.VnfOnBoardingBase):
- def __init__(self, project='functest', case='', repo='', cmd=''):
+ def __init__(self, project='functest', case='orchestra_ims',
+ repo='', cmd=''):
super(ImsVnf, self).__init__(project, case, repo, cmd)
self.logger = ft_logger.Logger("vIMS").getLogger()
self.case_dir = os.path.join(CONST.functest_test, 'vnf/ims/')
diff --git a/functest/tests/unit/cli/commands/test_cli_env.py b/functest/tests/unit/cli/commands/test_cli_env.py
index f70761dc..4b6ea57a 100644
--- a/functest/tests/unit/cli/commands/test_cli_env.py
+++ b/functest/tests/unit/cli/commands/test_cli_env.py
@@ -11,7 +11,6 @@ import unittest
from git.exc import NoSuchPathError
import mock
-mock.patch('logging.FileHandler').start() # noqa
from functest.cli.commands import cli_env
from functest.utils.constants import CONST
from functest.tests.unit import test_utils
diff --git a/functest/tests/unit/core/test_testcase_base.py b/functest/tests/unit/core/test_testcase_base.py
index b6efa40d..94d2e966 100644..100755
--- a/functest/tests/unit/core/test_testcase_base.py
+++ b/functest/tests/unit/core/test_testcase_base.py
@@ -9,9 +9,9 @@
import logging
import mock
+import os
import unittest
-mock.patch('logging.FileHandler').start() # noqa
from functest.core import testcase_base
@@ -32,11 +32,12 @@ class TestcaseBaseTesting(unittest.TestCase):
self.assertEqual(self.test.run(),
testcase_base.TestcaseBase.EX_RUN_ERROR)
+ @mock.patch.dict(os.environ, {})
@mock.patch('functest.utils.functest_utils.push_results_to_db',
return_value=False)
def _test_missing_attribute(self, mock_function):
- self.assertEqual(self.test.push_to_db(),
- testcase_base.TestcaseBase.EX_PUSH_TO_DB_ERROR)
+ self.assertEqual(self.test.publish_report(),
+ testcase_base.TestcaseBase.EX_PUBLISH_RESULT_FAILED)
mock_function.assert_not_called()
def test_missing_case_name(self):
@@ -69,7 +70,7 @@ class TestcaseBaseTesting(unittest.TestCase):
return_value=False)
def test_push_to_db_failed(self, mock_function):
self.assertEqual(self.test.push_to_db(),
- testcase_base.TestcaseBase.EX_PUSH_TO_DB_ERROR)
+ testcase_base.TestcaseBase.EX_PUBLISH_RESULT_FAILED)
mock_function.assert_called_once_with(
self.test.project, self.test.case_name, self.test.start_time,
self.test.stop_time, self.test.criteria, self.test.details)
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index 8a52a9f6..568fdc82 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -19,7 +19,6 @@ from robot.errors import DataError, RobotError
from robot.result import testcase
from robot.utils.robottime import timestamp_to_secs
-mock.patch('logging.FileHandler').start() # noqa
from functest.core import testcase_base
from functest.opnfv_tests.sdn.odl import odl
@@ -337,7 +336,8 @@ class ODLTesting(unittest.TestCase):
testcase_base.TestcaseBase.EX_RUN_ERROR)
def _test_run(self, status=testcase_base.TestcaseBase.EX_OK,
- exception=None, odlip="127.0.0.3", odlwebport="8080"):
+ exception=None, odlip="127.0.0.3", odlwebport="8080",
+ odlrestconfport="8181"):
with mock.patch('functest.utils.openstack_utils.get_endpoint',
side_effect=self._fake_url_for):
if exception:
@@ -348,7 +348,7 @@ class ODLTesting(unittest.TestCase):
self.test.main.assert_called_once_with(
keystoneip=self._keystone_ip, neutronip=self._neutron_ip,
odlip=odlip, odlpassword=self._odl_password,
- odlrestconfport=self._odl_restconfport,
+ odlrestconfport=odlrestconfport,
odlusername=self._odl_username, odlwebport=odlwebport,
ospassword=self._os_password, ostenantname=self._os_tenantname,
osusername=self._os_username)
@@ -410,7 +410,8 @@ class ODLTesting(unittest.TestCase):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
os.environ["INSTALLER_TYPE"] = "apex"
self._test_run(testcase_base.TestcaseBase.EX_OK,
- odlip=self._sdn_controller_ip, odlwebport='8081')
+ odlip=self._sdn_controller_ip, odlwebport='8081',
+ odlrestconfport='8081')
def test_run_joid_missing_sdn_controller(self):
with mock.patch('functest.utils.openstack_utils.get_endpoint',
diff --git a/functest/tests/unit/test_logging.ini b/functest/tests/unit/test_logging.ini
new file mode 100644
index 00000000..3d5b947c
--- /dev/null
+++ b/functest/tests/unit/test_logging.ini
@@ -0,0 +1,27 @@
+[loggers]
+keys=root,functest_logger
+
+[logger_root]
+level=DEBUG
+handlers=console
+
+[logger_functest_logger]
+level=DEBUG
+handlers=console
+qualname=functest.utils.functest_logger
+propagate=0
+
+[handlers]
+keys=console
+
+[handler_console]
+class=StreamHandler
+level=INFO
+formatter=standard
+args=(sys.stdout,)
+
+[formatters]
+keys=standard
+
+[formatter_standard]
+format=%(asctime)s - %(name)s - %(levelname)s - %(message)s \ No newline at end of file
diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py
index c4b56660..ce9086a7 100644
--- a/functest/tests/unit/utils/test_functest_utils.py
+++ b/functest/tests/unit/utils/test_functest_utils.py
@@ -18,7 +18,6 @@ import mock
import requests
from functest.tests.unit import test_utils
-mock.patch('logging.FileHandler').start() # noqa
from functest.utils import functest_utils
diff --git a/functest/utils/functest_constants.py b/functest/utils/functest_constants.py
index c4be0779..7fb03e8a 100644
--- a/functest/utils/functest_constants.py
+++ b/functest/utils/functest_constants.py
@@ -241,20 +241,5 @@ EXAMPLE_SECGROUP_NAME = get_value('example.sg_name',
'EXAMPLE_SECGROUP_NAME')
EXAMPLE_SECGROUP_DESCR = get_value('example.sg_desc',
'EXAMPLE_SECGROUP_DESCR')
-VIMS_DATA_DIR = get_value('general.dir.dir_vIMS_data',
- 'VIMS_DATA_DIR')
-VIMS_TEST_DIR = get_value('general.dir.dir_repo_vims_test',
- 'VIMS_TEST_DIR')
-CFY_MANAGER_BLUEPRINT = get_value('vIMS.cloudify.blueprint',
- 'CFY_MANAGER_BLUEPRINT')
-CFY_MANAGER_REQUIERMENTS = get_value('vIMS.cloudify.requierments',
- 'CFY_MANAGER_REQUIERMENTS')
-CFY_INPUTS = get_value('vIMS.cloudify.inputs', 'CFY_INPUTS')
-CW_BLUEPRINT = get_value('vIMS.clearwater.blueprint', 'CW_BLUEPRINT')
-CW_DEPLOYMENT_NAME = get_value('vIMS.clearwater.deployment-name',
- 'CW_DEPLOYMENT_NAME')
-CW_INPUTS = get_value('vIMS.clearwater.inputs', 'CW_INPUTS')
-CW_REQUIERMENTS = get_value('vIMS.clearwater.requierments',
- 'CW_REQUIERMENTS')
PARSER_REPO_DIR = get_value('general.dir.repo_parser',
'PARSER_REPO_DIR')
diff --git a/functest/utils/functest_logger.py b/functest/utils/functest_logger.py
index c0fba082..f09f56be 100644..100755
--- a/functest/utils/functest_logger.py
+++ b/functest/utils/functest_logger.py
@@ -20,36 +20,50 @@
# logger = fl.Logger("script_name").getLogger()
# logger.info("message to be shown with - INFO - ")
# logger.debug("message to be shown with - DEBUG -")
-
import logging
+import logging.config
import os
+import json
-class Logger:
- def __init__(self, logger_name):
+from functest.utils.constants import CONST
+
+logger = logging.getLogger(__name__)
+
+
+def is_debug():
+ if CONST.CI_DEBUG and CONST.CI_DEBUG.lower() == "true":
+ return True
+ return False
- CI_DEBUG = os.getenv('CI_DEBUG')
+def setup_logging(default_path=CONST.dir_functest_logging_cfg,
+ default_level=logging.INFO,
+ env_key='LOG_CFG'):
+ path = default_path
+ value = os.getenv(env_key, None)
+ if value:
+ path = value
+ if os.path.exists(path):
+ with open(path, 'rt') as f:
+ config = json.load(f)
+ if (config['handlers'] and
+ config['handlers']['console']):
+ stream_level = logging.INFO
+ if is_debug():
+ stream_level = logging.DEBUG
+ config['handlers']['console']['level'] = stream_level
+ logging.config.dictConfig(config)
+ else:
+ logging.basicConfig(level=default_level)
+
+
+setup_logging()
+
+
+class Logger:
+ def __init__(self, logger_name):
self.logger = logging.getLogger(logger_name)
- self.logger.propagate = 0
- self.logger.setLevel(logging.DEBUG)
-
- ch = logging.StreamHandler()
- formatter = logging.Formatter('%(asctime)s - %(name)s - '
- '%(levelname)s - %(message)s')
- ch.setFormatter(formatter)
- if CI_DEBUG is not None and CI_DEBUG.lower() == "true":
- ch.setLevel(logging.DEBUG)
- self.logger.parent.level = logging.DEBUG
- else:
- ch.setLevel(logging.INFO)
- self.logger.parent.level = logging.INFO
- self.logger.addHandler(ch)
-
- hdlr = logging.FileHandler('/home/opnfv/functest/results/functest.log')
- hdlr.setFormatter(formatter)
- hdlr.setLevel(logging.DEBUG)
- self.logger.addHandler(hdlr)
def getLogger(self):
return self.logger
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py
index 1879e694..2bf87a05 100644
--- a/functest/utils/functest_utils.py
+++ b/functest/utils/functest_utils.py
@@ -23,8 +23,10 @@ import requests
import yaml
from git import Repo
+from functest.utils.constants import CONST
import functest.utils.functest_logger as ft_logger
+
logger = ft_logger.Logger("functest_utils").getLogger()
@@ -181,13 +183,43 @@ def logger_test_results(project, case_name, status, details):
'd': details})
+def write_results_to_file(project, case_name, start_date,
+ stop_date, criteria, details):
+ file_path = re.split(r'://', CONST.results_test_db_url)[1]
+
+ try:
+ installer = os.environ['INSTALLER_TYPE']
+ scenario = os.environ['DEPLOY_SCENARIO']
+ pod_name = os.environ['NODE_NAME']
+ except KeyError as e:
+ logger.error("Please set env var: " + str(e))
+ return False
+
+ test_start = dt.fromtimestamp(start_date).strftime('%Y-%m-%d %H:%M:%S')
+ test_stop = dt.fromtimestamp(stop_date).strftime('%Y-%m-%d %H:%M:%S')
+
+ params = {"project_name": project, "case_name": case_name,
+ "pod_name": pod_name, "installer": installer,
+ "scenario": scenario, "criteria": criteria,
+ "start_date": test_start, "stop_date": test_stop,
+ "details": details}
+ try:
+ with open(file_path, "a+w") as outfile:
+ json.dump(params, outfile)
+ outfile.write("\n")
+ return True
+ except Exception as e:
+ logger.error("write result data into a file failed: %s" % e)
+ return False
+
+
def push_results_to_db(project, case_name,
start_date, stop_date, criteria, details):
"""
POST results to the Result target DB
"""
# Retrieve params from CI and conf
- url = get_db_url() + "/results"
+ url = CONST.results_test_db_url + "/results"
try:
installer = os.environ['INSTALLER_TYPE']
diff --git a/functest/utils/openstack_tacker.py b/functest/utils/openstack_tacker.py
index f17b421e..f17b421e 100755..100644
--- a/functest/utils/openstack_tacker.py
+++ b/functest/utils/openstack_tacker.py
diff --git a/requirements.txt b/requirements.txt
index 28b3fed3..28b3fed3 100755..100644
--- a/requirements.txt
+++ b/requirements.txt
diff --git a/run_unit_tests.sh b/run_unit_tests.sh
index 79d05d3d..5167d78c 100755
--- a/run_unit_tests.sh
+++ b/run_unit_tests.sh
@@ -38,6 +38,7 @@ nosetests --with-xunit \
--cover-package=functest.utils \
--cover-xml \
--cover-html \
+ --log-config=$(pwd)/functest/tests/unit/test_logging.ini \
functest/tests/unit
rc=$?
diff --git a/test-requirements.txt b/test-requirements.txt
index 2bf297ba..2bf297ba 100755..100644
--- a/test-requirements.txt
+++ b/test-requirements.txt