From 5e264e2903a595f150247e632e3cd29141418430 Mon Sep 17 00:00:00 2001 From: Michael Price Date: Wed, 5 Aug 2015 12:58:21 -0500 Subject: [PATCH] Reduce runtime of E-Series iSCSI tests 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cinder/tests/unit/test_netapp_eseries_iscsi.py b/cinder/tests/unit/test_netapp_eseries_iscsi.py index e48d89861..e9139dc56 100644 --- a/cinder/tests/unit/test_netapp_eseries_iscsi.py +++ b/cinder/tests/unit/test_netapp_eseries_iscsi.py @@ -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) -- 2.45.2