From baf526ef907789fea4ea999cae288cd0d1c6d493 Mon Sep 17 00:00:00 2001 From: Luigi Toscano Date: Tue, 12 Apr 2016 13:55:23 +0200 Subject: [PATCH] Convert the imported API tests to Tempest Plugin interface Having tests exporting a Tempest Plugin interface allow them to be executed together with other Tempest tests. Change-Id: If25c343fb4871755dbb32eedc724268a3a617270 --- ...pest-tests-as-plugin-25d63ac04902f1ad.yaml | 4 ++ sahara_tempest_plugin/README.rst | 5 ++ .../__init__.py | 0 sahara_tempest_plugin/config.py | 43 +++++++++++++++ sahara_tempest_plugin/plugin.py | 55 +++++++++++++++++++ sahara_tempest_plugin/tests/__init__.py | 0 sahara_tempest_plugin/tests/api/__init__.py | 0 .../tests/api}/base.py | 0 .../tests/api}/test_cluster_templates.py | 2 +- .../tests/api}/test_data_sources.py | 2 +- .../tests/api}/test_job_binaries.py | 2 +- .../tests/api}/test_job_binary_internals.py | 2 +- .../tests/api}/test_jobs.py | 2 +- .../tests/api}/test_node_group_templates.py | 2 +- .../tests/api}/test_plugins.py | 2 +- setup.cfg | 4 ++ 16 files changed, 118 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/sahara-api-tempest-tests-as-plugin-25d63ac04902f1ad.yaml create mode 100644 sahara_tempest_plugin/README.rst rename {tempest/api/data_processing => sahara_tempest_plugin}/__init__.py (100%) create mode 100644 sahara_tempest_plugin/config.py create mode 100644 sahara_tempest_plugin/plugin.py create mode 100644 sahara_tempest_plugin/tests/__init__.py create mode 100644 sahara_tempest_plugin/tests/api/__init__.py rename {tempest/api/data_processing => sahara_tempest_plugin/tests/api}/base.py (100%) rename {tempest/api/data_processing => sahara_tempest_plugin/tests/api}/test_cluster_templates.py (98%) rename {tempest/api/data_processing => sahara_tempest_plugin/tests/api}/test_data_sources.py (99%) rename {tempest/api/data_processing => sahara_tempest_plugin/tests/api}/test_job_binaries.py (99%) rename {tempest/api/data_processing => sahara_tempest_plugin/tests/api}/test_job_binary_internals.py (98%) rename {tempest/api/data_processing => sahara_tempest_plugin/tests/api}/test_jobs.py (98%) rename {tempest/api/data_processing => sahara_tempest_plugin/tests/api}/test_node_group_templates.py (98%) rename {tempest/api/data_processing => sahara_tempest_plugin/tests/api}/test_plugins.py (97%) diff --git a/releasenotes/notes/sahara-api-tempest-tests-as-plugin-25d63ac04902f1ad.yaml b/releasenotes/notes/sahara-api-tempest-tests-as-plugin-25d63ac04902f1ad.yaml new file mode 100644 index 00000000..ec45f86a --- /dev/null +++ b/releasenotes/notes/sahara-api-tempest-tests-as-plugin-25d63ac04902f1ad.yaml @@ -0,0 +1,4 @@ +--- +features: + - Sahara API tests have been imported from Tempest and + made available using the Tempest Plugin Interface. diff --git a/sahara_tempest_plugin/README.rst b/sahara_tempest_plugin/README.rst new file mode 100644 index 00000000..efd551f1 --- /dev/null +++ b/sahara_tempest_plugin/README.rst @@ -0,0 +1,5 @@ +=============================================== +Tempest Integration of Sahara +=============================================== + +This directory contains Tempest tests to cover the Sahara project. diff --git a/tempest/api/data_processing/__init__.py b/sahara_tempest_plugin/__init__.py similarity index 100% rename from tempest/api/data_processing/__init__.py rename to sahara_tempest_plugin/__init__.py diff --git a/sahara_tempest_plugin/config.py b/sahara_tempest_plugin/config.py new file mode 100644 index 00000000..ed92f67c --- /dev/null +++ b/sahara_tempest_plugin/config.py @@ -0,0 +1,43 @@ +# Copyright 2016 Red Hat, Inc. +# 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 + + +data_processing_group = cfg.OptGroup(name="data-processing", + title="Data Processing options") + +DataProcessingGroup = [ + cfg.StrOpt('catalog_type', + default='data-processing', + help="Catalog type of the data processing service."), + cfg.StrOpt('endpoint_type', + default='publicURL', + choices=['public', 'admin', 'internal', + 'publicURL', 'adminURL', 'internalURL'], + help="The endpoint type to use for the data processing " + "service."), +] + + +data_processing_feature_group = cfg.OptGroup( + name="data-processing-feature-enabled", + title="Enabled Data Processing features") + +DataProcessingFeaturesGroup = [ + cfg.ListOpt('plugins', + default=["vanilla", "cdh"], + help="List of enabled data processing plugins") +] diff --git a/sahara_tempest_plugin/plugin.py b/sahara_tempest_plugin/plugin.py new file mode 100644 index 00000000..8ca7b425 --- /dev/null +++ b/sahara_tempest_plugin/plugin.py @@ -0,0 +1,55 @@ +# Copyright 2016 Red Hat, Inc. +# 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 oslo_config import cfg +from tempest import config +from tempest.test_discover import plugins + +from sahara_tempest_plugin import config as sahara_config + + +class SaharaTempestPlugin(plugins.TempestPlugin): + def load_tests(self): + base_path = os.path.split(os.path.dirname( + os.path.abspath(__file__)))[0] + test_dir = "sahara_tempest_plugin/tests" + full_test_dir = os.path.join(base_path, test_dir) + return full_test_dir, base_path + + def register_opts(self, conf): + # Ignore the duplicate error: it means that the same content + # is (still) defined in Tempest + try: + config.register_opt_group(conf, + sahara_config.data_processing_group, + sahara_config.DataProcessingGroup) + except cfg.DuplicateOptError: + pass + try: + config.register_opt_group(conf, sahara_config. + data_processing_feature_group, + sahara_config. + DataProcessingFeaturesGroup) + except cfg.DuplicateOptError: + pass + + def get_opt_lists(self): + return [(sahara_config.data_processing_group.name, + sahara_config.DataProcessingGroup), + (sahara_config.data_processing_feature_group.name, + sahara_config.DataProcessingFeaturesGroup)] diff --git a/sahara_tempest_plugin/tests/__init__.py b/sahara_tempest_plugin/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/sahara_tempest_plugin/tests/api/__init__.py b/sahara_tempest_plugin/tests/api/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tempest/api/data_processing/base.py b/sahara_tempest_plugin/tests/api/base.py similarity index 100% rename from tempest/api/data_processing/base.py rename to sahara_tempest_plugin/tests/api/base.py diff --git a/tempest/api/data_processing/test_cluster_templates.py b/sahara_tempest_plugin/tests/api/test_cluster_templates.py similarity index 98% rename from tempest/api/data_processing/test_cluster_templates.py rename to sahara_tempest_plugin/tests/api/test_cluster_templates.py index dfd8e27d..e67d7f6d 100644 --- a/tempest/api/data_processing/test_cluster_templates.py +++ b/sahara_tempest_plugin/tests/api/test_cluster_templates.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.api.data_processing import base as dp_base +from sahara_tempest_plugin.tests.api import base as dp_base from tempest.common.utils import data_utils from tempest import exceptions from tempest import test diff --git a/tempest/api/data_processing/test_data_sources.py b/sahara_tempest_plugin/tests/api/test_data_sources.py similarity index 99% rename from tempest/api/data_processing/test_data_sources.py rename to sahara_tempest_plugin/tests/api/test_data_sources.py index 67d09a03..e3b2fe1a 100644 --- a/tempest/api/data_processing/test_data_sources.py +++ b/sahara_tempest_plugin/tests/api/test_data_sources.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.api.data_processing import base as dp_base +from sahara_tempest_plugin.tests.api import base as dp_base from tempest.common.utils import data_utils from tempest import test diff --git a/tempest/api/data_processing/test_job_binaries.py b/sahara_tempest_plugin/tests/api/test_job_binaries.py similarity index 99% rename from tempest/api/data_processing/test_job_binaries.py rename to sahara_tempest_plugin/tests/api/test_job_binaries.py index a47ddbc4..4455a04b 100644 --- a/tempest/api/data_processing/test_job_binaries.py +++ b/sahara_tempest_plugin/tests/api/test_job_binaries.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.api.data_processing import base as dp_base +from sahara_tempest_plugin.tests.api import base as dp_base from tempest.common.utils import data_utils from tempest import test diff --git a/tempest/api/data_processing/test_job_binary_internals.py b/sahara_tempest_plugin/tests/api/test_job_binary_internals.py similarity index 98% rename from tempest/api/data_processing/test_job_binary_internals.py rename to sahara_tempest_plugin/tests/api/test_job_binary_internals.py index b4f07695..bc90ce3c 100644 --- a/tempest/api/data_processing/test_job_binary_internals.py +++ b/sahara_tempest_plugin/tests/api/test_job_binary_internals.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.api.data_processing import base as dp_base +from sahara_tempest_plugin.tests.api import base as dp_base from tempest.common.utils import data_utils from tempest import test diff --git a/tempest/api/data_processing/test_jobs.py b/sahara_tempest_plugin/tests/api/test_jobs.py similarity index 98% rename from tempest/api/data_processing/test_jobs.py rename to sahara_tempest_plugin/tests/api/test_jobs.py index 85033202..6ab41c02 100644 --- a/tempest/api/data_processing/test_jobs.py +++ b/sahara_tempest_plugin/tests/api/test_jobs.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.api.data_processing import base as dp_base +from sahara_tempest_plugin.tests.api import base as dp_base from tempest.common.utils import data_utils from tempest import test diff --git a/tempest/api/data_processing/test_node_group_templates.py b/sahara_tempest_plugin/tests/api/test_node_group_templates.py similarity index 98% rename from tempest/api/data_processing/test_node_group_templates.py rename to sahara_tempest_plugin/tests/api/test_node_group_templates.py index 388bb587..cbdce373 100644 --- a/tempest/api/data_processing/test_node_group_templates.py +++ b/sahara_tempest_plugin/tests/api/test_node_group_templates.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.api.data_processing import base as dp_base +from sahara_tempest_plugin.tests.api import base as dp_base from tempest.common.utils import data_utils from tempest import test diff --git a/tempest/api/data_processing/test_plugins.py b/sahara_tempest_plugin/tests/api/test_plugins.py similarity index 97% rename from tempest/api/data_processing/test_plugins.py rename to sahara_tempest_plugin/tests/api/test_plugins.py index 14594e46..a6286749 100644 --- a/tempest/api/data_processing/test_plugins.py +++ b/sahara_tempest_plugin/tests/api/test_plugins.py @@ -12,7 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. -from tempest.api.data_processing import base as dp_base +from sahara_tempest_plugin.tests.api import base as dp_base from tempest import config from tempest import test diff --git a/setup.cfg b/setup.cfg index 69e13709..b517673d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,6 +22,7 @@ setup-hooks = pbr.hooks.setup_hook [files] packages = sahara_tests + sahara_tempest_plugin data_files = etc/sahara-scenario = etc/* @@ -30,6 +31,9 @@ data_files = console_scripts = sahara-scenario = sahara_tests.scenario.runner:main +tempest.test_plugins = + sahara_tempest_tests = sahara_tempest_plugin.plugin:SaharaTempestPlugin + [build_sphinx] all_files = 1 build-dir = doc/build