]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Mock wait_for_volume_removal in test_brick_connector
authorJay S. Bryant <jsbryant@us.ibm.com>
Fri, 3 Apr 2015 19:19:28 +0000 (14:19 -0500)
committerJay S. Bryant <jsbryant@us.ibm.com>
Fri, 3 Apr 2015 19:27:33 +0000 (14:27 -0500)
Systems where /dev/disk/by-path did exist were failing unit
test for test_connect_volume, test_connect_volume_with_alternative_targets
and test_connect_volume_with_alternative_targets_primary_error in
cinder.tests.test_brick_connector .  The problem was that the test
cases were mocking out os.path to return exists.  This resulted in
the new code from commit 43029941219505bc3861dd285e3393e08c76b433
never being able to exit the wait_for_volume_removal loop.

To avoid this problem I am mocking out wait_for_volume_removal for these
test cases.  wait_for_volume_removal is tested elsewhere and not relevant
for these test cases.

Change-Id: Ib7f75c852f9c79f261e319be0c1e3fd21acab8f1
Closes-bug: 1440153

cinder/tests/brick/test_brick_connector.py

index 4a55cb5e15e4b9c1455a0356dc24b83a71454e09..cc2509f6074324936865cab25089c1cf2c069f65 100644 (file)
@@ -27,6 +27,7 @@ from cinder.brick import exception
 from cinder.brick.initiator import connector
 from cinder.brick.initiator import host_driver
 from cinder.brick.initiator import linuxfc
+from cinder.brick.initiator import linuxscsi
 from cinder.i18n import _LE
 from cinder.openstack.common import loopingcall
 from cinder import test
@@ -267,12 +268,17 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
 
     @test.testtools.skipUnless(os.path.exists('/dev/disk/by-path'),
                                'Test requires /dev/disk/by-path')
-    def test_connect_volume(self):
+    @mock.patch.object(linuxscsi.LinuxSCSI, 'wait_for_volume_removal',
+                       return_value=None)
+    def test_connect_volume(self, mock_wait_for_vol_rem):
         self._test_connect_volume({}, [])
 
     @test.testtools.skipUnless(os.path.exists('/dev/disk/by-path'),
                                'Test requires /dev/disk/by-path')
-    def test_connect_volume_with_alternative_targets(self):
+    @mock.patch.object(linuxscsi.LinuxSCSI, 'wait_for_volume_removal',
+                       return_value=None)
+    def test_connect_volume_with_alternative_targets(self,
+                                                     mock_wait_for_vol_rem):
         location = '10.0.2.15:3260'
         location2 = '10.0.3.15:3260'
         iqn = 'iqn.2010-10.org.openstack:volume-00000001'
@@ -295,8 +301,10 @@ class ISCSIConnectorTestCase(ConnectorTestCase):
                                'Test requires /dev/disk/by-path')
     @mock.patch.object(os.path, 'exists')
     @mock.patch.object(connector.ISCSIConnector, '_run_iscsiadm')
+    @mock.patch.object(linuxscsi.LinuxSCSI, 'wait_for_volume_removal',
+                       return_value=None)
     def test_connect_volume_with_alternative_targets_primary_error(
-            self, mock_iscsiadm, mock_exists):
+            self, mock_wait_for_vol_rem, mock_iscsiadm, mock_exists):
         location = '10.0.2.15:3260'
         location2 = '10.0.3.15:3260'
         name = 'volume-00000001'