summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-07-27 00:36:41 +0000
committerGerrit Code Review <review@openstack.org>2017-07-27 00:36:41 +0000
commit1c6845def904899f999d3f2579d7cc082c746ce2 (patch)
tree0588d05eb5a8745c097bb7f90e6d16009c2a2db0
parentc5545e861c8ee069a6e8c7b710b8813d8cb77012 (diff)
parent032af06a6f514560a8e4574089b9c0dcb5bf112f (diff)
Merge "Backport for scenario tests access fixes" into stable/newtonnewton-eol
-rw-r--r--manila_tempest_tests/tests/scenario/test_share_basic_ops.py40
1 files changed, 29 insertions, 11 deletions
diff --git a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
index 532ddd5..02bada4 100644
--- a/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
+++ b/manila_tempest_tests/tests/scenario/test_share_basic_ops.py
@@ -53,6 +53,14 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
53 # Support both configured and injected values 53 # Support both configured and injected values
54 if not hasattr(self, 'flavor_ref'): 54 if not hasattr(self, 'flavor_ref'):
55 self.flavor_ref = CONF.share.client_vm_flavor_ref 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 if CONF.share.image_with_share_tools: 64 if CONF.share.image_with_share_tools:
57 images = self.compute_images_client.list_images()["images"] 65 images = self.compute_images_client.list_images()["images"]
58 for img in images: 66 for img in images:
@@ -90,6 +98,7 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
90 # Obtain a floating IP 98 # Obtain a floating IP
91 floating_ip = (self.compute_floating_ips_client.create_floating_ip() 99 floating_ip = (self.compute_floating_ips_client.create_floating_ip()
92 ['floating_ip']) 100 ['floating_ip'])
101 self.floatings[instance['id']] = floating_ip
93 self.addCleanup(test_utils.call_and_ignore_notfound_exc, 102 self.addCleanup(test_utils.call_and_ignore_notfound_exc,
94 self.compute_floating_ips_client.delete_floating_ip, 103 self.compute_floating_ips_client.delete_floating_ip,
95 floating_ip['id']) 104 floating_ip['id'])
@@ -178,6 +187,18 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
178 self._allow_access(share_id, access_type='ip', access_to=ip, 187 self._allow_access(share_id, access_type='ip', access_to=ip,
179 cleanup=cleanup) 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 def wait_for_active_instance(self, instance_id): 202 def wait_for_active_instance(self, instance_id):
182 waiters.wait_for_server_status( 203 waiters.wait_for_server_status(
183 self.manager.servers_client, instance_id, "ACTIVE") 204 self.manager.servers_client, instance_id, "ACTIVE")
@@ -189,10 +210,10 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
189 instance = self.boot_instance(wait_until="BUILD") 210 instance = self.boot_instance(wait_until="BUILD")
190 self.create_share() 211 self.create_share()
191 instance = self.wait_for_active_instance(instance["id"]) 212 instance = self.wait_for_active_instance(instance["id"])
192 self.allow_access_ip(self.share['id'], instance=instance,
193 cleanup=False)
194 ssh_client = self.init_ssh(instance) 213 ssh_client = self.init_ssh(instance)
195 214
215 self.provide_access_to_auxiliary_instance(instance)
216
196 if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"): 217 if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"):
197 locations = self.share['export_locations'] 218 locations = self.share['export_locations']
198 else: 219 else:
@@ -219,9 +240,8 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
219 instance2 = self.wait_for_active_instance(instance2["id"]) 240 instance2 = self.wait_for_active_instance(instance2["id"])
220 241
221 # Write data to first VM 242 # Write data to first VM
222 self.allow_access_ip(self.share['id'], instance=instance1,
223 cleanup=False)
224 ssh_client_inst1 = self.init_ssh(instance1) 243 ssh_client_inst1 = self.init_ssh(instance1)
244 self.provide_access_to_auxiliary_instance(instance1)
225 245
226 if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"): 246 if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"):
227 locations = self.share['export_locations'] 247 locations = self.share['export_locations']
@@ -236,9 +256,8 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
236 self.write_data(test_data, ssh_client_inst1) 256 self.write_data(test_data, ssh_client_inst1)
237 257
238 # Read from second VM 258 # Read from second VM
239 self.allow_access_ip(
240 self.share['id'], instance=instance2, cleanup=False)
241 ssh_client_inst2 = self.init_ssh(instance2) 259 ssh_client_inst2 = self.init_ssh(instance2)
260 self.provide_access_to_auxiliary_instance(instance2)
242 self.mount_share(locations[0], ssh_client_inst2) 261 self.mount_share(locations[0], ssh_client_inst2)
243 self.addCleanup(self.umount_share, 262 self.addCleanup(self.umount_share,
244 ssh_client_inst2) 263 ssh_client_inst2)
@@ -252,7 +271,7 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
252 "Share migration tests are disabled.") 271 "Share migration tests are disabled.")
253 def test_migration_files(self): 272 def test_migration_files(self):
254 273
255 if self.protocol != "NFS": 274 if self.protocol != "nfs":
256 raise self.skipException("Only NFS protocol supported " 275 raise self.skipException("Only NFS protocol supported "
257 "at this moment.") 276 "at this moment.")
258 277
@@ -278,9 +297,8 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
278 297
279 dest_pool = dest_pool['name'] 298 dest_pool = dest_pool['name']
280 299
281 self.allow_access_ip(
282 self.share['id'], instance=instance, cleanup=False)
283 ssh_client = self.init_ssh(instance) 300 ssh_client = self.init_ssh(instance)
301 self.provide_access_to_auxiliary_instance(instance)
284 302
285 if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"): 303 if utils.is_microversion_lt(CONF.share.max_api_microversion, "2.9"):
286 exports = self.share['export_locations'] 304 exports = self.share['export_locations']
@@ -348,14 +366,14 @@ class ShareBasicOpsBase(manager.ShareScenarioTest):
348 366
349 367
350class TestShareBasicOpsNFS(ShareBasicOpsBase): 368class TestShareBasicOpsNFS(ShareBasicOpsBase):
351 protocol = "NFS" 369 protocol = "nfs"
352 370
353 def mount_share(self, location, ssh_client): 371 def mount_share(self, location, ssh_client):
354 ssh_client.exec_command("sudo mount -vt nfs \"%s\" /mnt" % location) 372 ssh_client.exec_command("sudo mount -vt nfs \"%s\" /mnt" % location)
355 373
356 374
357class TestShareBasicOpsCIFS(ShareBasicOpsBase): 375class TestShareBasicOpsCIFS(ShareBasicOpsBase):
358 protocol = "CIFS" 376 protocol = "cifs"
359 377
360 def mount_share(self, location, ssh_client): 378 def mount_share(self, location, ssh_client):
361 location = location.replace("\\", "/") 379 location = location.replace("\\", "/")