From 1ea561c3c84c1e4750ec4f9000400e52c14805f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Fri, 25 Nov 2016 16:37:53 -0500 Subject: [PATCH] Add first tempest test - First functional test for the API endpoint /info - Move all unit tests to almanach.tests.unit like other OpenStack projects Change-Id: I8017aec28a060024f63bee59173b3c1df8879edb --- .gitignore | 2 + .testr.conf | 8 ++++ {tests => almanach/tests}/__init__.py | 0 almanach/tests/tempest/README.rst | 45 +++++++++++++++++++ .../tests/tempest}/__init__.py | 0 almanach/tests/tempest/clients.py | 24 ++++++++++ almanach/tests/tempest/config.py | 44 ++++++++++++++++++ almanach/tests/tempest/plugin.py | 41 +++++++++++++++++ almanach/tests/tempest/services/__init__.py | 3 ++ .../tests/tempest/services/almanach_client.py | 32 +++++++++++++ .../tests/tempest/tests}/__init__.py | 0 .../tests/tempest/tests/api}/__init__.py | 0 almanach/tests/tempest/tests/api/base.py | 40 +++++++++++++++++ .../tests/tempest/tests/api/test_version.py | 31 +++++++++++++ .../tests/tempest/tests/scenario}/__init__.py | 0 .../tests/unit}/__init__.py | 0 .../tests/unit/api}/__init__.py | 0 .../tests/unit/api/auth}/__init__.py | 0 .../unit}/api/auth/test_keystone_auth.py | 3 +- .../tests/unit}/api/auth/test_mixed_auth.py | 3 +- .../unit}/api/auth/test_private_key_auth.py | 3 +- .../tests/unit}/api/base_api.py | 2 +- .../unit}/api/test_api_authentication.py | 2 +- .../tests/unit}/api/test_api_entity.py | 6 +-- .../tests/unit}/api/test_api_info.py | 2 +- .../tests/unit}/api/test_api_instance.py | 8 ++-- .../tests/unit}/api/test_api_volume.py | 2 +- .../tests/unit}/api/test_api_volume_type.py | 6 +-- .../tests/unit}/api/test_auth_adapter.py | 3 +- {tests => almanach/tests/unit}/base.py | 0 {tests => almanach/tests/unit}/builder.py | 0 .../tests/unit/builders}/__init__.py | 0 .../tests/unit}/builders/notification.py | 0 .../tests/unit/collector}/__init__.py | 0 .../tests/unit/collector/handlers/__init__.py | 0 .../handlers/test_instance_handler.py | 4 +- .../collector/handlers/test_volume_handler.py | 4 +- .../handlers/test_volume_type_handler.py | 4 +- .../tests/unit}/collector/test_messaging.py | 2 +- .../unit}/collector/test_notification.py | 2 +- almanach/tests/unit/core/__init__.py | 0 .../tests/unit}/core/test_controller.py | 11 +++-- almanach/tests/unit/storage/__init__.py | 0 .../tests/unit/storage/drivers/__init__.py | 0 .../storage/drivers/test_mongodb_driver.py | 11 +++-- .../unit}/storage/test_storage_driver.py | 2 +- almanach/tests/unit/validators/__init__.py | 0 .../validators/test_instance_validator.py | 0 setup.cfg | 2 + test-requirements.txt | 4 +- tox.ini | 2 +- 51 files changed, 313 insertions(+), 45 deletions(-) create mode 100644 .testr.conf rename {tests => almanach/tests}/__init__.py (100%) create mode 100644 almanach/tests/tempest/README.rst rename {tests/api => almanach/tests/tempest}/__init__.py (100%) create mode 100644 almanach/tests/tempest/clients.py create mode 100644 almanach/tests/tempest/config.py create mode 100644 almanach/tests/tempest/plugin.py create mode 100644 almanach/tests/tempest/services/__init__.py create mode 100644 almanach/tests/tempest/services/almanach_client.py rename {tests/api/auth => almanach/tests/tempest/tests}/__init__.py (100%) rename {tests/builders => almanach/tests/tempest/tests/api}/__init__.py (100%) create mode 100644 almanach/tests/tempest/tests/api/base.py create mode 100644 almanach/tests/tempest/tests/api/test_version.py rename {tests/collector => almanach/tests/tempest/tests/scenario}/__init__.py (100%) rename {tests/collector/handlers => almanach/tests/unit}/__init__.py (100%) rename {tests/core => almanach/tests/unit/api}/__init__.py (100%) rename {tests/storage => almanach/tests/unit/api/auth}/__init__.py (100%) rename {tests => almanach/tests/unit}/api/auth/test_keystone_auth.py (98%) rename {tests => almanach/tests/unit}/api/auth/test_mixed_auth.py (98%) rename {tests => almanach/tests/unit}/api/auth/test_private_key_auth.py (97%) rename {tests => almanach/tests/unit}/api/base_api.py (98%) rename {tests => almanach/tests/unit}/api/test_api_authentication.py (96%) rename {tests => almanach/tests/unit}/api/test_api_entity.py (96%) rename {tests => almanach/tests/unit}/api/test_api_info.py (95%) rename {tests => almanach/tests/unit}/api/test_api_instance.py (98%) rename {tests => almanach/tests/unit}/api/test_api_volume.py (99%) rename {tests => almanach/tests/unit}/api/test_api_volume_type.py (95%) rename {tests => almanach/tests/unit}/api/test_auth_adapter.py (97%) rename {tests => almanach/tests/unit}/base.py (100%) rename {tests => almanach/tests/unit}/builder.py (100%) rename {tests/storage/drivers => almanach/tests/unit/builders}/__init__.py (100%) rename {tests => almanach/tests/unit}/builders/notification.py (100%) rename {tests/validators => almanach/tests/unit/collector}/__init__.py (100%) create mode 100644 almanach/tests/unit/collector/handlers/__init__.py rename {tests => almanach/tests/unit}/collector/handlers/test_instance_handler.py (97%) rename {tests => almanach/tests/unit}/collector/handlers/test_volume_handler.py (97%) rename {tests => almanach/tests/unit}/collector/handlers/test_volume_type_handler.py (92%) rename {tests => almanach/tests/unit}/collector/test_messaging.py (96%) rename {tests => almanach/tests/unit}/collector/test_notification.py (98%) create mode 100644 almanach/tests/unit/core/__init__.py rename {tests => almanach/tests/unit}/core/test_controller.py (99%) create mode 100644 almanach/tests/unit/storage/__init__.py create mode 100644 almanach/tests/unit/storage/drivers/__init__.py rename {tests => almanach/tests/unit}/storage/drivers/test_mongodb_driver.py (98%) rename {tests => almanach/tests/unit}/storage/test_storage_driver.py (97%) create mode 100644 almanach/tests/unit/validators/__init__.py rename {tests => almanach/tests/unit}/validators/test_instance_validator.py (100%) diff --git a/.gitignore b/.gitignore index cb0e86b..5ccf954 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,12 @@ .idea .tox *.iml +*.log *.pyc *.coverage *.egg* .DS_Store +.testrepository AUTHORS ChangeLog doc/build diff --git a/.testr.conf b/.testr.conf new file mode 100644 index 0000000..85369cd --- /dev/null +++ b/.testr.conf @@ -0,0 +1,8 @@ +[DEFAULT] +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 . ./almanach/tests/tempest/tests $LISTOPT $IDOPTION + +test_id_option=--load-list $IDFILE +test_list_option=--list diff --git a/tests/__init__.py b/almanach/tests/__init__.py similarity index 100% rename from tests/__init__.py rename to almanach/tests/__init__.py diff --git a/almanach/tests/tempest/README.rst b/almanach/tests/tempest/README.rst new file mode 100644 index 0000000..9df9009 --- /dev/null +++ b/almanach/tests/tempest/README.rst @@ -0,0 +1,45 @@ +=============================================== +Tempest Integration of Almanach +=============================================== + +This directory contains Tempest tests to cover the Almanach project. + +Tempest Configuration File +-------------------------- + +Example of config file for devstack: + +.. code:: bash + [DEFAULT] + + [identity] + auth_version = v3 + uri = http://192.168.50.50:5000/v2.0 + uri_v3 = http://192.168.50.50:5000/v3 + + [auth] + admin_username = admin + admin_password = secret + admin_project_name = admin + admin_domain_name = Default + + use_dynamic_credentials = true + +Here, :code:`192.168.50.50` is your devstack IP address. + +Run tests on your local machine +------------------------------- + +1. Create a virtualenv from :code:`https://git.openstack.org/openstack/tempest.git +2. Create a custom :code:`tempest.conf`, by default :code:`/etc/tempest/tempest.conf` is loaded +3. List the tests: :code:`testr list-tests` +4. Run the tests with testr or tempest: + - :code:`testr run` + - :code:`tempest run` + + +Run tests in devstack +--------------------- + +- :code:`cd /opt/stack/almanach` +- :code:`tempest run` diff --git a/tests/api/__init__.py b/almanach/tests/tempest/__init__.py similarity index 100% rename from tests/api/__init__.py rename to almanach/tests/tempest/__init__.py diff --git a/almanach/tests/tempest/clients.py b/almanach/tests/tempest/clients.py new file mode 100644 index 0000000..9f7e329 --- /dev/null +++ b/almanach/tests/tempest/clients.py @@ -0,0 +1,24 @@ +# Copyright 2016 Internap. +# +# 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 clients + +from almanach.tests.tempest.services import almanach_client + + +class Manager(clients.Manager): + + def __init__(self, credentials=None, service=None): + super(Manager, self).__init__(credentials, service) + self.almanach_client = almanach_client.AlmanachClient(self.auth_provider) diff --git a/almanach/tests/tempest/config.py b/almanach/tests/tempest/config.py new file mode 100644 index 0000000..30870ef --- /dev/null +++ b/almanach/tests/tempest/config.py @@ -0,0 +1,44 @@ +# Copyright 2016 Internap. +# +# 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("almanach", + default=True, + help="Whether or not Almanach is expected to be available"), +] + +usage_group = cfg.OptGroup(name="almanach", + title="Usage Service Options") + +UsageGroup = [ + cfg.StrOpt("region", + default="", + help="The usage region name to use. If empty, the value " + "of identity.region is used instead. If no such region " + "is found in the service catalog, the first found one is " + "used."), + cfg.StrOpt("catalog_type", + default="usage", + help="Catalog type for Almanach."), + cfg.StrOpt('endpoint_type', + default='publicURL', + choices=['public', 'admin', 'internal', + 'publicURL', 'adminURL', 'internalURL'], + help="The endpoint type to use for the usage service.") +] diff --git a/almanach/tests/tempest/plugin.py b/almanach/tests/tempest/plugin.py new file mode 100644 index 0000000..ac1b919 --- /dev/null +++ b/almanach/tests/tempest/plugin.py @@ -0,0 +1,41 @@ +# Copyright 2016 Internap. +# +# 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 almanach.tests.tempest import config as project_config + + +class AlmanachTempestPlugin(plugins.TempestPlugin): + + def load_tests(self): + base_path = os.path.split(os.path.dirname( + os.path.abspath(__file__)))[0] + test_dir = "tempest/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, project_config.service_available_group, + project_config.ServiceAvailableGroup) + config.register_opt_group(conf, project_config.usage_group, + project_config.UsageGroup) + + def get_opt_lists(self): + return [(project_config.usage_group.name, + project_config.UsageGroup)] diff --git a/almanach/tests/tempest/services/__init__.py b/almanach/tests/tempest/services/__init__.py new file mode 100644 index 0000000..5e8fa83 --- /dev/null +++ b/almanach/tests/tempest/services/__init__.py @@ -0,0 +1,3 @@ +from almanach.tests.tempest.services.almanach_client import AlmanachClient + +__all__ = ['AlmanachClient'] diff --git a/almanach/tests/tempest/services/almanach_client.py b/almanach/tests/tempest/services/almanach_client.py new file mode 100644 index 0000000..393f211 --- /dev/null +++ b/almanach/tests/tempest/services/almanach_client.py @@ -0,0 +1,32 @@ +# Copyright 2016 Internap. +# +# 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 config +from tempest.lib.common import rest_client + +CONF = config.CONF + + +class AlmanachClient(rest_client.RestClient): + + def __init__(self, auth_provider): + super(AlmanachClient, self).__init__( + auth_provider, + CONF.almanach.catalog_type, + CONF.almanach.region or CONF.identity.region, + endpoint_type=CONF.almanach.endpoint_type) + + def get_version(self): + resp, response_body = self.get('info') + return resp, response_body diff --git a/tests/api/auth/__init__.py b/almanach/tests/tempest/tests/__init__.py similarity index 100% rename from tests/api/auth/__init__.py rename to almanach/tests/tempest/tests/__init__.py diff --git a/tests/builders/__init__.py b/almanach/tests/tempest/tests/api/__init__.py similarity index 100% rename from tests/builders/__init__.py rename to almanach/tests/tempest/tests/api/__init__.py diff --git a/almanach/tests/tempest/tests/api/base.py b/almanach/tests/tempest/tests/api/base.py new file mode 100644 index 0000000..65caf5a --- /dev/null +++ b/almanach/tests/tempest/tests/api/base.py @@ -0,0 +1,40 @@ +# Copyright 2016 Internap. +# +# 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 config +import tempest.test + +from almanach.tests.tempest import clients + +CONF = config.CONF + + +class BaseAlmanachTest(tempest.test.BaseTestCase): + + @classmethod + def skip_checks(cls): + super(BaseAlmanachTest, cls).skip_checks() + + @classmethod + def setup_credentials(cls): + cls.set_network_resources() + super(BaseAlmanachTest, cls).setup_credentials() + + @classmethod + def setup_clients(cls): + super(BaseAlmanachTest, cls).setup_clients() + cred_provider = cls._get_credentials_provider() + credentials = cred_provider.get_creds_by_roles(['admin']).credentials + cls.os = clients.Manager(credentials=credentials) + cls.almanach_client = cls.os.almanach_client diff --git a/almanach/tests/tempest/tests/api/test_version.py b/almanach/tests/tempest/tests/api/test_version.py new file mode 100644 index 0000000..f2d66bd --- /dev/null +++ b/almanach/tests/tempest/tests/api/test_version.py @@ -0,0 +1,31 @@ +# Copyright 2016 Internap. +# +# 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_serialization import jsonutils as json + +from almanach.tests.tempest.tests.api import base + + +class TestVersion(base.BaseAlmanachTest): + + @classmethod + def resource_setup(cls): + super(TestVersion, cls).resource_setup() + + def test_get_version(self): + resp, response_body = self.almanach_client.get_version() + self.assertEqual(resp.status, 200) + response_body = json.loads(response_body) + + self.assertIsInstance(response_body, dict) diff --git a/tests/collector/__init__.py b/almanach/tests/tempest/tests/scenario/__init__.py similarity index 100% rename from tests/collector/__init__.py rename to almanach/tests/tempest/tests/scenario/__init__.py diff --git a/tests/collector/handlers/__init__.py b/almanach/tests/unit/__init__.py similarity index 100% rename from tests/collector/handlers/__init__.py rename to almanach/tests/unit/__init__.py diff --git a/tests/core/__init__.py b/almanach/tests/unit/api/__init__.py similarity index 100% rename from tests/core/__init__.py rename to almanach/tests/unit/api/__init__.py diff --git a/tests/storage/__init__.py b/almanach/tests/unit/api/auth/__init__.py similarity index 100% rename from tests/storage/__init__.py rename to almanach/tests/unit/api/auth/__init__.py diff --git a/tests/api/auth/test_keystone_auth.py b/almanach/tests/unit/api/auth/test_keystone_auth.py similarity index 98% rename from tests/api/auth/test_keystone_auth.py rename to almanach/tests/unit/api/auth/test_keystone_auth.py index 8f9d074..1f6ad05 100644 --- a/tests/api/auth/test_keystone_auth.py +++ b/almanach/tests/unit/api/auth/test_keystone_auth.py @@ -20,8 +20,7 @@ from hamcrest import raises from almanach.api.auth import keystone_auth from almanach.core import exception - -from tests import base +from almanach.tests.unit import base class KeystoneAuthenticationTest(base.BaseTestCase): diff --git a/tests/api/auth/test_mixed_auth.py b/almanach/tests/unit/api/auth/test_mixed_auth.py similarity index 98% rename from tests/api/auth/test_mixed_auth.py rename to almanach/tests/unit/api/auth/test_mixed_auth.py index fb7e1ac..7117749 100644 --- a/tests/api/auth/test_mixed_auth.py +++ b/almanach/tests/unit/api/auth/test_mixed_auth.py @@ -20,8 +20,7 @@ from hamcrest import raises from almanach.api.auth import mixed_auth from almanach.core import exception - -from tests import base +from almanach.tests.unit import base class MixedAuthenticationTest(base.BaseTestCase): diff --git a/tests/api/auth/test_private_key_auth.py b/almanach/tests/unit/api/auth/test_private_key_auth.py similarity index 97% rename from tests/api/auth/test_private_key_auth.py rename to almanach/tests/unit/api/auth/test_private_key_auth.py index 22dfd28..2841be4 100644 --- a/tests/api/auth/test_private_key_auth.py +++ b/almanach/tests/unit/api/auth/test_private_key_auth.py @@ -19,8 +19,7 @@ from hamcrest import raises from almanach.api.auth import private_key_auth from almanach.core import exception - -from tests import base +from almanach.tests.unit import base class PrivateKeyAuthenticationTest(base.BaseTestCase): diff --git a/tests/api/base_api.py b/almanach/tests/unit/api/base_api.py similarity index 98% rename from tests/api/base_api.py rename to almanach/tests/unit/api/base_api.py index 97778f7..08f6f1e 100644 --- a/tests/api/base_api.py +++ b/almanach/tests/unit/api/base_api.py @@ -20,7 +20,7 @@ import oslo_serialization from almanach.api.v1 import routes from almanach.core import exception -from tests import base +from almanach.tests.unit import base class BaseApi(base.BaseTestCase): diff --git a/tests/api/test_api_authentication.py b/almanach/tests/unit/api/test_api_authentication.py similarity index 96% rename from tests/api/test_api_authentication.py rename to almanach/tests/unit/api/test_api_authentication.py index 67bfa33..060d1c4 100644 --- a/tests/api/test_api_authentication.py +++ b/almanach/tests/unit/api/test_api_authentication.py @@ -15,7 +15,7 @@ from hamcrest import assert_that from hamcrest import equal_to -from tests.api.base_api import BaseApi +from almanach.tests.unit.api.base_api import BaseApi class ApiAuthenticationTest(BaseApi): diff --git a/tests/api/test_api_entity.py b/almanach/tests/unit/api/test_api_entity.py similarity index 96% rename from tests/api/test_api_entity.py rename to almanach/tests/unit/api/test_api_entity.py index 41c7d66..08eb1e8 100644 --- a/tests/api/test_api_entity.py +++ b/almanach/tests/unit/api/test_api_entity.py @@ -20,9 +20,9 @@ from hamcrest import is_ from voluptuous import Invalid from almanach.core import exception -from tests.api.base_api import BaseApi -from tests.builder import a -from tests.builder import instance +from almanach.tests.unit.api.base_api import BaseApi +from almanach.tests.unit.builder import a +from almanach.tests.unit.builder import instance class ApiEntityTest(BaseApi): diff --git a/tests/api/test_api_info.py b/almanach/tests/unit/api/test_api_info.py similarity index 95% rename from tests/api/test_api_info.py rename to almanach/tests/unit/api/test_api_info.py index ddc6561..f3f1708 100644 --- a/tests/api/test_api_info.py +++ b/almanach/tests/unit/api/test_api_info.py @@ -16,7 +16,7 @@ from hamcrest import assert_that from hamcrest import equal_to from hamcrest import has_key -from tests.api.base_api import BaseApi +from almanach.tests.unit.api.base_api import BaseApi class ApiInfoTest(BaseApi): diff --git a/tests/api/test_api_instance.py b/almanach/tests/unit/api/test_api_instance.py similarity index 98% rename from tests/api/test_api_instance.py rename to almanach/tests/unit/api/test_api_instance.py index 1069329..db76cc4 100644 --- a/tests/api/test_api_instance.py +++ b/almanach/tests/unit/api/test_api_instance.py @@ -20,10 +20,10 @@ from hamcrest import has_length from hamcrest import is_ from almanach.core import exception -from tests.api.base_api import a_date_matching -from tests.api.base_api import BaseApi -from tests.builder import a -from tests.builder import instance +from almanach.tests.unit.api.base_api import a_date_matching +from almanach.tests.unit.api.base_api import BaseApi +from almanach.tests.unit.builder import a +from almanach.tests.unit.builder import instance class ApiInstanceTest(BaseApi): diff --git a/tests/api/test_api_volume.py b/almanach/tests/unit/api/test_api_volume.py similarity index 99% rename from tests/api/test_api_volume.py rename to almanach/tests/unit/api/test_api_volume.py index bf68b4f..a82402d 100644 --- a/tests/api/test_api_volume.py +++ b/almanach/tests/unit/api/test_api_volume.py @@ -19,7 +19,7 @@ from hamcrest import equal_to from hamcrest import has_entries from almanach.core import exception -from tests.api.base_api import BaseApi +from almanach.tests.unit.api.base_api import BaseApi class ApiVolumeTest(BaseApi): diff --git a/tests/api/test_api_volume_type.py b/almanach/tests/unit/api/test_api_volume_type.py similarity index 95% rename from tests/api/test_api_volume_type.py rename to almanach/tests/unit/api/test_api_volume_type.py index 7eb1b09..3bf945e 100644 --- a/tests/api/test_api_volume_type.py +++ b/almanach/tests/unit/api/test_api_volume_type.py @@ -20,9 +20,9 @@ from hamcrest import has_key from hamcrest import has_length from almanach.core import exception -from tests.api.base_api import BaseApi -from tests.builder import a -from tests.builder import volume_type +from almanach.tests.unit.api.base_api import BaseApi +from almanach.tests.unit.builder import a +from almanach.tests.unit.builder import volume_type class ApiVolumeTypeTest(BaseApi): diff --git a/tests/api/test_auth_adapter.py b/almanach/tests/unit/api/test_auth_adapter.py similarity index 97% rename from tests/api/test_auth_adapter.py rename to almanach/tests/unit/api/test_auth_adapter.py index becb944..980fd9b 100644 --- a/tests/api/test_auth_adapter.py +++ b/almanach/tests/unit/api/test_auth_adapter.py @@ -19,8 +19,7 @@ from almanach.api.auth import keystone_auth from almanach.api.auth import mixed_auth from almanach.api.auth import private_key_auth from almanach.api import auth_adapter - -from tests import base +from almanach.tests.unit import base class AuthenticationAdapterTest(base.BaseTestCase): diff --git a/tests/base.py b/almanach/tests/unit/base.py similarity index 100% rename from tests/base.py rename to almanach/tests/unit/base.py diff --git a/tests/builder.py b/almanach/tests/unit/builder.py similarity index 100% rename from tests/builder.py rename to almanach/tests/unit/builder.py diff --git a/tests/storage/drivers/__init__.py b/almanach/tests/unit/builders/__init__.py similarity index 100% rename from tests/storage/drivers/__init__.py rename to almanach/tests/unit/builders/__init__.py diff --git a/tests/builders/notification.py b/almanach/tests/unit/builders/notification.py similarity index 100% rename from tests/builders/notification.py rename to almanach/tests/unit/builders/notification.py diff --git a/tests/validators/__init__.py b/almanach/tests/unit/collector/__init__.py similarity index 100% rename from tests/validators/__init__.py rename to almanach/tests/unit/collector/__init__.py diff --git a/almanach/tests/unit/collector/handlers/__init__.py b/almanach/tests/unit/collector/handlers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/collector/handlers/test_instance_handler.py b/almanach/tests/unit/collector/handlers/test_instance_handler.py similarity index 97% rename from tests/collector/handlers/test_instance_handler.py rename to almanach/tests/unit/collector/handlers/test_instance_handler.py index 22cabef..59b1f41 100644 --- a/tests/collector/handlers/test_instance_handler.py +++ b/almanach/tests/unit/collector/handlers/test_instance_handler.py @@ -15,8 +15,8 @@ import mock from almanach.collector.handlers import instance_handler -from tests import base -from tests.builders import notification as builder +from almanach.tests.unit import base +from almanach.tests.unit.builders import notification as builder class InstanceHandlerTest(base.BaseTestCase): diff --git a/tests/collector/handlers/test_volume_handler.py b/almanach/tests/unit/collector/handlers/test_volume_handler.py similarity index 97% rename from tests/collector/handlers/test_volume_handler.py rename to almanach/tests/unit/collector/handlers/test_volume_handler.py index 4befdae..6857cec 100644 --- a/tests/collector/handlers/test_volume_handler.py +++ b/almanach/tests/unit/collector/handlers/test_volume_handler.py @@ -15,8 +15,8 @@ import mock from almanach.collector.handlers import volume_handler -from tests import base -from tests.builders import notification as builder +from almanach.tests.unit import base +from almanach.tests.unit.builders import notification as builder class VolumeHandlerTest(base.BaseTestCase): diff --git a/tests/collector/handlers/test_volume_type_handler.py b/almanach/tests/unit/collector/handlers/test_volume_type_handler.py similarity index 92% rename from tests/collector/handlers/test_volume_type_handler.py rename to almanach/tests/unit/collector/handlers/test_volume_type_handler.py index 29221d1..f647331 100644 --- a/tests/collector/handlers/test_volume_type_handler.py +++ b/almanach/tests/unit/collector/handlers/test_volume_type_handler.py @@ -15,8 +15,8 @@ import mock from almanach.collector.handlers import volume_type_handler -from tests import base -from tests.builders import notification as builder +from almanach.tests.unit import base +from almanach.tests.unit.builders import notification as builder class VolumeTypeHandlerTest(base.BaseTestCase): diff --git a/tests/collector/test_messaging.py b/almanach/tests/unit/collector/test_messaging.py similarity index 96% rename from tests/collector/test_messaging.py rename to almanach/tests/unit/collector/test_messaging.py index 915a87b..84155c0 100644 --- a/tests/collector/test_messaging.py +++ b/almanach/tests/unit/collector/test_messaging.py @@ -16,7 +16,7 @@ import mock import oslo_messaging from almanach.collector import messaging -from tests import base +from almanach.tests.unit import base class MessagingFactoryTest(base.BaseTestCase): diff --git a/tests/collector/test_notification.py b/almanach/tests/unit/collector/test_notification.py similarity index 98% rename from tests/collector/test_notification.py rename to almanach/tests/unit/collector/test_notification.py index 099db8d..1acb266 100644 --- a/tests/collector/test_notification.py +++ b/almanach/tests/unit/collector/test_notification.py @@ -15,7 +15,7 @@ import mock from almanach.collector import notification -from tests import base +from almanach.tests.unit import base class NotificationTest(base.BaseTestCase): diff --git a/almanach/tests/unit/core/__init__.py b/almanach/tests/unit/core/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/core/test_controller.py b/almanach/tests/unit/core/test_controller.py similarity index 99% rename from tests/core/test_controller.py rename to almanach/tests/unit/core/test_controller.py index 47f6b6d..8753cf0 100644 --- a/tests/core/test_controller.py +++ b/almanach/tests/unit/core/test_controller.py @@ -28,12 +28,11 @@ from almanach.core import controller from almanach.core import exception from almanach.core import model from almanach.storage.drivers import base_driver - -from tests import base -from tests.builder import a -from tests.builder import instance -from tests.builder import volume -from tests.builder import volume_type +from almanach.tests.unit import base +from almanach.tests.unit.builder import a +from almanach.tests.unit.builder import instance +from almanach.tests.unit.builder import volume +from almanach.tests.unit.builder import volume_type class ControllerTest(base.BaseTestCase): diff --git a/almanach/tests/unit/storage/__init__.py b/almanach/tests/unit/storage/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/almanach/tests/unit/storage/drivers/__init__.py b/almanach/tests/unit/storage/drivers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/storage/drivers/test_mongodb_driver.py b/almanach/tests/unit/storage/drivers/test_mongodb_driver.py similarity index 98% rename from tests/storage/drivers/test_mongodb_driver.py rename to almanach/tests/unit/storage/drivers/test_mongodb_driver.py index e93caed..b55e594 100644 --- a/tests/storage/drivers/test_mongodb_driver.py +++ b/almanach/tests/unit/storage/drivers/test_mongodb_driver.py @@ -25,12 +25,11 @@ from hamcrest import contains_inanyorder from almanach.core import exception from almanach.core import model from almanach.storage.drivers import mongodb_driver - -from tests import base -from tests.builder import a -from tests.builder import instance -from tests.builder import volume -from tests.builder import volume_type +from almanach.tests.unit import base +from almanach.tests.unit.builder import a +from almanach.tests.unit.builder import instance +from almanach.tests.unit.builder import volume +from almanach.tests.unit.builder import volume_type class MongoDbDriverTest(base.BaseTestCase): diff --git a/tests/storage/test_storage_driver.py b/almanach/tests/unit/storage/test_storage_driver.py similarity index 97% rename from tests/storage/test_storage_driver.py rename to almanach/tests/unit/storage/test_storage_driver.py index 118bf04..601a643 100644 --- a/tests/storage/test_storage_driver.py +++ b/almanach/tests/unit/storage/test_storage_driver.py @@ -16,7 +16,7 @@ from almanach.core import exception from almanach.storage.drivers import mongodb_driver from almanach.storage import storage_driver -from tests import base +from almanach.tests.unit import base class StorageDriverTest(base.BaseTestCase): diff --git a/almanach/tests/unit/validators/__init__.py b/almanach/tests/unit/validators/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/validators/test_instance_validator.py b/almanach/tests/unit/validators/test_instance_validator.py similarity index 100% rename from tests/validators/test_instance_validator.py rename to almanach/tests/unit/validators/test_instance_validator.py diff --git a/setup.cfg b/setup.cfg index 0e0d499..60029bd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,6 +28,8 @@ oslo.config.opts = console_scripts = almanach-api = almanach.api.main:main almanach-collector = almanach.collector.main:main +tempest.test_plugins = + almanach_tests = almanach.tests.tempest.plugin:AlmanachTempestPlugin [nosetests] no-path-adjustment = 1 diff --git a/test-requirements.txt b/test-requirements.txt index ffd94c6..1ec25ea 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -8,4 +8,6 @@ sphinxcontrib-httpdomain # BSD flake8>=2.5.4,<2.6.0 # MIT hacking<0.12,>=0.11.0 # Apache-2.0 testtools>=1.4.0 # MIT -mock>=2.0 # BSD \ No newline at end of file +mock>=2.0 # BSD +tempest>=12.1.0 # Apache-2.0 +tempest-lib>=0.14.0 # Apache-2.0 \ No newline at end of file diff --git a/tox.ini b/tox.ini index 1286ff6..b91b738 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,7 @@ deps = -r{toxinidir}/requirements.txt setenv = PYTHONPATH = {toxinidir} -commands = nosetests --tests tests +commands = nosetests --tests almanach.tests.unit [testenv:genconfig] commands = oslo-config-generator --namespace almanach --output-file=etc/almanach/almanach.conf