From dbcae9d07be758e2fbb14f6f8dcd3d131c7fbd19 Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Wed, 28 Feb 2018 18:46:13 +0100 Subject: Switch from /home/opnfv/functest to /var/lib/xtesting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Functest containers will have to create symlinks to allow publishing artifacts. All classes create the mandatory dirs. Change-Id: Ia1f215005d553dd6d64685e4d8a3f5c843c5db7a Signed-off-by: Cédric Ollivier --- docker/Dockerfile | 3 +-- xtesting/ci/logging.ini | 2 +- xtesting/ci/run_tests.py | 8 ++++++++ xtesting/ci/testcases.yaml | 1 + xtesting/core/feature.py | 2 +- xtesting/core/robotframework.py | 2 +- xtesting/tests/unit/core/test_feature.py | 2 +- xtesting/tests/unit/core/test_robotframework.py | 2 ++ xtesting/utils/constants.py | 2 +- 9 files changed, 17 insertions(+), 7 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 857ae6ce..4d0fe00f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -10,6 +10,5 @@ RUN apk --no-cache add --update python py-pip bash git && \ -chttps://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=$OPENSTACK_TAG \ -chttps://git.opnfv.org/functest-xtesting/plain/upper-constraints.txt?h=$BRANCH \ /src/functest-xtesting && \ - rm -r /src/functest-xtesting && \ - bash -c "mkdir -p /home/opnfv/xtesting/results/robot" + rm -r /src/functest-xtesting CMD ["run_tests", "-t", "all"] diff --git a/xtesting/ci/logging.ini b/xtesting/ci/logging.ini index b1365f1e..fc011ad6 100644 --- a/xtesting/ci/logging.ini +++ b/xtesting/ci/logging.ini @@ -58,7 +58,7 @@ args=(sys.stdout,) class=FileHandler level=DEBUG formatter=standard -args=("/home/opnfv/xtesting/results/xtesting.log",) +args=("/var/lib/xtesting/results/xtesting.log",) [formatter_standard] format=%(asctime)s - %(name)s - %(levelname)s - %(message)s diff --git a/xtesting/ci/run_tests.py b/xtesting/ci/run_tests.py index 5c9143a3..8c32ee12 100644 --- a/xtesting/ci/run_tests.py +++ b/xtesting/ci/run_tests.py @@ -14,6 +14,7 @@ """ import argparse +import errno import importlib import logging import logging.config @@ -25,6 +26,7 @@ import pkg_resources import enum import prettytable +import six import yaml from xtesting.ci import tier_builder @@ -293,6 +295,12 @@ class Runner(object): def main(): """Entry point""" + try: + os.makedirs('/var/lib/xtesting/results/') + except OSError as ex: + if ex.errno != errno.EEXIST: + six.print_("Cannot create /var/lib/xtesting/results/") + return testcase.TestCase.EX_RUN_ERROR logging.config.fileConfig(pkg_resources.resource_filename( 'xtesting', 'ci/logging.ini')) logging.captureWarnings(True) diff --git a/xtesting/ci/testcases.yaml b/xtesting/ci/testcases.yaml index 9c1cb506..42e71936 100644 --- a/xtesting/ci/testcases.yaml +++ b/xtesting/ci/testcases.yaml @@ -69,6 +69,7 @@ tiers: - case_name: fifth project_name: xtesting + enabled: false criteria: 100 blocking: false description: '' diff --git a/xtesting/core/feature.py b/xtesting/core/feature.py index d3f86c02..8474b8a4 100644 --- a/xtesting/core/feature.py +++ b/xtesting/core/feature.py @@ -27,7 +27,7 @@ class Feature(testcase.TestCase): """Base model for single feature.""" __logger = logging.getLogger(__name__) - dir_results = "/home/opnfv/xtesting/results" + dir_results = "/var/lib/xtesting/results" def __init__(self, **kwargs): super(Feature, self).__init__(**kwargs) diff --git a/xtesting/core/robotframework.py b/xtesting/core/robotframework.py index 4d3746aa..cc6020a2 100644 --- a/xtesting/core/robotframework.py +++ b/xtesting/core/robotframework.py @@ -53,7 +53,7 @@ class RobotFramework(testcase.TestCase): """RobotFramework runner.""" __logger = logging.getLogger(__name__) - dir_results = "/home/opnfv/xtesting/results" + dir_results = "/var/lib/xtesting/results" def __init__(self, **kwargs): self.res_dir = os.path.join(self.dir_results, 'robot') diff --git a/xtesting/tests/unit/core/test_feature.py b/xtesting/tests/unit/core/test_feature.py index 9bbe5331..3d3b66d3 100644 --- a/xtesting/tests/unit/core/test_feature.py +++ b/xtesting/tests/unit/core/test_feature.py @@ -24,7 +24,7 @@ class FeatureTestingBase(unittest.TestCase): _project_name = "bar" _repo = "dir_repo_bar" _cmd = "run_bar_tests.py" - _output_file = '/home/opnfv/xtesting/results/foo.log' + _output_file = '/var/lib/xtesting/results/foo.log' feature = None @mock.patch('time.time', side_effect=[1, 2]) diff --git a/xtesting/tests/unit/core/test_robotframework.py b/xtesting/tests/unit/core/test_robotframework.py index 7131b7e2..93111f38 100644 --- a/xtesting/tests/unit/core/test_robotframework.py +++ b/xtesting/tests/unit/core/test_robotframework.py @@ -169,6 +169,7 @@ class RunTesting(unittest.TestCase): self._test_makedirs() args[0].assert_called_once_with(self.test.res_dir) + @mock.patch('os.makedirs') @mock.patch('robot.run') def _test_parse_results(self, status, *args): self.assertEqual( @@ -180,6 +181,7 @@ class RunTesting(unittest.TestCase): *self.suites, log='NONE', output=self.test.xml_file, report='NONE', stdout=mock.ANY, variable=self.variable, variablefile=self.variablefile) + args[1].assert_called_once_with(self.test.res_dir) def test_parse_results_exc(self): with mock.patch.object(self.test, 'parse_results', diff --git a/xtesting/utils/constants.py b/xtesting/utils/constants.py index dae08ca6..18e03f68 100644 --- a/xtesting/utils/constants.py +++ b/xtesting/utils/constants.py @@ -2,4 +2,4 @@ # pylint: disable=missing-docstring -ENV_FILE = '/home/opnfv/xtesting/conf/env_file' +ENV_FILE = '/var/lib/xtesting/conf/env_file' -- cgit 1.2.3-korg