From 5221ce3ffffca1a4a1f59ca1c9b7504867f7c9b6 Mon Sep 17 00:00:00 2001 From: yanyanhu Date: Fri, 17 Jun 2016 04:21:02 -0400 Subject: [PATCH] Initial work for zun tempest plugin This patch does some initial work for zun tempest plugin support. Since zun API design/implementation will come soon, tempest API test will be helpful to verify its correctness. Co-Authored-By: Ethan Lynn Change-Id: Iabc8429285150857fb9791dea8a5471e2995e17b --- setup.cfg | 2 ++ test-requirements.txt | 1 + zun/tests/tempest/README.rst | 17 ++++++++++++ zun/tests/tempest/__init__.py | 0 zun/tests/tempest/api/__init__.py | 0 zun/tests/tempest/api/test_basic.py | 24 +++++++++++++++++ zun/tests/tempest/base.py | 37 ++++++++++++++++++++++++++ zun/tests/tempest/config.py | 36 ++++++++++++++++++++++++++ zun/tests/tempest/plugin.py | 40 +++++++++++++++++++++++++++++ 9 files changed, 157 insertions(+) create mode 100644 zun/tests/tempest/README.rst create mode 100644 zun/tests/tempest/__init__.py create mode 100644 zun/tests/tempest/api/__init__.py create mode 100644 zun/tests/tempest/api/test_basic.py create mode 100644 zun/tests/tempest/base.py create mode 100644 zun/tests/tempest/config.py create mode 100644 zun/tests/tempest/plugin.py diff --git a/setup.cfg b/setup.cfg index bb849879c..288fcd95b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -56,3 +56,5 @@ oslo.config.opts = zun.database.migration_backend = sqlalchemy = zun.db.sqlalchemy.migration +tempest.test_plugins = + zun_tests = zun.tests.tempest.plugin:ZunTempestPlugin diff --git a/test-requirements.txt b/test-requirements.txt index eacd1c7da..952a86286 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -14,6 +14,7 @@ sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2 # BSD oslosphinx!=3.4.0,>=2.5.0 # Apache-2.0 oslotest>=1.10.0 # Apache-2.0 os-testr>=0.7.0 # Apache-2.0 +tempest>=11.0.0 # Apache-2.0 testrepository>=0.0.18 # Apache-2.0/BSD testscenarios>=0.4 # Apache-2.0/BSD testtools>=1.4.0 # MIT diff --git a/zun/tests/tempest/README.rst b/zun/tests/tempest/README.rst new file mode 100644 index 000000000..4dc0e5c97 --- /dev/null +++ b/zun/tests/tempest/README.rst @@ -0,0 +1,17 @@ +============== +Tempest Plugin +============== + +This directory contains Tempest tests to cover Zun project. + +To list all Zun tempest cases, go to tempest directory, then run:: + + $ testr list-tests zun + +To run only these tests in tempest, go to tempest directory, then run:: + + $ ./run_tempest.sh -N -- zun + +To run a single test case, go to tempest directory, then run with test case name, e.g.:: + + $ ./run_tempest.sh -- -N zun.tests.tempest.api.test_basic.TestBasic.test_basic diff --git a/zun/tests/tempest/__init__.py b/zun/tests/tempest/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/zun/tests/tempest/api/__init__.py b/zun/tests/tempest/api/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/zun/tests/tempest/api/test_basic.py b/zun/tests/tempest/api/test_basic.py new file mode 100644 index 000000000..ab0c188e0 --- /dev/null +++ b/zun/tests/tempest/api/test_basic.py @@ -0,0 +1,24 @@ +# 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.lib import decorators + +from zun.tests.tempest import base + + +class TestBasic(base.BaseZunTest): + + @decorators.idempotent_id('a04f61f2-15ae-4200-83b7-1f311b101f65') + def test_basic(self): + # This is a basic test used to verify zun tempest plugin + # works. Remove it after real test cases being added. + pass diff --git a/zun/tests/tempest/base.py b/zun/tests/tempest/base.py new file mode 100644 index 000000000..4de22e379 --- /dev/null +++ b/zun/tests/tempest/base.py @@ -0,0 +1,37 @@ +# +# 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 +from tempest import config +from tempest import test + +CONF = config.CONF +lOG = log.getLogger(__name__) + + +class BaseZunTest(test.BaseTestCase): + + credentials = ['primary'] + + @classmethod + def skip_checks(cls): + super(BaseZunTest, cls).skip_checks() + if not CONF.service_available.zun: + skip_msg = 'Zun is disabled' + raise cls.skipException(skip_msg) + + @classmethod + def setup_clients(cls): + super(BaseZunTest, cls).setup_clients() + pass diff --git a/zun/tests/tempest/config.py b/zun/tests/tempest/config.py new file mode 100644 index 000000000..21b53f252 --- /dev/null +++ b/zun/tests/tempest/config.py @@ -0,0 +1,36 @@ +# +# 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_config import cfg + + +service_available_group = cfg.OptGroup(name="service_available", + title="Available OpenStack Services") + +ServiceAvailableGroup = [ + cfg.BoolOpt("zun", + default=True, + help="Whether or not zun is expected to be available"), +] + +container_management_group = cfg.OptGroup( + name="container_management", title="Container Management Service Options") + +ContainerManagementGroup = [ + cfg.StrOpt("catalog_type", + default="container_management", + help="Catalog type of the container management service."), + cfg.IntOpt("wait_timeout", + default=60, + help="Waiting time for a specific status, in seconds.") +] diff --git a/zun/tests/tempest/plugin.py b/zun/tests/tempest/plugin.py new file mode 100644 index 000000000..b8edd6a09 --- /dev/null +++ b/zun/tests/tempest/plugin.py @@ -0,0 +1,40 @@ +# +# 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 +from tempest.test_discover import plugins + +from zun.tests.tempest import config as config_zun + + +class ZunTempestPlugin(plugins.TempestPlugin): + def load_tests(self): + base_path = os.path.split(os.path.dirname( + os.path.abspath(__file__)))[0] + base_path += '/../..' + test_dir = "zun/tests/tempest" + full_test_dir = os.path.join(base_path, test_dir) + return full_test_dir, base_path + + def register_opts(self, conf): + config.register_opt_group(conf, config_zun.service_available_group, + config_zun.ServiceAvailableGroup) + config.register_opt_group(conf, config_zun.container_management_group, + config_zun.ContainerManagementGroup) + + def get_opt_lists(self): + return [(config_zun.container_management_group.name, + config_zun.ContainerManagementGroup)]