From 541baee572addf34df2cbfb1ca60167e9799422c Mon Sep 17 00:00:00 2001 From: Deklan Dieterly Date: Wed, 2 Mar 2016 11:29:26 -0700 Subject: [PATCH] Introduce tempest tests Start to introduce tempest tests. See if gate job executes first test. Change-Id: Id55daec07f6a99a08cb1433807b7b5c5ed2db3f8 --- devstack/settings | 3 ++ .../freezer_api_tempest_plugin/README.rst | 6 +++ .../freezer_api_tempest_plugin/__init__.py | 0 .../freezer_api_tempest_plugin/config.py | 26 +++++++++++++ .../freezer_api_tempest_plugin/plugin.py | 38 +++++++++++++++++++ .../services/__init__.py | 0 .../tests/__init__.py | 0 .../tests/api/__init__.py | 0 .../tests/api/base.py | 18 +++++++++ .../tests/api/test_api_version.py | 23 +++++++++++ .../tests/scenario/__init__.py | 0 setup.cfg | 3 ++ test-requirements.txt | 3 ++ 13 files changed, 120 insertions(+) create mode 100644 freezer_api/tests/freezer_api_tempest_plugin/README.rst create mode 100644 freezer_api/tests/freezer_api_tempest_plugin/__init__.py create mode 100644 freezer_api/tests/freezer_api_tempest_plugin/config.py create mode 100644 freezer_api/tests/freezer_api_tempest_plugin/plugin.py create mode 100644 freezer_api/tests/freezer_api_tempest_plugin/services/__init__.py create mode 100644 freezer_api/tests/freezer_api_tempest_plugin/tests/__init__.py create mode 100644 freezer_api/tests/freezer_api_tempest_plugin/tests/api/__init__.py create mode 100644 freezer_api/tests/freezer_api_tempest_plugin/tests/api/base.py create mode 100644 freezer_api/tests/freezer_api_tempest_plugin/tests/api/test_api_version.py create mode 100644 freezer_api/tests/freezer_api_tempest_plugin/tests/scenario/__init__.py diff --git a/devstack/settings b/devstack/settings index 619ceb73..cea1fc4c 100644 --- a/devstack/settings +++ b/devstack/settings @@ -33,3 +33,6 @@ FREEZER_API_SERVICE_PROTOCOL=http FREEZER_API_PORT=9090 enable_service freezer-api + +# Tell Tempest this project is present +TEMPEST_SERVICES+=,freezer-api diff --git a/freezer_api/tests/freezer_api_tempest_plugin/README.rst b/freezer_api/tests/freezer_api_tempest_plugin/README.rst new file mode 100644 index 00000000..97983de1 --- /dev/null +++ b/freezer_api/tests/freezer_api_tempest_plugin/README.rst @@ -0,0 +1,6 @@ +=============================================== +Tempest Integration of Sample +=============================================== + +This directory contains Tempest tests to cover the Sample project. + diff --git a/freezer_api/tests/freezer_api_tempest_plugin/__init__.py b/freezer_api/tests/freezer_api_tempest_plugin/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/freezer_api/tests/freezer_api_tempest_plugin/config.py b/freezer_api/tests/freezer_api_tempest_plugin/config.py new file mode 100644 index 00000000..5f5602fe --- /dev/null +++ b/freezer_api/tests/freezer_api_tempest_plugin/config.py @@ -0,0 +1,26 @@ +# 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. + +from oslo_config import cfg + + +service_available_group = cfg.OptGroup(name="service_available", + title="Available OpenStack Services") + +ServiceAvailableGroup = [ + cfg.BoolOpt("freezer-api", + default=True, + help="Whether or not Freezer API is expected to be available"), +] \ No newline at end of file diff --git a/freezer_api/tests/freezer_api_tempest_plugin/plugin.py b/freezer_api/tests/freezer_api_tempest_plugin/plugin.py new file mode 100644 index 00000000..96c8ea7e --- /dev/null +++ b/freezer_api/tests/freezer_api_tempest_plugin/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 +from tempest.test_discover import plugins + +from freezer_api.tests.freezer_api_tempest_plugin import config as freezer_api_config + +class FreezerApiTempestPlugin(plugins.TempestPlugin): + def load_tests(self): + base_path = os.path.split(os.path.dirname( + os.path.abspath(__file__)))[0] + test_dir = "freezer_api_tempest_plugin/tests" + 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, freezer_api_config.service_available_group, + freezer_api_config.ServiceAvailableGroup) + + def get_opt_lists(self): + pass \ No newline at end of file diff --git a/freezer_api/tests/freezer_api_tempest_plugin/services/__init__.py b/freezer_api/tests/freezer_api_tempest_plugin/services/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/freezer_api/tests/freezer_api_tempest_plugin/tests/__init__.py b/freezer_api/tests/freezer_api_tempest_plugin/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/freezer_api/tests/freezer_api_tempest_plugin/tests/api/__init__.py b/freezer_api/tests/freezer_api_tempest_plugin/tests/api/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/freezer_api/tests/freezer_api_tempest_plugin/tests/api/base.py b/freezer_api/tests/freezer_api_tempest_plugin/tests/api/base.py new file mode 100644 index 00000000..44005486 --- /dev/null +++ b/freezer_api/tests/freezer_api_tempest_plugin/tests/api/base.py @@ -0,0 +1,18 @@ +# (C) Copyright 2016 Hewlett Packard Enterprise Development Company LP +# +# 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 tempest.test + +class BaseFreezerApiTest(tempest.test.BaseTestCase): + pass \ No newline at end of file diff --git a/freezer_api/tests/freezer_api_tempest_plugin/tests/api/test_api_version.py b/freezer_api/tests/freezer_api_tempest_plugin/tests/api/test_api_version.py new file mode 100644 index 00000000..044542cd --- /dev/null +++ b/freezer_api/tests/freezer_api_tempest_plugin/tests/api/test_api_version.py @@ -0,0 +1,23 @@ +# (C) Copyright 2016 Hewlett Packard Enterprise Development Company LP +# +# 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 freezer_api.tests.freezer_api_tempest_plugin.tests.api import base +from tempest import test + +class TestFreezerApiVersion(base.BaseFreezerApiTest): + + @test.attr(type="gate") + def test_api_version(self): + # See if tempest plugin tests run. + self.assertEqual(1, 1, 'First test case') \ No newline at end of file diff --git a/freezer_api/tests/freezer_api_tempest_plugin/tests/scenario/__init__.py b/freezer_api/tests/freezer_api_tempest_plugin/tests/scenario/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/setup.cfg b/setup.cfg index 13995018..0b108f1f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -45,6 +45,9 @@ all_files = 1 console_scripts = freezer-api = freezer_api.cmd.api:main freezer-db-init = freezer_api.cmd.db_init:main +tempest.test_plugins = + freezer_api_tempest_tests = freezer_api.tests.freezer_api_tempest_plugin.plugin:FreezerApiTempestPlugin + [pytests] where=tests diff --git a/test-requirements.txt b/test-requirements.txt index 6f71154d..777fcf5f 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -10,3 +10,6 @@ python-subunit>=0.0.18 # Apache-2.0/BSD sphinx>=1.1.2,!=1.2.0,!=1.3b1,<1.3 # BSD testrepository>=0.0.18 # Apache-2.0/BSD testtools>=1.4.0 # MIT + +# Tempest Plugin +tempest-lib>=0.14.0 # Apache-2.0