Browse Source

Use Cinder API V2 if V1 is disabled

Cinder API v1 will be removed in Mitaka. We should be able to run tests against APIv2 only.

Change-Id: I6916eb3e4b7c85f37be8b365b11ca8b48f88177c
Closes-Bug: #1479157
Related-Bug: #1467589
tags/7
Ivan Kolodyazhny 4 years ago
parent
commit
bcfc32e676

+ 5
- 1
tempest/api/compute/base.py View File

@@ -73,7 +73,6 @@ class BaseComputeTest(tempest.test.BaseTestCase):
73 73
         cls.networks_client = cls.os.networks_client
74 74
         cls.limits_client = cls.os.limits_client
75 75
         cls.volumes_extensions_client = cls.os.volumes_extensions_client
76
-        cls.volumes_client = cls.os.volumes_client
77 76
         cls.interfaces_client = cls.os.interfaces_client
78 77
         cls.fixed_ips_client = cls.os.fixed_ips_client
79 78
         cls.availability_zone_client = cls.os.availability_zone_client
@@ -88,6 +87,11 @@ class BaseComputeTest(tempest.test.BaseTestCase):
88 87
         cls.security_group_default_rules_client = (
89 88
             cls.os.security_group_default_rules_client)
90 89
 
90
+        if CONF.volume_feature_enabled.api_v1:
91
+            cls.volumes_client = cls.os.volumes_client
92
+        else:
93
+            cls.volumes_client = cls.os.volumes_v2_client
94
+
91 95
     @classmethod
92 96
     def resource_setup(cls):
93 97
         super(BaseComputeTest, cls).resource_setup()

+ 6
- 0
tempest/cmd/verify_tempest_config.py View File

@@ -144,6 +144,12 @@ def get_extension_client(os, service):
144 144
         'neutron': os.network_client,
145 145
         'swift': os.account_client,
146 146
     }
147
+    # NOTE (e0ne): Use Cinder API v2 by default because v1 is deprecated
148
+    if CONF.volume_feature_enabled.api_v2:
149
+        extensions_client['cinder'] = os.volumes_v2_extension_client
150
+    else:
151
+        extensions_client['cinder'] = os.volumes_extension_client
152
+
147 153
     if service not in extensions_client:
148 154
         print('No tempest extensions client for %s' % service)
149 155
         exit(1)

+ 16
- 4
tempest/scenario/manager.py View File

@@ -57,14 +57,19 @@ class ScenarioTest(tempest.test.BaseTestCase):
57 57
         cls.security_group_rules_client = (
58 58
             cls.manager.security_group_rules_client)
59 59
         cls.servers_client = cls.manager.servers_client
60
-        cls.volumes_client = cls.manager.volumes_client
61
-        cls.snapshots_client = cls.manager.snapshots_client
62 60
         cls.interface_client = cls.manager.interfaces_client
63 61
         # Neutron network client
64 62
         cls.network_client = cls.manager.network_client
65 63
         # Heat client
66 64
         cls.orchestration_client = cls.manager.orchestration_client
67 65
 
66
+        if CONF.volume_feature_enabled.api_v1:
67
+            cls.volumes_client = cls.manager.volumes_client
68
+            cls.snapshots_client = cls.manager.snapshots_client
69
+        else:
70
+            cls.volumes_client = cls.manager.volumes_v2_client
71
+            cls.snapshots_client = cls.manager.snapshots_v2_client
72
+
68 73
     # ## Methods to handle sync and async deletes
69 74
 
70 75
     def setUp(self):
@@ -210,7 +215,11 @@ class ScenarioTest(tempest.test.BaseTestCase):
210 215
                 cleanup_callable=self.delete_wrapper,
211 216
                 cleanup_args=[self.volumes_client.delete_volume, volume['id']])
212 217
 
213
-        self.assertEqual(name, volume['display_name'])
218
+        # NOTE(e0ne): Cinder API v2 uses name instead of display_name
219
+        if 'display_name' in volume:
220
+            self.assertEqual(name, volume['display_name'])
221
+        else:
222
+            self.assertEqual(name, volume['name'])
214 223
         self.volumes_client.wait_for_volume_status(volume['id'], 'available')
215 224
         # The volume retrieved on creation has a non-up-to-date status.
216 225
         # Retrieval after it becomes active ensures correct details.
@@ -1262,7 +1271,10 @@ class EncryptionScenarioTest(ScenarioTest):
1262 1271
     @classmethod
1263 1272
     def setup_clients(cls):
1264 1273
         super(EncryptionScenarioTest, cls).setup_clients()
1265
-        cls.admin_volume_types_client = cls.os_adm.volume_types_client
1274
+        if CONF.volume_feature_enabled.api_v1:
1275
+            cls.admin_volume_types_client = cls.os_adm.volume_types_client
1276
+        else:
1277
+            cls.admin_volume_types_client = cls.os_adm.volume_types_v2_client
1266 1278
 
1267 1279
     def _wait_for_volume_status(self, status):
1268 1280
         self.status_timeout(

+ 7
- 1
tempest/scenario/test_volume_boot_pattern.py View File

@@ -74,7 +74,13 @@ class TestVolumeBootPattern(manager.ScenarioTest):
74 74
             self.snapshots_client.wait_for_resource_deletion, snap['id'])
75 75
         self.addCleanup(self.snapshots_client.delete_snapshot, snap['id'])
76 76
         self.snapshots_client.wait_for_snapshot_status(snap['id'], 'available')
77
-        self.assertEqual(snap_name, snap['display_name'])
77
+
78
+        # NOTE(e0ne): Cinder API v2 uses name instead of display_name
79
+        if 'display_name' in snap:
80
+            self.assertEqual(snap_name, snap['display_name'])
81
+        else:
82
+            self.assertEqual(snap_name, snap['name'])
83
+
78 84
         return snap
79 85
 
80 86
     def _create_volume_from_snapshot(self, snap_id):

+ 6
- 0
tempest/tests/cmd/test_verify_tempest_config.py View File

@@ -240,7 +240,10 @@ class TestDiscovery(base.TestCase):
240 240
                                    {'alias': 'fake2'},
241 241
                                    {'alias': 'not_fake'}]}
242 242
         fake_os = mock.MagicMock()
243
+        # NOTE (e0ne): mock both v1 and v2 APIs
243 244
         fake_os.volumes_extension_client.list_extensions = fake_list_extensions
245
+        fake_os.volumes_v2_extension_client.list_extensions = (
246
+            fake_list_extensions)
244 247
         self.useFixture(mockpatch.PatchObject(
245 248
             verify_tempest_config, 'get_enabled_extensions',
246 249
             return_value=(['fake1', 'fake2', 'fake3'])))
@@ -262,7 +265,10 @@ class TestDiscovery(base.TestCase):
262 265
                                    {'alias': 'fake2'},
263 266
                                    {'alias': 'not_fake'}]}
264 267
         fake_os = mock.MagicMock()
268
+        # NOTE (e0ne): mock both v1 and v2 APIs
265 269
         fake_os.volumes_extension_client.list_extensions = fake_list_extensions
270
+        fake_os.volumes_v2_extension_client.list_extensions = (
271
+            fake_list_extensions)
266 272
         self.useFixture(mockpatch.PatchObject(
267 273
             verify_tempest_config, 'get_enabled_extensions',
268 274
             return_value=(['all'])))

Loading…
Cancel
Save