Merge "Deprecate the old API microversion fixture"
diff --git a/tempest/api/compute/base.py b/tempest/api/compute/base.py
index a6ff965..ed50282 100644
--- a/tempest/api/compute/base.py
+++ b/tempest/api/compute/base.py
@@ -21,7 +21,6 @@
from tempest.common import waiters
from tempest import config
from tempest import exceptions
-from tempest.lib.common import api_microversion_fixture
from tempest.lib.common import api_version_request
from tempest.lib.common import api_version_utils
from tempest.lib.common.utils import data_utils
@@ -164,6 +163,11 @@
api_version_utils.select_request_microversion(
cls.placement_min_microversion,
CONF.placement.min_microversion))
+ cls.setup_api_microversion_fixture(
+ compute_microversion=cls.request_microversion,
+ volume_microversion=cls.volume_request_microversion,
+ placement_microversion=cls.placement_request_microversion)
+
cls.build_interval = CONF.compute.build_interval
cls.build_timeout = CONF.compute.build_timeout
cls.image_ref = CONF.compute.image_ref
@@ -499,13 +503,6 @@
else:
raise lib_exc.InvalidConfiguration()
- def setUp(self):
- super(BaseV2ComputeTest, self).setUp()
- self.useFixture(api_microversion_fixture.APIMicroversionFixture(
- compute_microversion=self.request_microversion,
- volume_microversion=self.volume_request_microversion,
- placement_microversion=self.placement_request_microversion))
-
@classmethod
def create_volume(cls, image_ref=None, **kwargs):
"""Create a volume and wait for it to become 'available'.
diff --git a/tempest/api/volume/base.py b/tempest/api/volume/base.py
index 6e34dd6..b90b5bb 100644
--- a/tempest/api/volume/base.py
+++ b/tempest/api/volume/base.py
@@ -16,7 +16,6 @@
from tempest.common import compute
from tempest.common import waiters
from tempest import config
-from tempest.lib.common import api_microversion_fixture
from tempest.lib.common import api_version_utils
from tempest.lib.common.utils import data_utils
from tempest.lib.common.utils import test_utils
@@ -75,12 +74,6 @@
cls.os_primary.volume_availability_zone_client_latest)
cls.volume_limits_client = cls.os_primary.volume_limits_client_latest
- def setUp(self):
- super(BaseVolumeTest, self).setUp()
- self.useFixture(api_microversion_fixture.APIMicroversionFixture(
- compute_microversion=self.compute_request_microversion,
- volume_microversion=self.volume_request_microversion))
-
@classmethod
def resource_setup(cls):
super(BaseVolumeTest, cls).resource_setup()
@@ -92,6 +85,9 @@
api_version_utils.select_request_microversion(
cls.min_microversion,
CONF.compute.min_microversion))
+ cls.setup_api_microversion_fixture(
+ compute_microversion=cls.compute_request_microversion,
+ volume_microversion=cls.volume_request_microversion)
cls.image_ref = CONF.compute.image_ref
cls.flavor_ref = CONF.compute.flavor_ref
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 39021d5..7aa96b2 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -30,7 +30,6 @@
from tempest.common import waiters
from tempest import config
from tempest import exceptions
-from tempest.lib.common import api_microversion_fixture
from tempest.lib.common import api_version_utils
from tempest.lib.common.utils import data_utils
from tempest.lib.common.utils import test_utils
@@ -85,12 +84,10 @@
cls.placement_min_microversion,
CONF.placement.min_microversion))
- def setUp(self):
- super(ScenarioTest, self).setUp()
- self.useFixture(api_microversion_fixture.APIMicroversionFixture(
- compute_microversion=self.compute_request_microversion,
- volume_microversion=self.volume_request_microversion,
- placement_microversion=self.placement_request_microversion))
+ cls.setup_api_microversion_fixture(
+ compute_microversion=cls.compute_request_microversion,
+ volume_microversion=cls.volume_request_microversion,
+ placement_microversion=cls.placement_request_microversion)
def setup_compute_client(cls):
"""Compute client"""
diff --git a/tempest/test.py b/tempest/test.py
index 8ea3b16..bf0aba4 100644
--- a/tempest/test.py
+++ b/tempest/test.py
@@ -27,6 +27,7 @@
from tempest.common import utils
from tempest import config
from tempest.lib import base as lib_base
+from tempest.lib.common import api_microversion_fixture
from tempest.lib.common import fixed_network
from tempest.lib.common import profiler
from tempest.lib.common import validation_resources as vr
@@ -480,6 +481,34 @@
pass
@classmethod
+ def setup_api_microversion_fixture(
+ cls, compute_microversion=None, volume_microversion=None,
+ placement_microversion=None):
+ """Set up api microversion fixture on service clients.
+
+ `setup_api_microversion_fixture` is used to set the api microversion
+ on service clients. This can be invoked from resource_setup() method.
+
+ Example::
+
+ @classmethod
+ def resource_setup(cls):
+ super(MyTest, cls).resource_setup()
+ cls.setup_api_microversion_fixture(
+ compute_microversion=cls.compute_request_microversion,
+ volume_microversion=cls.volume_request_microversion,
+ placement_microversion=cls.placement_request_microversion)
+
+ """
+
+ api_fixture = api_microversion_fixture.APIMicroversionFixture(
+ compute_microversion=compute_microversion,
+ volume_microversion=volume_microversion,
+ placement_microversion=placement_microversion)
+ api_fixture.setUp()
+ cls.addClassResourceCleanup(api_fixture._reset_microversion)
+
+ @classmethod
def resource_setup(cls):
"""Class level resource setup for test cases.
diff --git a/tempest/tests/lib/services/network/test_routers_client.py b/tempest/tests/lib/services/network/test_routers_client.py
index f5dcc7d..20b6853 100644
--- a/tempest/tests/lib/services/network/test_routers_client.py
+++ b/tempest/tests/lib/services/network/test_routers_client.py
@@ -95,6 +95,67 @@
}
}
+ FAKE_ROUTER_ID = "f8a44de0-fc8e-45df-93c7-f79bf3b01c95"
+ FAKE_INTERFACE = {
+ "id": "915a14a6-867b-4af7-83d1-70efceb146f9",
+ "network_id": "91c013e2-d65a-474e-9177-c3e1799ca726",
+ "port_id": "2dc46bcc-d1f2-4077-b99e-91ee28afaff0",
+ "subnet_id": "a2f1f29d-571b-4533-907f-5803ab96ead1",
+ "subnet_ids": [
+ "a2f1f29d-571b-4533-907f-5803ab96ead1"
+ ],
+ "project_id": "0bd18306d801447bb457a46252d82d13",
+ "tenant_id": "0bd18306d801447bb457a46252d82d13",
+ "tags": ["tag1,tag2"]
+ }
+ FAKE_INTERFACE_KWARGS = {
+ "subnet_id": "a2f1f29d-571b-4533-907f-5803ab96ead1"
+ }
+ FAKE_SHOW_ROUTER = {
+ "router": {
+ "admin_state_up": "true",
+ "availability_zone_hints": [],
+ "availability_zones": [
+ "nova"
+ ],
+ "created_at": "2018-03-19T19:17:04Z",
+ "description": "",
+ "distributed": "false",
+ "external_gateway_info": {
+ "enable_snat": "true",
+ "external_fixed_ips": [
+ {
+ "ip_address": "172.24.4.6",
+ "subnet_id": "b930d7f6-ceb7-40a0-8b81-a425dd994ccf"
+ },
+ {
+ "ip_address": "2001:db8::9",
+ "subnet_id": "0c56df5d-ace5-46c8-8f4c-45fa4e334d18"
+ }
+ ],
+ "network_id": "ae34051f-aa6c-4c75-abf5-50dc9ac99ef3"
+ },
+ "flavor_id": "f7b14d9a-b0dc-4fbe-bb14-a0f4970a69e0",
+ "ha": "false",
+ "id": "f8a44de0-fc8e-45df-93c7-f79bf3b01c95",
+ "name": "router1",
+ "revision_number": 1,
+ "routes": [
+ {
+ "destination": "179.24.1.0/24",
+ "nexthop": "172.24.3.99"
+ }
+ ],
+ "status": "ACTIVE",
+ "updated_at": "2018-03-19T19:17:22Z",
+ "project_id": "0bd18306d801447bb457a46252d82d13",
+ "tenant_id": "0bd18306d801447bb457a46252d82d13",
+ "service_type_id": "null",
+ "tags": ["tag1,tag2"],
+ "conntrack_helpers": []
+ }
+ }
+
def setUp(self):
super(TestRoutersClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
@@ -116,6 +177,15 @@
bytes_body,
name="another_router", admin_state_up="true", status=201)
+ def _test_show_router(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.show_router,
+ "tempest.lib.common.rest_client.RestClient.get",
+ self.FAKE_SHOW_ROUTER,
+ bytes_body,
+ 200,
+ router_id=self.FAKE_ROUTER_ID)
+
def _test_update_router(self, bytes_body=False):
self.check_service_client_function(
self.client.update_router,
@@ -125,6 +195,24 @@
router_id="8604a0de-7f6b-409a-a47c-a1cc7bc77b2e",
admin_state_up=False)
+ def _test_add_router_interface(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.add_router_interface,
+ 'tempest.lib.common.rest_client.RestClient.put',
+ self.FAKE_INTERFACE,
+ bytes_body,
+ router_id=self.FAKE_ROUTER_ID,
+ **self.FAKE_INTERFACE_KWARGS)
+
+ def _test_remove_router_interface(self, bytes_body=False):
+ self.check_service_client_function(
+ self.client.remove_router_interface,
+ 'tempest.lib.common.rest_client.RestClient.put',
+ self.FAKE_INTERFACE,
+ bytes_body,
+ router_id=self.FAKE_ROUTER_ID,
+ **self.FAKE_INTERFACE_KWARGS)
+
def test_list_routers_with_str_body(self):
self._test_list_routers()
@@ -148,3 +236,21 @@
def test_update_router_with_bytes_body(self):
self._test_update_router(bytes_body=True)
+
+ def test_show_router_with_str_body(self):
+ self._test_show_router()
+
+ def test_show_router_with_bytes_body(self):
+ self._test_show_router(bytes_body=True)
+
+ def test_add_router_interface_with_str_body(self):
+ self._test_add_router_interface()
+
+ def test_add_router_interface_with_bytes_body(self):
+ self._test_add_router_interface(bytes_body=True)
+
+ def test_remove_router_interface_with_str_body(self):
+ self._test_remove_router_interface()
+
+ def test_remove_router_interface_with_bytes_body(self):
+ self._test_remove_router_interface(bytes_body=True)
diff --git a/tempest/tests/lib/services/network/test_subnetpools_client.py b/tempest/tests/lib/services/network/test_subnetpools_client.py
index 3abb438..2dfa25e 100644
--- a/tempest/tests/lib/services/network/test_subnetpools_client.py
+++ b/tempest/tests/lib/services/network/test_subnetpools_client.py
@@ -26,13 +26,13 @@
"subnetpools": [
{
"min_prefixlen": "64",
- "address_scope_id": None,
+ "address_scope_id": "null",
"default_prefixlen": "64",
"id": "03f761e6-eee0-43fc-a921-8acf64c14988",
"max_prefixlen": "64",
"name": "my-subnet-pool-ipv6",
- "default_quota": None,
- "is_default": False,
+ "default_quota": "null",
+ "is_default": "false",
"project_id": "9fadcee8aa7c40cdb2114fff7d569c08",
"tenant_id": "9fadcee8aa7c40cdb2114fff7d569c08",
"prefixes": [
@@ -40,19 +40,22 @@
"2001:db8::/63"
],
"ip_version": 6,
- "shared": False,
+ "shared": "false",
"description": "",
- "revision_number": 2
+ "created_at": "2016-03-08T20:19:41",
+ "updated_at": "2016-03-08T20:19:41",
+ "revision_number": 2,
+ "tags": ["tag1,tag2"]
},
{
"min_prefixlen": "24",
- "address_scope_id": None,
+ "address_scope_id": "null",
"default_prefixlen": "25",
"id": "f49a1319-423a-4ee6-ba54-1d95a4f6cc68",
"max_prefixlen": "30",
"name": "my-subnet-pool-ipv4",
- "default_quota": None,
- "is_default": False,
+ "default_quota": "null",
+ "is_default": "false",
"project_id": "9fadcee8aa7c40cdb2114fff7d569c08",
"tenant_id": "9fadcee8aa7c40cdb2114fff7d569c08",
"prefixes": [
@@ -60,9 +63,12 @@
"192.168.0.0/16"
],
"ip_version": 4,
- "shared": False,
+ "shared": "false",
"description": "",
- "revision_number": 2
+ "created_at": "2016-03-08T20:19:41",
+ "updated_at": "2016-03-08T20:19:41",
+ "revision_number": 2,
+ "tags": ["tag1,tag2"]
}
]
}
diff --git a/tempest/tests/test_test.py b/tempest/tests/test_test.py
index 9aeedb3..a95914a 100644
--- a/tempest/tests/test_test.py
+++ b/tempest/tests/test_test.py
@@ -24,6 +24,9 @@
from tempest import config
from tempest.lib.common import validation_resources as vr
from tempest.lib import exceptions as lib_exc
+from tempest.lib.services.compute import base_compute_client
+from tempest.lib.services.placement import base_placement_client
+from tempest.lib.services.volume import base_client as base_volume_client
from tempest import test
from tempest.tests import base
from tempest.tests import fake_config
@@ -749,3 +752,186 @@
self.test.fixtures_invoked)
found_exc = log[0][1][1]
self.assertIn(expected_exc, str(found_exc))
+
+
+class TestAPIMicroversionTest1(test.BaseTestCase):
+
+ @classmethod
+ def resource_setup(cls):
+ super(TestAPIMicroversionTest1, cls).resource_setup()
+ # Setting microvesions and checks that every tests
+ # of this class will have those microversion set
+ # on service clients requesting service APIs.
+ cls.setup_api_microversion_fixture(
+ compute_microversion='2.30',
+ volume_microversion='3.10',
+ placement_microversion='3.1')
+ # Check microvesion is set during resource_setup()
+ if base_compute_client.COMPUTE_MICROVERSION != '2.30':
+ raise testtools.TestCase.failureException(
+ "Microversion is not set in resource_setup method")
+ if base_volume_client.VOLUME_MICROVERSION != '3.10':
+ raise testtools.TestCase.failureException(
+ "Microversion is not set in resource_setup method")
+ if base_placement_client.PLACEMENT_MICROVERSION != '3.1':
+ raise testtools.TestCase.failureException(
+ "Microversion is not set in resource_setup method")
+
+ @classmethod
+ def resource_cleanup(cls):
+ super(TestAPIMicroversionTest1, cls).resource_cleanup()
+ # Check microversion is reset back to None in resource_cleanup()
+ if base_compute_client.COMPUTE_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not reset to None in resource_cleanup method")
+ if base_volume_client.VOLUME_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not reset to None in resource_cleanup method")
+ if base_placement_client.PLACEMENT_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not reset to None in resource_cleanup method")
+
+ def setUp(self):
+ super(TestAPIMicroversionTest1, self).setUp()
+ # Check microversion is set in setUp method also.
+ self.assertEqual('2.30', base_compute_client.COMPUTE_MICROVERSION)
+ self.assertEqual('3.10', base_volume_client.VOLUME_MICROVERSION)
+ self.assertEqual('3.1', base_placement_client.PLACEMENT_MICROVERSION)
+
+ def tearDown(self):
+ super(TestAPIMicroversionTest1, self).tearDown()
+ # Check microversion is set in tearDown method also.
+ self.assertEqual('2.30', base_compute_client.COMPUTE_MICROVERSION)
+ self.assertEqual('3.10', base_volume_client.VOLUME_MICROVERSION)
+ self.assertEqual('3.1', base_placement_client.PLACEMENT_MICROVERSION)
+
+ def test_1(self):
+ self.assertEqual('2.30', base_compute_client.COMPUTE_MICROVERSION)
+ self.assertEqual('3.10', base_volume_client.VOLUME_MICROVERSION)
+ self.assertEqual('3.1', base_placement_client.PLACEMENT_MICROVERSION)
+
+ def test_2(self):
+ self.assertEqual('2.30', base_compute_client.COMPUTE_MICROVERSION)
+ self.assertEqual('3.10', base_volume_client.VOLUME_MICROVERSION)
+ self.assertEqual('3.1', base_placement_client.PLACEMENT_MICROVERSION)
+
+
+class TestAPIMicroversionTest2(test.BaseTestCase):
+
+ @classmethod
+ def resource_setup(cls):
+ super(TestAPIMicroversionTest2, cls).resource_setup()
+ # Setting microvesions different from what set in
+ # MicroversionTest1 and checks that every tests
+ # of this class will have the new microversion set
+ # on service clients requesting service APIs.
+ cls.setup_api_microversion_fixture(
+ compute_microversion='2.80',
+ volume_microversion='3.80',
+ placement_microversion='3.8')
+ # Check microvesion is set during resource_setup()
+ if base_compute_client.COMPUTE_MICROVERSION != '2.80':
+ raise testtools.TestCase.failureException(
+ "Microversion is not set in resource_setup method")
+ if base_volume_client.VOLUME_MICROVERSION != '3.80':
+ raise testtools.TestCase.failureException(
+ "Microversion is not set in resource_setup method")
+ if base_placement_client.PLACEMENT_MICROVERSION != '3.8':
+ raise testtools.TestCase.failureException(
+ "Microversion is not set in resource_setup method")
+
+ @classmethod
+ def resource_cleanup(cls):
+ super(TestAPIMicroversionTest2, cls).resource_cleanup()
+ # Check microversion is reset back to None in resource_cleanup()
+ if base_compute_client.COMPUTE_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not reset to None in resource_cleanup method")
+ if base_volume_client.VOLUME_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not reset to None in resource_cleanup method")
+ if base_placement_client.PLACEMENT_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not reset to None in resource_cleanup method")
+
+ def setUp(self):
+ super(TestAPIMicroversionTest2, self).setUp()
+ # Check microversion is set in setUp method also.
+ self.assertEqual('2.80', base_compute_client.COMPUTE_MICROVERSION)
+ self.assertEqual('3.80', base_volume_client.VOLUME_MICROVERSION)
+ self.assertEqual('3.8', base_placement_client.PLACEMENT_MICROVERSION)
+
+ def tearDown(self):
+ super(TestAPIMicroversionTest2, self).tearDown()
+ # Check microversion is set in tearDown method also.
+ self.assertEqual('2.80', base_compute_client.COMPUTE_MICROVERSION)
+ self.assertEqual('3.80', base_volume_client.VOLUME_MICROVERSION)
+ self.assertEqual('3.8', base_placement_client.PLACEMENT_MICROVERSION)
+
+ def test_1(self):
+ self.assertEqual('2.80', base_compute_client.COMPUTE_MICROVERSION)
+ self.assertEqual('3.80', base_volume_client.VOLUME_MICROVERSION)
+ self.assertEqual('3.8', base_placement_client.PLACEMENT_MICROVERSION)
+
+ def test_2(self):
+ self.assertEqual('2.80', base_compute_client.COMPUTE_MICROVERSION)
+ self.assertEqual('3.80', base_volume_client.VOLUME_MICROVERSION)
+ self.assertEqual('3.8', base_placement_client.PLACEMENT_MICROVERSION)
+
+
+class TestAPIMicroversionTest3(test.BaseTestCase):
+
+ @classmethod
+ def resource_setup(cls):
+ super(TestAPIMicroversionTest3, cls).resource_setup()
+ # Not setting microversion for this test class so
+ # there should not be any micorversion set on service
+ # clients requesting services APIs.
+ # Check microvesion is not set during resource_setup()
+ if base_compute_client.COMPUTE_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not set in resource_setup method")
+ if base_volume_client.VOLUME_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not set in resource_setup method")
+ if base_placement_client.PLACEMENT_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not set in resource_setup method")
+
+ @classmethod
+ def resource_cleanup(cls):
+ super(TestAPIMicroversionTest3, cls).resource_cleanup()
+ # Check microversion is set to None in resource_cleanup()
+ if base_compute_client.COMPUTE_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not reset to None in resource_cleanup method")
+ if base_volume_client.VOLUME_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not reset to None in resource_cleanup method")
+ if base_placement_client.PLACEMENT_MICROVERSION is not None:
+ raise testtools.TestCase.failureException(
+ "Microversion is not reset to None in resource_cleanup method")
+
+ def setUp(self):
+ super(TestAPIMicroversionTest3, self).setUp()
+ # Check microversion is None in setUp method also.
+ self.assertIsNone(base_compute_client.COMPUTE_MICROVERSION)
+ self.assertIsNone(base_volume_client.VOLUME_MICROVERSION)
+ self.assertIsNone(base_placement_client.PLACEMENT_MICROVERSION)
+
+ def tearDown(self):
+ super(TestAPIMicroversionTest3, self).tearDown()
+ # Check microversion is None in tearDown method also.
+ self.assertIsNone(base_compute_client.COMPUTE_MICROVERSION)
+ self.assertIsNone(base_volume_client.VOLUME_MICROVERSION)
+ self.assertIsNone(base_placement_client.PLACEMENT_MICROVERSION)
+
+ def test_1(self):
+ self.assertIsNone(base_compute_client.COMPUTE_MICROVERSION)
+ self.assertIsNone(base_volume_client.VOLUME_MICROVERSION)
+ self.assertIsNone(base_placement_client.PLACEMENT_MICROVERSION)
+
+ def test_2(self):
+ self.assertIsNone(base_compute_client.COMPUTE_MICROVERSION)
+ self.assertIsNone(base_volume_client.VOLUME_MICROVERSION)
+ self.assertIsNone(base_placement_client.PLACEMENT_MICROVERSION)