@@ -231,6 +231,35 @@ def _mount_share_on_instance(self, instance_ip, ssh_user_name,
231
231
command = ssh_cmd ,
232
232
verify = verify_status )
233
233
234
+ def _umount_share_on_instance (self , instance_ip , ssh_user_name ,
235
+ ssh_private_key , share_path ):
236
+ """Umount a share from a Nova instance.
237
+
238
+ The mount command is executed via SSH.
239
+
240
+ :param instance_ip: IP of the Nova instance.
241
+ :type instance_ip: string
242
+ :param ssh_user_name: SSH user name.
243
+ :type ssh_user_name: string
244
+ :param ssh_private_key: SSH private key.
245
+ :type ssh_private_key: string
246
+ :param share_path: share network path.
247
+ :type share_path: string
248
+ """
249
+ ssh_cmd = 'sudo umount {mount_dir}' .format (mount_dir = self .mount_dir )
250
+
251
+ for attempt in tenacity .Retrying (
252
+ stop = tenacity .stop_after_attempt (5 ),
253
+ wait = tenacity .wait_exponential (multiplier = 3 , min = 2 , max = 10 )):
254
+ with attempt :
255
+ openstack_utils .ssh_command (
256
+ vm_name = "instance-{}" .format (instance_ip ),
257
+ ip = instance_ip ,
258
+ username = ssh_user_name ,
259
+ privkey = ssh_private_key ,
260
+ command = ssh_cmd ,
261
+ verify = verify_status )
262
+
234
263
@tenacity .retry (
235
264
stop = tenacity .stop_after_attempt (5 ),
236
265
wait = tenacity .wait_exponential (multiplier = 3 , min = 2 , max = 10 ))
@@ -323,6 +352,23 @@ def _restart_share_instance(self):
323
352
"""
324
353
return False
325
354
355
+ def _wait_for_ceph_healthy (self ):
356
+ """Wait until the ceph health is healthy"""
357
+ logging .info ("Waiting for ceph to be healthy" )
358
+ for attempt in tenacity .Retrying (
359
+ wait = tenacity .wait_fixed (5 ),
360
+ stop = tenacity .stop_after_attempt (10 ),
361
+ reraise = True
362
+ ):
363
+ logging .info ("... testing Ceph" )
364
+ with attempt :
365
+ self .assertEqual (
366
+ zaza .model .run_on_leader (
367
+ "ceph-mon" , "sudo ceph health" )["Code" ],
368
+ "0"
369
+ )
370
+ logging .info ("...Ceph is healthy" )
371
+
326
372
def test_manila_share (self ):
327
373
"""Test that a Manila share can be accessed on two instances.
328
374
@@ -346,6 +392,10 @@ def test_manila_share(self):
346
392
fip_1 = neutron_tests .floating_ips_from_instance (instance_1 )[0 ]
347
393
fip_2 = neutron_tests .floating_ips_from_instance (instance_2 )[0 ]
348
394
395
+ # force a restart to clear out any clients that may be hanging around
396
+ # due to restarts on manila-ganesha during deployment.
397
+ self ._restart_share_instance ()
398
+ self ._wait_for_ceph_healthy ()
349
399
# Create a share
350
400
share = self .manila_client .shares .create (
351
401
share_type = self .share_type_name ,
@@ -403,3 +453,9 @@ def test_manila_share(self):
403
453
fip_2 , ssh_user_name , privkey , share_path )
404
454
self ._validate_testing_file_from_instance (
405
455
fip_2 , ssh_user_name , privkey )
456
+
457
+ # now umount the share on each instance to allow cleaning up.
458
+ self ._umount_share_on_instance (
459
+ fip_1 , ssh_user_name , privkey , share_path )
460
+ self ._umount_share_on_instance (
461
+ fip_2 , ssh_user_name , privkey , share_path )
0 commit comments