From d24f5aa6e035382a1fdf015ffd4d35033ef4903a 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 --- zun_tempest_plugin/tests/tempest/README.rst | 17 ++++++++ zun_tempest_plugin/tests/tempest/__init__.py | 0 .../tests/tempest/api/__init__.py | 0 .../tests/tempest/api/test_basic.py | 24 +++++++++++ zun_tempest_plugin/tests/tempest/base.py | 37 +++++++++++++++++ zun_tempest_plugin/tests/tempest/config.py | 36 +++++++++++++++++ zun_tempest_plugin/tests/tempest/plugin.py | 40 +++++++++++++++++++ 7 files changed, 154 insertions(+) create mode 100644 zun_tempest_plugin/tests/tempest/README.rst create mode 100644 zun_tempest_plugin/tests/tempest/__init__.py create mode 100644 zun_tempest_plugin/tests/tempest/api/__init__.py create mode 100644 zun_tempest_plugin/tests/tempest/api/test_basic.py create mode 100644 zun_tempest_plugin/tests/tempest/base.py create mode 100644 zun_tempest_plugin/tests/tempest/config.py create mode 100644 zun_tempest_plugin/tests/tempest/plugin.py diff --git a/zun_tempest_plugin/tests/tempest/README.rst b/zun_tempest_plugin/tests/tempest/README.rst new file mode 100644 index 0000000..4dc0e5c --- /dev/null +++ b/zun_tempest_plugin/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_tempest_plugin/tests/tempest/__init__.py b/zun_tempest_plugin/tests/tempest/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/zun_tempest_plugin/tests/tempest/api/__init__.py b/zun_tempest_plugin/tests/tempest/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/zun_tempest_plugin/tests/tempest/api/test_basic.py b/zun_tempest_plugin/tests/tempest/api/test_basic.py new file mode 100644 index 0000000..ab0c188 --- /dev/null +++ b/zun_tempest_plugin/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_tempest_plugin/tests/tempest/base.py b/zun_tempest_plugin/tests/tempest/base.py new file mode 100644 index 0000000..4de22e3 --- /dev/null +++ b/zun_tempest_plugin/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_tempest_plugin/tests/tempest/config.py b/zun_tempest_plugin/tests/tempest/config.py new file mode 100644 index 0000000..21b53f2 --- /dev/null +++ b/zun_tempest_plugin/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_tempest_plugin/tests/tempest/plugin.py b/zun_tempest_plugin/tests/tempest/plugin.py new file mode 100644 index 0000000..b8edd6a --- /dev/null +++ b/zun_tempest_plugin/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)]