Browse Source

Merge "Backport for scenario tests access fixes" into stable/newton

tags/newton-eol^0
Jenkins 2 years ago
parent
commit
1c6845def9
1 changed files with 29 additions and 11 deletions
  1. 29
    11
      manila_tempest_tests/tests/scenario/test_share_basic_ops.py

+ 29
- 11
manila_tempest_tests/tests/scenario/test_share_basic_ops.py View File

@@ -53,6 +53,14 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
53 53
         # Support both configured and injected values
54 54
         if not hasattr(self, 'flavor_ref'):
55 55
             self.flavor_ref = CONF.share.client_vm_flavor_ref
56
+        self.floatings = {}
57
+        if self.protocol not in CONF.share.enable_protocols:
58
+            message = "%s tests are disabled" % self.protocol
59
+            raise self.skipException(message)
60
+        if self.protocol not in CONF.share.enable_ip_rules_for_protocols:
61
+            message = ("%s tests for access rules other than IP are disabled" %
62
+                       self.protocol)
63
+            raise self.skipException(message)
56 64
         if CONF.share.image_with_share_tools:
57 65
             images = self.compute_images_client.list_images()["images"]
58 66
             for img in images:
@@ -90,6 +98,7 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
90 98
         # Obtain a floating IP
91 99
         floating_ip = (self.compute_floating_ips_client.create_floating_ip()
92 100
                        ['floating_ip'])
101
+        self.floatings[instance['id']] = floating_ip
93 102
         self.addCleanup(test_utils.call_and_ignore_notfound_exc,
94 103
                         self.compute_floating_ips_client.delete_floating_ip,
95 104
                         floating_ip['id'])
@@ -178,6 +187,18 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
178 187
         self._allow_access(share_id, access_type='ip', access_to=ip,
179 188
                            cleanup=cleanup)
180 189
 
190
+    def provide_access_to_auxiliary_instance(self, instance, share=None):
191
+        share = share or self.share
192
+        if self.protocol.lower() == 'cifs':
193
+            self.allow_access_ip(share['id'], instance=instance, cleanup=False)
194
+        elif not CONF.share.multitenancy_enabled:
195
+            self.allow_access_ip(
196
+                share['id'], ip=self.floatings[instance['id']]['ip'],
197
+                instance=instance, cleanup=False)
198
+        elif (CONF.share.multitenancy_enabled and
199
+              self.protocol.lower() == 'nfs'):
200
+            self.allow_access_ip(share['id'], instance=instance, cleanup=False)
201
+
181 202
     def wait_for_active_instance(self, instance_id):
182 203
         waiters.wait_for_server_status(
183 204
             self.manager.servers_client, instance_id, "ACTIVE")
@@ -189,10 +210,10 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
189 210
         instance = self.boot_instance(wait_until="BUILD")
190 211
         self.create_share()
191 212
         instance = self.wait_for_active_instance(instance["id"])
192
-        self.allow_access_ip(self.share['id'], instance=instance,
193
-                             cleanup=False)
194 213
         ssh_client = self.init_ssh(instance)
195 214
 
215
+        self.provide_access_to_auxiliary_instance(instance)
216
+
196 217
         if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"):
197 218
             locations = self.share['export_locations']
198 219
         else:
@@ -219,9 +240,8 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
219 240
         instance2 = self.wait_for_active_instance(instance2["id"])
220 241
 
221 242
         # Write data to first VM
222
-        self.allow_access_ip(self.share['id'], instance=instance1,
223
-                             cleanup=False)
224 243
         ssh_client_inst1 = self.init_ssh(instance1)
244
+        self.provide_access_to_auxiliary_instance(instance1)
225 245
 
226 246
         if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"):
227 247
             locations = self.share['export_locations']
@@ -236,9 +256,8 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
236 256
         self.write_data(test_data, ssh_client_inst1)
237 257
 
238 258
         # Read from second VM
239
-        self.allow_access_ip(
240
-            self.share['id'], instance=instance2, cleanup=False)
241 259
         ssh_client_inst2 = self.init_ssh(instance2)
260
+        self.provide_access_to_auxiliary_instance(instance2)
242 261
         self.mount_share(locations[0], ssh_client_inst2)
243 262
         self.addCleanup(self.umount_share,
244 263
                         ssh_client_inst2)
@@ -252,7 +271,7 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
252 271
                           "Share migration tests are disabled.")
253 272
     def test_migration_files(self):
254 273
 
255
-        if self.protocol != "NFS":
274
+        if self.protocol != "nfs":
256 275
             raise self.skipException("Only NFS protocol supported "
257 276
                                      "at this moment.")
258 277
 
@@ -278,9 +297,8 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
278 297
 
279 298
         dest_pool = dest_pool['name']
280 299
 
281
-        self.allow_access_ip(
282
-            self.share['id'], instance=instance, cleanup=False)
283 300
         ssh_client = self.init_ssh(instance)
301
+        self.provide_access_to_auxiliary_instance(instance)
284 302
 
285 303
         if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"):
286 304
             exports = self.share['export_locations']
@@ -348,14 +366,14 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
348 366
 
349 367
 
350 368
 class TestShareBasicOpsNFS(ShareBasicOpsBase):
351
-    protocol = "NFS"
369
+    protocol = "nfs"
352 370
 
353 371
     def mount_share(self, location, ssh_client):
354 372
         ssh_client.exec_command("sudo mount -vt nfs \"%s\" /mnt" % location)
355 373
 
356 374
 
357 375
 class TestShareBasicOpsCIFS(ShareBasicOpsBase):
358
-    protocol = "CIFS"
376
+    protocol = "cifs"
359 377
 
360 378
     def mount_share(self, location, ssh_client):
361 379
         location = location.replace("\\", "/")

Loading…
Cancel
Save