summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--docker/Dockerfile9
-rw-r--r--docker/Dockerfile.aarch645
-rw-r--r--docs/api/_static/.gitkeep0
-rw-r--r--docs/api/_templates/.gitkeep0
-rw-r--r--docs/api/apidoc/functest.core.rst2
-rw-r--r--docs/api/apidoc/functest.core.vnf.rst7
-rw-r--r--docs/api/apidoc/functest.core.vnf_base.rst7
-rwxr-xr-xfunctest/ci/run_tests.py15
-rw-r--r--functest/ci/testcases.yaml1
-rw-r--r--functest/ci/tier_builder.py5
-rw-r--r--functest/core/pytest_suite_runner.py42
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/refstack_client.py24
-rwxr-xr-xfunctest/opnfv_tests/openstack/refstack_client/tempest_conf.py8
-rwxr-xr-xfunctest/opnfv_tests/sdn/odl/odl.py2
-rw-r--r--functest/tests/unit/core/test_pytest_suite_runner.py76
-rw-r--r--functest/tests/unit/core/test_vnf.py4
-rw-r--r--functest/tests/unit/features/test_barometer.py5
-rw-r--r--functest/tests/unit/openstack/refstack_client/test_refstack_client.py24
-rw-r--r--functest/tests/unit/test_logging.ini27
-rw-r--r--functest/tests/unit/utils/test_decorators.py2
-rw-r--r--functest/tests/unit/utils/test_functest_utils.py3
-rw-r--r--functest/utils/env.py4
-rw-r--r--functest/utils/functest_utils.py8
-rw-r--r--functest/utils/openstack_utils.py8
-rw-r--r--requirements.py3.txt39
-rw-r--r--requirements.txt4
-rwxr-xr-xrun_unit_tests.sh49
-rw-r--r--test-requirements.txt3
-rw-r--r--tox.ini43
30 files changed, 231 insertions, 196 deletions
diff --git a/.gitignore b/.gitignore
index d8ba0a976..341cf2811 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,4 @@ coverage.xml
nosetests.xml
functest.egg-info
*venv
+.tox
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 202eb5cb3..ef5967f7f 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -29,7 +29,6 @@ ARG FUNCTEST_IMAGES_DIR=${FUNCTEST_BASE_DIR}/images
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
@@ -90,11 +89,9 @@ RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/doctor ${REPO
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/promise ${REPOS_DIR}/promise
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/netready ${REPOS_DIR}/netready
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/fds ${REPOS_DIR}/fds
-RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/barometer ${REPOS_DIR}/barometer
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sfc ${REPOS_DIR}/sfc
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/snaps ${REPOS_DIR}/snaps
RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/securityscanning ${REPOS_DIR}/securityscanning
-RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng ${REPOS_DIR}/releng
RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/opera ${REPOS_DIR}/opera
# OpenStack repositories
@@ -117,12 +114,6 @@ RUN cd ${FUNCTEST_REPO_DIR} \
&& pip install -r requirements.txt \
&& pip install -e .
-RUN cd ${RELENG_MODULE_DIR} \
- && pip install -e .
-
-RUN cd ${REPOS_DIR}/barometer \
- && pip install .
-
RUN pip install ${REPOS_DIR}/opera
RUN find ${FUNCTEST_REPO_DIR} -name "*.py" \
diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64
index b03c6d978..e323cb18a 100644
--- a/docker/Dockerfile.aarch64
+++ b/docker/Dockerfile.aarch64
@@ -28,7 +28,6 @@ ARG FUNCTEST_IMAGES_DIR=${FUNCTEST_BASE_DIR}/images
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
@@ -90,7 +89,6 @@ RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/promise ${REP
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/sfc ${REPOS_DIR}/sfc
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/snaps ${REPOS_DIR}/snaps
RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/securityscanning ${REPOS_DIR}/securityscanning
-RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng ${REPOS_DIR}/releng
RUN git clone --depth 1 https://gerrit.opnfv.org/gerrit/opera ${REPOS_DIR}/opera
# OpenStack repositories
@@ -112,9 +110,6 @@ RUN cd ${FUNCTEST_REPO_DIR} \
&& pip install -r requirements.txt \
&& pip install -e .
-RUN cd ${RELENG_MODULE_DIR} \
- && pip install -e .
-
RUN find ${FUNCTEST_REPO_DIR} -name "*.py" \
-not -path "*tests/unit*" \
-not -path "*functest_venv*" \
diff --git a/docs/api/_static/.gitkeep b/docs/api/_static/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/docs/api/_static/.gitkeep
diff --git a/docs/api/_templates/.gitkeep b/docs/api/_templates/.gitkeep
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/docs/api/_templates/.gitkeep
diff --git a/docs/api/apidoc/functest.core.rst b/docs/api/apidoc/functest.core.rst
index 29c67e4e3..27b2ed1fb 100644
--- a/docs/api/apidoc/functest.core.rst
+++ b/docs/api/apidoc/functest.core.rst
@@ -13,5 +13,5 @@ Submodules
functest.core.feature
functest.core.testcase
- functest.core.vnf_base
+ functest.core.vnf
diff --git a/docs/api/apidoc/functest.core.vnf.rst b/docs/api/apidoc/functest.core.vnf.rst
new file mode 100644
index 000000000..9fd6b375c
--- /dev/null
+++ b/docs/api/apidoc/functest.core.vnf.rst
@@ -0,0 +1,7 @@
+functest.core.vnf module
+========================
+
+.. automodule:: functest.core.vnf
+ :members:
+ :undoc-members:
+ :show-inheritance:
diff --git a/docs/api/apidoc/functest.core.vnf_base.rst b/docs/api/apidoc/functest.core.vnf_base.rst
deleted file mode 100644
index 94b2eaa90..000000000
--- a/docs/api/apidoc/functest.core.vnf_base.rst
+++ /dev/null
@@ -1,7 +0,0 @@
-functest.core.vnf_base module
-=============================
-
-.. automodule:: functest.core.vnf_base
- :members:
- :undoc-members:
- :show-inheritance:
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index f973b616c..95353c87a 100755
--- a/functest/ci/run_tests.py
+++ b/functest/ci/run_tests.py
@@ -122,10 +122,9 @@ class Runner(object):
if not test.is_enabled():
raise TestNotEnabled(
"The test case {} is not enabled".format(test.get_name()))
- test_name = test.get_name()
logger.info("\n") # blank line
self.print_separator("=")
- logger.info("Running test case '%s'..." % test_name)
+ logger.info("Running test case '%s'..." % test.get_name())
self.print_separator("=")
logger.debug("\n%s" % test)
self.source_rc_file()
@@ -133,17 +132,17 @@ class Runner(object):
if test.needs_clean() and self.clean_flag:
self.generate_os_snapshot()
- flags = (" -t %s" % (test_name))
+ flags = " -t %s" % test.get_name()
if self.report_flag:
flags += " -r"
result = testcase.TestCase.EX_RUN_ERROR
- run_dict = self.get_run_dict(test_name)
+ run_dict = self.get_run_dict(test.get_name())
if run_dict:
try:
module = importlib.import_module(run_dict['module'])
cls = getattr(module, run_dict['class'])
- test_dict = ft_utils.get_dict_by_test(test_name)
+ test_dict = ft_utils.get_dict_by_test(test.get_name())
test_case = cls(**test_dict)
self.executed_test_cases.append(test_case)
try:
@@ -168,7 +167,7 @@ class Runner(object):
if test.needs_clean() and self.clean_flag:
self.cleanup()
if result != testcase.TestCase.EX_OK:
- logger.error("The test case '%s' failed. " % test_name)
+ logger.error("The test case '%s' failed. " % test.get_name())
self.overall_result = Result.EX_ERROR
if test.is_blocking():
raise BlockingTestFailed(
@@ -242,8 +241,10 @@ class Runner(object):
return Result.EX_ERROR
else:
self.run_all(_tiers)
+ except BlockingTestFailed:
+ pass
except Exception:
- logger.exception("Runner failed")
+ logger.exception("Failures when running testcase(s)")
self.overall_result = Result.EX_ERROR
msg = prettytable.PrettyTable(
diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml
index d98a2de23..10587f269 100644
--- a/functest/ci/testcases.yaml
+++ b/functest/ci/testcases.yaml
@@ -302,7 +302,6 @@ tiers:
-
case_name: bgpvpn
- enabled: false
project_name: sdnvpn
criteria: 100
blocking: false
diff --git a/functest/ci/tier_builder.py b/functest/ci/tier_builder.py
index 12562f09c..d03cd9032 100644
--- a/functest/ci/tier_builder.py
+++ b/functest/ci/tier_builder.py
@@ -54,8 +54,9 @@ class TierBuilder(object):
blocking=dic_testcase['blocking'],
clean_flag=dic_testcase['clean_flag'],
description=dic_testcase['description'])
- if (testcase.is_compatible(self.ci_installer, self.ci_scenario)
- and testcase.is_enabled()):
+ if (testcase.is_compatible(self.ci_installer,
+ self.ci_scenario) and
+ testcase.is_enabled()):
tier.add_test(testcase)
self.tier_objects.append(tier)
diff --git a/functest/core/pytest_suite_runner.py b/functest/core/pytest_suite_runner.py
index a6e476600..efcef7b66 100644
--- a/functest/core/pytest_suite_runner.py
+++ b/functest/core/pytest_suite_runner.py
@@ -7,6 +7,8 @@
# pylint: disable=missing-docstring
+from __future__ import division
+
import logging
import time
import unittest
@@ -46,32 +48,14 @@ class PyTestSuiteRunner(testcase.TestCase):
stream=stream, verbosity=2).run(self.suite)
self.logger.debug("\n\n%s", stream.getvalue())
self.stop_time = time.time()
-
- if result.errors:
- self.logger.error('Number of errors in test suite - ' +
- str(len(result.errors)))
- for test, message in result.errors:
- self.logger.error(str(test) + " ERROR with " + message)
-
- if result.failures:
- self.logger.error('Number of failures in test suite - ' +
- str(len(result.failures)))
- for test, message in result.failures:
- self.logger.error(str(test) + " FAILED with " + message)
-
- # a result can be PASS or FAIL
- # But in this case it means that the Execution was OK
- # we shall distinguish Execution Error from FAIL results
- # TestCase.EX_RUN_ERROR means that the test case was not run
- # not that it was run but the result was FAIL
- exit_code = testcase.TestCase.EX_OK
- if ((result.errors and len(result.errors) > 0) or
- (result.failures and len(result.failures) > 0)):
- self.logger.info("%s FAILED", self.case_name)
- self.result = 0
- else:
- self.logger.info("%s OK", self.case_name)
- self.result = 100
-
- self.details = {}
- return exit_code
+ self.details = {"failures": result.failures,
+ "errors": result.errors}
+ try:
+ self.result = 100 * (
+ (result.testsRun - (len(result.failures) +
+ len(result.errors))) /
+ result.testsRun)
+ return testcase.TestCase.EX_OK
+ except ZeroDivisionError:
+ self.logger.error("No test has been run")
+ return testcase.TestCase.EX_RUN_ERROR
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index 2a2718dd8..5f1f3a1dd 100755
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -33,9 +33,9 @@ class RefstackClient(testcase.TestCase):
if "case_name" not in kwargs:
kwargs["case_name"] = "refstack_defcore"
super(RefstackClient, self).__init__(**kwargs)
- self.FUNCTEST_TEST = CONST.dir_functest_test
- self.CONF_PATH = CONST.refstack_tempest_conf_path
- self.DEFCORE_LIST = CONST.refstack_defcore_list
+ self.FUNCTEST_TEST = CONST.__getattribute__('dir_functest_test')
+ self.CONF_PATH = CONST.__getattribute__('refstack_tempest_conf_path')
+ self.DEFCORE_LIST = CONST.__getattribute__('refstack_defcore_list')
self.confpath = os.path.join(self.FUNCTEST_TEST,
self.CONF_PATH)
self.defcorelist = os.path.join(self.FUNCTEST_TEST,
@@ -45,7 +45,7 @@ class RefstackClient(testcase.TestCase):
cmd = ("cd {0};"
". .venv/bin/activate;"
- "cd -;".format(CONST.dir_refstack_client))
+ "cd -;".format(CONST.__getattribute__('dir_refstack_client')))
ft_utils.execute_command(cmd)
def run_defcore(self, conf, testlist):
@@ -53,7 +53,7 @@ class RefstackClient(testcase.TestCase):
cmd = ("cd {0};"
"./refstack-client test -c {1} -v --test-list {2};"
- "cd -;".format(CONST.dir_refstack_client,
+ "cd -;".format(CONST.__getattribute__('dir_refstack_client'),
conf,
testlist))
ft_utils.execute_command(cmd)
@@ -63,16 +63,16 @@ class RefstackClient(testcase.TestCase):
cmd = ("cd {0};"
"./refstack-client test -c {1} -v --test-list {2};"
- "cd -;".format(CONST.dir_refstack_client,
+ "cd -;".format(CONST.__getattribute__('dir_refstack_client'),
self.confpath,
self.defcorelist))
logger.info("Starting Refstack_defcore test case: '%s'." % cmd)
header = ("Refstack environment:\n"
" SUT: %s\n Scenario: %s\n Node: %s\n Date: %s\n" %
- (CONST.INSTALLER_TYPE,
- CONST.DEPLOY_SCENARIO,
- CONST.NODE_NAME,
+ (CONST.__getattribute__('INSTALLER_TYPE'),
+ CONST.__getattribute__('DEPLOY_SCENARIO'),
+ CONST.__getattribute__('NODE_NAME'),
time.strftime("%a %b %d %H:%M:%S %Z %Y")))
f_stdout = open(
@@ -202,9 +202,9 @@ class RefstackClient(testcase.TestCase):
class RefstackClientParser(object):
def __init__(self):
- self.FUNCTEST_TEST = CONST.dir_functest_test
- self.CONF_PATH = CONST.refstack_tempest_conf_path
- self.DEFCORE_LIST = CONST.refstack_defcore_list
+ self.FUNCTEST_TEST = CONST.__getattribute__('dir_functest_test')
+ self.CONF_PATH = CONST.__getattribute__('refstack_tempest_conf_path')
+ self.DEFCORE_LIST = CONST.__getattribute__('refstack_defcore_list')
self.confpath = os.path.join(self.FUNCTEST_TEST,
self.CONF_PATH)
self.defcorelist = os.path.join(self.FUNCTEST_TEST,
diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
index 5c04253c3..fbaad589e 100755
--- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
+++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
@@ -24,12 +24,14 @@ class TempestConf(object):
self.DEPLOYMENT_ID = conf_utils.get_verifier_deployment_id()
self.DEPLOYMENT_DIR = conf_utils.get_verifier_deployment_dir(
self.VERIFIER_ID, self.DEPLOYMENT_ID)
- self.confpath = os.path.join(CONST.dir_functest_test,
- CONST.refstack_tempest_conf_path)
+ self.confpath = os.path.join(
+ CONST.__getattribute__('dir_functest_test'),
+ CONST.__getattribute__('refstack_tempest_conf_path'))
def generate_tempestconf(self):
try:
- openstack_utils.source_credentials(CONST.openstack_creds)
+ openstack_utils.source_credentials(
+ CONST.__getattribute__('openstack_creds'))
img_flavor_dict = conf_utils.create_tempest_resources(
use_custom_images=True, use_custom_flavors=True)
conf_utils.configure_tempest_defcore(
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index 2f3dd74be..b2b0b77c6 100755
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -108,7 +108,7 @@ class ODLTests(testcase.TestCase):
result.suite.statistics.critical.passed /
result.suite.statistics.critical.total)
except ZeroDivisionError:
- self.__logger.error("No test has been ran")
+ self.__logger.error("No test has been run")
self.start_time = timestamp_to_secs(result.suite.starttime)
self.stop_time = timestamp_to_secs(result.suite.endtime)
self.details = {}
diff --git a/functest/tests/unit/core/test_pytest_suite_runner.py b/functest/tests/unit/core/test_pytest_suite_runner.py
index 07ac79060..f317cdea2 100644
--- a/functest/tests/unit/core/test_pytest_suite_runner.py
+++ b/functest/tests/unit/core/test_pytest_suite_runner.py
@@ -20,29 +20,71 @@ class PyTestSuiteRunnerTesting(unittest.TestCase):
def setUp(self):
self.psrunner = pytest_suite_runner.PyTestSuiteRunner()
- self.result = mock.Mock()
- attrs = {'errors': [('test1', 'error_msg1')],
- 'failures': [('test2', 'failure_msg1')]}
- self.result.configure_mock(**attrs)
-
- self.pass_results = mock.Mock()
- attrs = {'errors': None,
- 'failures': None}
- self.pass_results.configure_mock(**attrs)
-
- def test_run(self):
- self.psrunner.case_name = 'test_case_name'
+
+ @mock.patch('unittest.TestLoader')
+ def _test_run(self, mock_class=None, result=mock.Mock(),
+ status=testcase.TestCase.EX_OK):
with mock.patch('functest.core.pytest_suite_runner.'
'unittest.TextTestRunner.run',
- return_value=self.result):
- self.assertEqual(self.psrunner.run(),
- testcase.TestCase.EX_OK)
+ return_value=result):
+ self.assertEqual(self.psrunner.run(), status)
+ mock_class.assert_not_called()
+
+ def test_check_suite_null(self):
+ self.assertEqual(self.psrunner.suite, None)
+
+ def test_run_no_ut(self):
+ mock_result = mock.Mock(testsRun=0, errors=[], failures=[])
+ self._test_run(result=mock_result,
+ status=testcase.TestCase.EX_RUN_ERROR)
+ self.assertEqual(self.psrunner.result, 0)
+ self.assertEqual(self.psrunner.details, {'errors': [], 'failures': []})
+ self.assertEqual(self.psrunner.is_successful(),
+ testcase.TestCase.EX_TESTCASE_FAILED)
+
+ def test_run_result_ko(self):
+ self.psrunner.criteria = 100
+ mock_result = mock.Mock(testsRun=50, errors=[('test1', 'error_msg1')],
+ failures=[('test2', 'failure_msg1')])
+ self._test_run(result=mock_result)
+ self.assertEqual(self.psrunner.result, 96)
+ self.assertEqual(self.psrunner.details,
+ {'errors': [('test1', 'error_msg1')],
+ 'failures': [('test2', 'failure_msg1')]})
+ self.assertEqual(self.psrunner.is_successful(),
+ testcase.TestCase.EX_TESTCASE_FAILED)
+
+ def test_run_result_ok(self):
+ mock_result = mock.Mock(testsRun=50, errors=[],
+ failures=[])
+ self._test_run(result=mock_result)
+ self.assertEqual(self.psrunner.result, 100)
+ self.assertEqual(self.psrunner.details, {'errors': [], 'failures': []})
+ self.assertEqual(self.psrunner.is_successful(),
+ testcase.TestCase.EX_OK)
+
+ @mock.patch('unittest.TestLoader')
+ def test_run_name_exc(self, mock_class=None):
+ mock_obj = mock.Mock(side_effect=ImportError)
+ mock_class.side_effect = mock_obj
+ self.assertEqual(self.psrunner.run(name='foo'),
+ testcase.TestCase.EX_RUN_ERROR)
+ mock_class.assert_called_once_with()
+ mock_obj.assert_called_once_with()
+ @mock.patch('unittest.TestLoader')
+ def test_run_name(self, mock_class=None):
+ mock_result = mock.Mock(testsRun=50, errors=[],
+ failures=[])
+ mock_obj = mock.Mock()
+ mock_class.side_effect = mock_obj
with mock.patch('functest.core.pytest_suite_runner.'
'unittest.TextTestRunner.run',
- return_value=self.pass_results):
- self.assertEqual(self.psrunner.run(),
+ return_value=mock_result):
+ self.assertEqual(self.psrunner.run(name='foo'),
testcase.TestCase.EX_OK)
+ mock_class.assert_called_once_with()
+ mock_obj.assert_called_once_with()
if __name__ == "__main__":
diff --git a/functest/tests/unit/core/test_vnf.py b/functest/tests/unit/core/test_vnf.py
index e322773ed..ce8590400 100644
--- a/functest/tests/unit/core/test_vnf.py
+++ b/functest/tests/unit/core/test_vnf.py
@@ -146,12 +146,12 @@ class VnfBaseTesting(unittest.TestCase):
def test_deploy_vnf_unimplemented(self):
with self.assertRaises(Exception) as context:
self.test.deploy_vnf()
- self.assertTrue('VNF not deployed' in context.exception)
+ self.assertIn('VNF not deployed', str(context.exception))
def test_test_vnf_unimplemented(self):
with self.assertRaises(Exception) as context:
self.test.test_vnf()()
- self.assertTrue('VNF not tested' in context.exception)
+ self.assertIn('VNF not tested', str(context.exception))
def test_parse_results_ex_ok(self):
self.test.details['test_vnf']['status'] = 'PASS'
diff --git a/functest/tests/unit/features/test_barometer.py b/functest/tests/unit/features/test_barometer.py
index c6512615e..8c2585d9c 100644
--- a/functest/tests/unit/features/test_barometer.py
+++ b/functest/tests/unit/features/test_barometer.py
@@ -16,9 +16,8 @@ import unittest
import mock
from functest.core import testcase
-sys.modules['baro_tests'] = mock.Mock() # noqa
-# pylint: disable=wrong-import-position
-from functest.opnfv_tests.features import barometer
+with mock.patch('functest.utils.functest_utils.get_parameter_from_yaml'):
+ from functest.opnfv_tests.features import barometer
class BarometerTesting(unittest.TestCase):
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 58ec5a072..8c149baa8 100644
--- a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
+++ b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
@@ -17,10 +17,12 @@ from functest.utils.constants import CONST
class OSRefstackClientTesting(unittest.TestCase):
- _config = os.path.join(CONST.dir_functest_test,
- CONST.refstack_tempest_conf_path)
- _testlist = os.path.join(CONST.dir_functest_test,
- CONST.refstack_defcore_list)
+ _config = os.path.join(
+ CONST.__getattribute__('dir_functest_test'),
+ CONST.__getattribute__('refstack_tempest_conf_path'))
+ _testlist = os.path.join(
+ CONST.__getattribute__('dir_functest_test'),
+ CONST.__getattribute__('refstack_defcore_list'))
def setUp(self):
self.defaultargs = {'config': self._config,
@@ -28,12 +30,13 @@ class OSRefstackClientTesting(unittest.TestCase):
self.refstackclient = refstack_client.RefstackClient()
def test_source_venv(self):
- CONST.dir_refstack_client = 'test_repo_dir'
+ CONST.__setattr__('dir_refstack_client', 'test_repo_dir')
with mock.patch('functest.opnfv_tests.openstack.refstack_client.'
'refstack_client.ft_utils.execute_command') as m:
cmd = ("cd {0};"
". .venv/bin/activate;"
- "cd -;".format(CONST.dir_refstack_client))
+ "cd -;"
+ .format(CONST.__getattribute__('dir_refstack_client')))
self.refstackclient.source_venv()
m.assert_any_call(cmd)
@@ -44,9 +47,10 @@ class OSRefstackClientTesting(unittest.TestCase):
'refstack_client.ft_utils.execute_command') as m:
cmd = ("cd {0};"
"./refstack-client test -c {1} -v --test-list {2};"
- "cd -;".format(CONST.dir_refstack_client,
- config,
- testlist))
+ "cd -;"
+ .format(CONST.__getattribute__('dir_refstack_client'),
+ config,
+ testlist))
self.refstackclient.run_defcore(config, testlist)
m.assert_any_call(cmd)
@@ -62,7 +66,7 @@ class OSRefstackClientTesting(unittest.TestCase):
self.assertEqual(self.refstackclient.main(**kwargs), status)
if len(args) > 0:
args[0].assert_called_once_with(
- refstack_client.RefstackClient.result_dir)
+ refstack_client.RefstackClient.result_dir)
if len(args) > 1:
args
diff --git a/functest/tests/unit/test_logging.ini b/functest/tests/unit/test_logging.ini
deleted file mode 100644
index 492767d16..000000000
--- a/functest/tests/unit/test_logging.ini
+++ /dev/null
@@ -1,27 +0,0 @@
-[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_decorators.py b/functest/tests/unit/utils/test_decorators.py
index 6bd47d25c..44448f238 100644
--- a/functest/tests/unit/utils/test_decorators.py
+++ b/functest/tests/unit/utils/test_decorators.py
@@ -63,7 +63,7 @@ class DecoratorsTesting(unittest.TestCase):
'pod_name': self._node_name, 'installer': self._installer_type,
'scenario': self._deploy_scenario, 'version': VERSION,
'details': {}, 'criteria': self._result}
- return json.dumps(data)
+ return json.dumps(data, sort_keys=True)
@mock.patch('{}.get_db_url'.format(functest_utils.__name__),
return_value='http://127.0.0.1')
diff --git a/functest/tests/unit/utils/test_functest_utils.py b/functest/tests/unit/utils/test_functest_utils.py
index 0fe7e91d0..218f7f727 100644
--- a/functest/tests/unit/utils/test_functest_utils.py
+++ b/functest/tests/unit/utils/test_functest_utils.py
@@ -55,7 +55,8 @@ class FunctestUtilsTesting(unittest.TestCase):
self.testcase_dict = {'case_name': 'testname',
'criteria': self.criteria}
self.parameter = 'general.openstack.image_name'
- self.config_yaml = 'test_config_yaml-'
+ self.config_yaml = os.path.normpath(os.path.join(os.path.dirname(
+ os.path.abspath(__file__)), '../../../ci/config_functest.yaml'))
self.db_url_env = 'http://foo/testdb'
self.file_yaml = {'general': {'openstack': {'image_name':
'test_image_name'}}}
diff --git a/functest/utils/env.py b/functest/utils/env.py
index c9629e153..3724ec998 100644
--- a/functest/utils/env.py
+++ b/functest/utils/env.py
@@ -15,7 +15,9 @@ default_envs = {
'INSTALLER_IP': None,
'BUILD_TAG': None,
'OS_ENDPOINT_TYPE': None,
- 'OS_AUTH_URL': None
+ 'OS_AUTH_URL': None,
+ 'CONFIG_FUNCTEST_YAML': os.path.normpath(os.path.join(os.path.dirname(
+ os.path.abspath(__file__)), '../ci/config_functest.yaml'))
}
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py
index bf30f56ee..dc20eea10 100644
--- a/functest/utils/functest_utils.py
+++ b/functest/utils/functest_utils.py
@@ -24,6 +24,7 @@ from six.moves import urllib
import yaml
from git import Repo
+from functest.utils import constants
from functest.utils import decorators
logger = logging.getLogger(__name__)
@@ -220,7 +221,8 @@ def push_results_to_db(project, case_name,
error = None
headers = {'Content-Type': 'application/json'}
try:
- r = requests.post(url, data=json.dumps(params), headers=headers)
+ r = requests.post(url, data=json.dumps(params, sort_keys=True),
+ headers=headers)
logger.debug(r)
r.raise_for_status()
except requests.RequestException as exc:
@@ -375,7 +377,7 @@ def get_parameter_from_yaml(parameter, file):
def get_functest_config(parameter):
- yaml_ = os.environ["CONFIG_FUNCTEST_YAML"]
+ yaml_ = constants.CONST.__getattribute__('CONFIG_FUNCTEST_YAML')
return get_parameter_from_yaml(parameter, yaml_)
@@ -397,7 +399,7 @@ def get_testcases_file_dir():
def get_functest_yaml():
- with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
+ with open(constants.CONST.__getattribute__('CONFIG_FUNCTEST_YAML')) as f:
functest_yaml = yaml.safe_load(f)
f.close()
return functest_yaml
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py
index 8bd950528..57a2aa2be 100644
--- a/functest/utils/openstack_utils.py
+++ b/functest/utils/openstack_utils.py
@@ -1081,10 +1081,10 @@ def check_security_group_rules(neutron_client, sg_id, direction, protocol,
try:
security_rules = get_security_group_rules(neutron_client, sg_id)
security_rules = [rule for rule in security_rules
- if (rule["direction"].lower() == direction
- and rule["protocol"].lower() == protocol
- and rule["port_range_min"] == port_min
- and rule["port_range_max"] == port_max)]
+ if (rule["direction"].lower() == direction and
+ rule["protocol"].lower() == protocol and
+ rule["port_range_min"] == port_min and
+ rule["port_range_max"] == port_max)]
if len(security_rules) == 0:
return True
else:
diff --git a/requirements.py3.txt b/requirements.py3.txt
new file mode 100644
index 000000000..6a003d532
--- /dev/null
+++ b/requirements.py3.txt
@@ -0,0 +1,39 @@
+#
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+pyyaml==3.10
+gitpython==1.0.1
+python-openstackclient==2.3.0
+python-ceilometerclient==2.6.2
+python-heatclient==1.7.0
+python-keystoneclient==3.5.0
+python-neutronclient==6.0.0
+python-novaclient==6.0.0
+python-congressclient==1.5.0
+python-tackerclient==0.7.0
+pexpect==4.0
+requests==2.9.1
+robotframework==3.0.2
+robotframework-httplibrary==0.4.2
+robotframework-requests==0.4.7
+jmespath==0.9.2
+configObj==5.0.6
+Flask==0.10.1
+xmltodict==0.9.2
+scp==0.10.2
+paramiko==2.1.2
+shyaml
+dnspython
+Pillow==3.3.0
+click==6.6
+openbaton-cli==2.2.1-beta7
+mock==1.3.0
+iniparse==0.4
+PrettyTable>=0.7.1,<0.8 # BSD
+six>=1.9.0 # MIT
+git+https://gerrit.opnfv.org/gerrit/releng#egg=opnfv&subdirectory=modules
+git+https://gerrit.opnfv.org/gerrit/barometer#egg=baro_tests
diff --git a/requirements.txt b/requirements.txt
index 65b369799..059775deb 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -16,7 +16,7 @@ python-novaclient==6.0.0
python-congressclient==1.5.0
python-tackerclient==0.7.0
pexpect==4.0
-requests>=2.8.0
+requests==2.9.1
robotframework==3.0.2
robotframework-httplibrary==0.4.2
robotframework-requests==0.4.7
@@ -37,3 +37,5 @@ mock==1.3.0
iniparse==0.4
PrettyTable>=0.7.1,<0.8 # BSD
six>=1.9.0 # MIT
+git+https://gerrit.opnfv.org/gerrit/releng#egg=opnfv&subdirectory=modules
+git+https://gerrit.opnfv.org/gerrit/barometer#egg=baro_tests
diff --git a/run_unit_tests.sh b/run_unit_tests.sh
deleted file mode 100755
index 86096fabf..000000000
--- a/run_unit_tests.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/bash
-set -o errexit
-set -o pipefail
-
-# Either Workspace is set (CI)
-if [ -z $WORKSPACE ]
-then
- WORKSPACE=`pwd`
-fi
-
-
-# ***************
-# Run unit tests
-# ***************
-echo "Running unit tests..."
-
-sudo apt-get install -y build-essential python-dev python-pip
-sudo pip install virtualenv==15.1.0
-
-# start vitual env
-virtualenv $WORKSPACE/functest_venv
-source $WORKSPACE/functest_venv/bin/activate
-
-# install python packages
-pip install --upgrade pip
-pip install -r $WORKSPACE/requirements.txt
-pip install -r $WORKSPACE/test-requirements.txt
-pip install $WORKSPACE
-
-#install releng
-rm -rf releng-unittests
-git clone --depth 1 https://gerrit.opnfv.org/gerrit/releng releng-unittests
-pip install releng-unittests/modules/
-rm -fr releng-unittests
-
-export CONFIG_FUNCTEST_YAML=$(pwd)/functest/ci/config_functest.yaml
-nosetests --with-xunit \
- --with-coverage \
- --cover-tests \
- --cover-package=functest \
- --cover-xml \
- --cover-html \
- --log-config=$(pwd)/functest/tests/unit/test_logging.ini \
- functest/tests/unit
-rc=$?
-
-deactivate
-
-exit $rc
diff --git a/test-requirements.txt b/test-requirements.txt
index b0d4ff8d1..9fe4bc749 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -8,3 +8,6 @@
coverage==4.1
mock==1.3.0
nose==1.3.7
+flake8>=2.5.4,<2.6.0 # MIT
+pylint==1.4.5 # GPLv2
+sphinx!=1.6.1,>=1.5.1 # BSD
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 000000000..bde3a9757
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,43 @@
+[tox]
+envlist = docs,pep8,pylint,py35,py27
+
+[testenv]
+usedevelop = True
+deps =
+ -r{toxinidir}/requirements.txt
+ -r{toxinidir}/test-requirements.txt
+commands = nosetests --with-xunit \
+ --with-coverage \
+ --cover-tests \
+ --cover-package=functest \
+ --cover-xml \
+ --cover-html \
+ functest/tests/unit
+
+[testenv:docs]
+basepython = python2.7
+commands = sphinx-build -W -b html docs/api/ docs/api/_build
+
+[testenv:pep8]
+basepython = python2.7
+deps =
+ {[testenv]deps}
+commands = flake8
+
+[testenv:pylint]
+basepython = python2.7
+deps =
+ {[testenv]deps}
+whitelist_externals = bash
+commands = bash -c \
+ "pylint --persistent=n functest | sed -ne '/Raw metrics/,//p'"
+
+[testenv:py35]
+dirs =
+ functest/tests/unit/core
+ functest/tests/unit/odl
+ functest/tests/unit/utils/test_decorators.py
+deps =
+ -r{toxinidir}/requirements.py3.txt
+ -r{toxinidir}/test-requirements.txt
+commands = nosetests {[testenv:py35]dirs}