From 2015942d6e90e1fa8e97f94dc075da25259c96d1 Mon Sep 17 00:00:00 2001 From: Artom Lifshitz Date: Mon, 9 Jul 2018 13:59:41 -0400 Subject: [PATCH] Subclass API tests instead of scenario Our tests are only for the compute API (and related compute things). They are not scenario tests as defined in the Tempest scenario README. This patch moves our tests to subclass the Tempest base compute test class. While this isn't guaranteed to be a stable interface, it's convenient enough (we gain helper methods) that the potential maintenance overhead is deemed worth it. Our unit tests are also moved up a directory, with tests/ now being only for unit tests and tempest/api for our test cases. Change-Id: Ie34aa99765c3fa8a136fa4cb1b11edb3d8c76ba3 --- .stestr.conf | 2 +- .../{tests/scenario => api}/__init__.py | 0 .../{tests/unit => api/compute}/__init__.py | 0 .../{tests/scenario => api/compute}/base.py | 4 ++-- .../scenario => api/compute}/test_pointer_device_type.py | 7 +++---- whitebox_tempest_plugin/plugin.py | 2 +- whitebox_tempest_plugin/tests/{unit => }/base.py | 0 whitebox_tempest_plugin/tests/{unit => }/test_utils.py | 2 +- 8 files changed, 8 insertions(+), 9 deletions(-) rename whitebox_tempest_plugin/{tests/scenario => api}/__init__.py (100%) rename whitebox_tempest_plugin/{tests/unit => api/compute}/__init__.py (100%) rename whitebox_tempest_plugin/{tests/scenario => api/compute}/base.py (92%) rename whitebox_tempest_plugin/{tests/scenario => api/compute}/test_pointer_device_type.py (94%) rename whitebox_tempest_plugin/tests/{unit => }/base.py (100%) rename whitebox_tempest_plugin/tests/{unit => }/test_utils.py (97%) diff --git a/.stestr.conf b/.stestr.conf index 30b8d1b4..bdae8ab5 100644 --- a/.stestr.conf +++ b/.stestr.conf @@ -1,3 +1,3 @@ [DEFAULT] -test_path=./whitebox_tempest_plugin/tests/unit +test_path=./whitebox_tempest_plugin/tests top_dir=./ diff --git a/whitebox_tempest_plugin/tests/scenario/__init__.py b/whitebox_tempest_plugin/api/__init__.py similarity index 100% rename from whitebox_tempest_plugin/tests/scenario/__init__.py rename to whitebox_tempest_plugin/api/__init__.py diff --git a/whitebox_tempest_plugin/tests/unit/__init__.py b/whitebox_tempest_plugin/api/compute/__init__.py similarity index 100% rename from whitebox_tempest_plugin/tests/unit/__init__.py rename to whitebox_tempest_plugin/api/compute/__init__.py diff --git a/whitebox_tempest_plugin/tests/scenario/base.py b/whitebox_tempest_plugin/api/compute/base.py similarity index 92% rename from whitebox_tempest_plugin/tests/scenario/base.py rename to whitebox_tempest_plugin/api/compute/base.py index 77bfb4d2..8edc8a96 100644 --- a/whitebox_tempest_plugin/tests/scenario/base.py +++ b/whitebox_tempest_plugin/api/compute/base.py @@ -14,15 +14,15 @@ # under the License. from oslo_log import log as logging +from tempest.api.compute import base from tempest import config -from tempest.scenario import manager CONF = config.CONF LOG = logging.getLogger(__name__) -class BaseTest(manager.ScenarioTest): +class BaseTest(base.BaseV2ComputeTest): credentials = ['primary', 'admin'] diff --git a/whitebox_tempest_plugin/tests/scenario/test_pointer_device_type.py b/whitebox_tempest_plugin/api/compute/test_pointer_device_type.py similarity index 94% rename from whitebox_tempest_plugin/tests/scenario/test_pointer_device_type.py rename to whitebox_tempest_plugin/api/compute/test_pointer_device_type.py index cf0bbba0..c4610b69 100644 --- a/whitebox_tempest_plugin/tests/scenario/test_pointer_device_type.py +++ b/whitebox_tempest_plugin/api/compute/test_pointer_device_type.py @@ -23,12 +23,11 @@ # pointer_model=ps2mouse from oslo_log import log as logging -from tempest.common import utils from tempest import config +from whitebox_tempest_plugin.api.compute import base from whitebox_tempest_plugin.common import utils as whitebox_utils from whitebox_tempest_plugin.services import clients -from whitebox_tempest_plugin.tests.scenario import base CONF = config.CONF LOG = logging.getLogger(__name__) @@ -66,12 +65,12 @@ class PointerDeviceTypeFromImages(base.BaseTest): self.assertTrue(tablet in output) self.assertTrue(mouse in output) - @utils.services('compute') def test_pointer_device_type_from_images(self): # TODO(stephenfin): I'm pretty sure this modifying the main image. We # shouldn't be doing that. image_id = CONF.compute.image_ref self._set_image_metadata_item(image_id) - server = self.create_server(image_id=image_id) + server = self.create_test_server(image_id=image_id, + wait_until='ACTIVE') self._verify_pointer_device_type_from_images(server['id']) diff --git a/whitebox_tempest_plugin/plugin.py b/whitebox_tempest_plugin/plugin.py index 3bcc0048..d9054489 100644 --- a/whitebox_tempest_plugin/plugin.py +++ b/whitebox_tempest_plugin/plugin.py @@ -27,7 +27,7 @@ class WhiteboxTempestPlugin(plugins.TempestPlugin): def load_tests(self): base_path = os.path.split(os.path.dirname( os.path.abspath(__file__)))[0] - test_dir = 'whitebox_tempest_plugin/tests' + test_dir = 'whitebox_tempest_plugin/api' full_test_dir = os.path.join(base_path, test_dir) return full_test_dir, base_path diff --git a/whitebox_tempest_plugin/tests/unit/base.py b/whitebox_tempest_plugin/tests/base.py similarity index 100% rename from whitebox_tempest_plugin/tests/unit/base.py rename to whitebox_tempest_plugin/tests/base.py diff --git a/whitebox_tempest_plugin/tests/unit/test_utils.py b/whitebox_tempest_plugin/tests/test_utils.py similarity index 97% rename from whitebox_tempest_plugin/tests/unit/test_utils.py rename to whitebox_tempest_plugin/tests/test_utils.py index 0f52fddc..952c3eff 100644 --- a/whitebox_tempest_plugin/tests/unit/test_utils.py +++ b/whitebox_tempest_plugin/tests/test_utils.py @@ -15,7 +15,7 @@ import mock from whitebox_tempest_plugin.common import utils -from whitebox_tempest_plugin.tests.unit import base +from whitebox_tempest_plugin.tests import base class UtilsTestCase(base.WhiteboxPluginTestCase):