]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Reduce runtime of E-Series iSCSI tests
authorMichael Price <michael.price@netapp.com>
Wed, 5 Aug 2015 17:58:21 +0000 (12:58 -0500)
committerMichael Price <michael.price@netapp.com>
Wed, 26 Aug 2015 19:25:41 +0000 (19:25 +0000)
This patch improves the runtime of the connectivity-related tests
by mocking out network activity where it is expected to timeout.

Change-Id: I61029b7a4057c789e329b390b17bdab80f3085a9

cinder/tests/unit/test_netapp_eseries_iscsi.py

index e48d89861314ee4f7d594adb7e626264955d93a9..e9139dc56180333ce3232400c35392aa5a0c1452 100644 (file)
@@ -19,6 +19,7 @@
 import copy
 import json
 import re
+import socket
 
 import mock
 import requests
@@ -916,6 +917,9 @@ class NetAppEseriesISCSIDriverTestCase(test.TestCase):
         configuration = self._set_config(create_configuration())
         configuration.netapp_controller_ips = '987.65.43.21'
         driver = common.NetAppDriver(configuration=configuration)
+        self.mock_object(na_utils, 'resolve_hostname',
+                         mock.Mock(side_effect=socket.gaierror))
+
         self.assertRaises(
             exception.NoValidHost,
             driver.library._check_mode_get_or_register_storage_system)
@@ -924,6 +928,9 @@ class NetAppEseriesISCSIDriverTestCase(test.TestCase):
         configuration = self._set_config(create_configuration())
         configuration.netapp_controller_ips = '987.65.43.21,127.0.0.1'
         driver = common.NetAppDriver(configuration=configuration)
+        self.mock_object(na_utils, 'resolve_hostname',
+                         mock.Mock(side_effect=socket.gaierror))
+
         self.assertRaises(
             exception.NoValidHost,
             driver.library._check_mode_get_or_register_storage_system)
@@ -932,6 +939,9 @@ class NetAppEseriesISCSIDriverTestCase(test.TestCase):
         configuration = self._set_config(create_configuration())
         configuration.netapp_controller_ips = '127.0.0.1,987.65.43.21'
         driver = common.NetAppDriver(configuration=configuration)
+        self.mock_object(na_utils, 'resolve_hostname',
+                         mock.Mock(side_effect=socket.gaierror))
+
         self.assertRaises(
             exception.NoValidHost,
             driver.library._check_mode_get_or_register_storage_system)
@@ -940,6 +950,9 @@ class NetAppEseriesISCSIDriverTestCase(test.TestCase):
         configuration = self._set_config(create_configuration())
         configuration.netapp_controller_ips = '564.124.1231.1,987.65.43.21'
         driver = common.NetAppDriver(configuration=configuration)
+        self.mock_object(na_utils, 'resolve_hostname',
+                         mock.Mock(side_effect=socket.gaierror))
+
         self.assertRaises(
             exception.NoValidHost,
             driver.library._check_mode_get_or_register_storage_system)