From c8f3a65549880472f5b59a40b846c0d6cd68f673 Mon Sep 17 00:00:00 2001 From: Chaoyi Huang Date: Sat, 28 May 2016 09:57:24 +0800 Subject: [PATCH] Add the Tricircle tempest plugin with a sample test case 1.What is the purpose of this patch set? The Tricircle project doesn't provide integration test yet. To achieve integration test, the Tricircle needs to provide Tempest plugin, so that the integration test job could be configured in CI pipeline. Tempest is a set of integration tests to be run against a live OpenStack cluster: http://docs.openstack.org/developer/tempest/overview.html Tempest has an external test plugin interface which enables project to integrate an external test suite as part of a tempest run. http://docs.openstack.org/developer/tempest/plugin.html This patch set is to create the Tricircle tempest plugin with a sample test case. And main purpose of the patch set is to make tempest enable to discover the Tricircle tempest plugin and its test case. 2.What is the benefit of this patch set for the Tricircle project? Make the Tricircle tempest plugin being able to be discovered by Tempest, and support later integration test job. 3.What is the platform you tested it out? It will work on all linux distribution including python venv, docker container are available. The procedure to make discovering processes are as follows: Install the Tricircle after the patch merged (the Tricircle tempest plugin and the sample tempest test case will be installed together for they are in the same repository): 1. git clone https://github.com/openstack/tricircle.git 2. sudo pip install -e tricircle/ Install the Tempest in another folder in order to avoid the python import error: 1. git clone https://github.com/openstack/tempest.git 2. sudo pip install -e tempest/ Then run testr in tempest folder to see if the test case of the Tricircle has been discovered: 1. cd tempest/ 2. testr list-tests | grep Tricircle The Tricircle devstack plugin is also updated with the Tricircle package installation in order to simplify the tempest discovering processes. Change-Id: I977c23f5e55e3ee062190fa9d5e6472e5d5acb33 Signed-off-by: Chaoyi Huang --- .testr.conf | 2 +- devstack/plugin.sh | 2 + setup.cfg | 3 ++ tox.ini | 3 +- tricircle/tempestplugin/README.rst | 6 +++ tricircle/tempestplugin/__init__.py | 0 tricircle/tempestplugin/config.py | 16 ++++++++ tricircle/tempestplugin/plugin.py | 38 +++++++++++++++++++ tricircle/tempestplugin/services/__init__.py | 0 tricircle/tempestplugin/tests/__init__.py | 0 tricircle/tempestplugin/tests/api/__init__.py | 0 tricircle/tempestplugin/tests/api/base.py | 29 ++++++++++++++ .../tempestplugin/tests/api/test_sample.py | 32 ++++++++++++++++ .../tempestplugin/tests/scenario/__init__.py | 0 14 files changed, 129 insertions(+), 2 deletions(-) create mode 100644 tricircle/tempestplugin/README.rst create mode 100644 tricircle/tempestplugin/__init__.py create mode 100644 tricircle/tempestplugin/config.py create mode 100644 tricircle/tempestplugin/plugin.py create mode 100644 tricircle/tempestplugin/services/__init__.py create mode 100644 tricircle/tempestplugin/tests/__init__.py create mode 100644 tricircle/tempestplugin/tests/api/__init__.py create mode 100644 tricircle/tempestplugin/tests/api/base.py create mode 100644 tricircle/tempestplugin/tests/api/test_sample.py create mode 100644 tricircle/tempestplugin/tests/scenario/__init__.py diff --git a/.testr.conf b/.testr.conf index 6d83b3c..43200f9 100644 --- a/.testr.conf +++ b/.testr.conf @@ -2,6 +2,6 @@ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \ OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \ OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \ - ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION + ${PYTHON:-python} -m subunit.run discover $TRICIRCLE_TEST_DIRECTORY $LISTOPT $IDOPTION test_id_option=--load-list $IDFILE test_list_option=--list diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 043ee61..18f4638 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -257,6 +257,8 @@ if [[ "$Q_ENABLE_TRICIRCLE" == "True" ]]; then echo export PYTHONPATH=\$PYTHONPATH:$TRICIRCLE_DIR >> $RC_DIR/.localrc.auto + setup_package $TRICIRCLE_DIR -e + recreate_database tricircle python "$TRICIRCLE_DIR/cmd/manage.py" "$TRICIRCLE_API_CONF" diff --git a/setup.cfg b/setup.cfg index 64bd491..b4c7d49 100644 --- a/setup.cfg +++ b/setup.cfg @@ -55,3 +55,6 @@ oslo.config.opts = tricircle.nova_apigw = tricircle.nova_apigw.opts:list_opts tricircle.cinder_apigw = tricircle.cinder_apigw.opts:list_opts tricircle.xjob = tricircle.xjob.opts:list_opts + +tempest.test_plugins = + tricircle_tests = tricircle.tempestplugin.plugin:TricircleTempestPlugin diff --git a/tox.ini b/tox.ini index 8fb6218..cb01053 100644 --- a/tox.ini +++ b/tox.ini @@ -9,10 +9,11 @@ usedevelop = True install_command = pip install -U --force-reinstall {opts} {packages} setenv = VIRTUAL_ENV={envdir} + TRICIRCLE_TEST_DIRECTORY=tricircle/tests deps = -r{toxinidir}/test-requirements.txt -egit+https://git.openstack.org/openstack/neutron@master#egg=neutron -commands = python setup.py testr --slowest --testr-args='{posargs}' +commands = python setup.py testr --slowest --testr-args='{posargs}' whitelist_externals = rm [testenv:pep8] diff --git a/tricircle/tempestplugin/README.rst b/tricircle/tempestplugin/README.rst new file mode 100644 index 0000000..8668a70 --- /dev/null +++ b/tricircle/tempestplugin/README.rst @@ -0,0 +1,6 @@ +=============================================== +Tempest Integration of Tricircle +=============================================== + +This directory contains Tempest tests to cover the Tricircle project. + diff --git a/tricircle/tempestplugin/__init__.py b/tricircle/tempestplugin/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tricircle/tempestplugin/config.py b/tricircle/tempestplugin/config.py new file mode 100644 index 0000000..51e4b7e --- /dev/null +++ b/tricircle/tempestplugin/config.py @@ -0,0 +1,16 @@ +# Copyright 2016 Huawei Technologies Co., Ltd. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from tricircle.common import config as t_config # noqa diff --git a/tricircle/tempestplugin/plugin.py b/tricircle/tempestplugin/plugin.py new file mode 100644 index 0000000..ec832af --- /dev/null +++ b/tricircle/tempestplugin/plugin.py @@ -0,0 +1,38 @@ +# Copyright 2015 +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import os + +from tempest import config # noqa +from tempest.test_discover import plugins + +from tricircle.tests.tempestplugin import config as project_config # noqa + + +class TricircleTempestPlugin(plugins.TempestPlugin): + + def load_tests(self): + base_path = os.path.split(os.path.dirname( + os.path.abspath(__file__)))[0] + test_dir = "tempestplugin/tests" + full_test_dir = os.path.join(base_path, test_dir) + return full_test_dir, base_path + + def register_opts(self, conf): + pass + + def get_opt_lists(self): + pass diff --git a/tricircle/tempestplugin/services/__init__.py b/tricircle/tempestplugin/services/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tricircle/tempestplugin/tests/__init__.py b/tricircle/tempestplugin/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tricircle/tempestplugin/tests/api/__init__.py b/tricircle/tempestplugin/tests/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tricircle/tempestplugin/tests/api/base.py b/tricircle/tempestplugin/tests/api/base.py new file mode 100644 index 0000000..7e093e0 --- /dev/null +++ b/tricircle/tempestplugin/tests/api/base.py @@ -0,0 +1,29 @@ +# Copyright (c) 2016 Huawei Technologies Co., Ltd. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from oslo_log import log as logging + +from tempest import config +from tempest import test + +CONF = config.CONF +LOG = logging.getLogger(__name__) + + +class BaseTricircleTest(test.BaseTestCase): + + @classmethod + def skip_checks(cls): + pass diff --git a/tricircle/tempestplugin/tests/api/test_sample.py b/tricircle/tempestplugin/tests/api/test_sample.py new file mode 100644 index 0000000..397f181 --- /dev/null +++ b/tricircle/tempestplugin/tests/api/test_sample.py @@ -0,0 +1,32 @@ +# Copyright (c) 2016 Huawei Technologies Co., Ltd. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from tempest import test +from tricircle.tempestplugin.tests.api import base + + +class TestTricircleSample(base.BaseTricircleTest): + + @classmethod + def resource_setup(cls): + super(TestTricircleSample, cls).resource_setup() + + @test.attr(type="smoke") + def test_sample(self): + self.assertEqual('Tricircle Sample Test!', 'Tricircle Sample Test!') + + @classmethod + def resource_cleanup(cls): + super(TestTricircleSample, cls).resource_cleanup() diff --git a/tricircle/tempestplugin/tests/scenario/__init__.py b/tricircle/tempestplugin/tests/scenario/__init__.py new file mode 100644 index 0000000..e69de29