"""Test Case for FibreChannelDriver."""
driver_name = "cinder.volume.driver.FibreChannelDriver"
- def test_initialize_connection(self):
+ def setUp(self):
+ super(FibreChannelTestCase, self).setUp()
self.driver = driver.FibreChannelDriver()
self.driver.do_setup(None)
+
+ def test_initialize_connection(self):
self.assertRaises(NotImplementedError,
self.driver.initialize_connection, {}, {})
+ def test_validate_connector(self):
+ """validate_connector() successful use case.
+
+ validate_connector() does not throw an exception when
+ wwpns and wwnns are both set and both are not empty.
+ """
+ connector = {'wwpns': ["not empty"],
+ 'wwnns': ["not empty"]}
+ self.driver.validate_connector(connector)
+
+ def test_validate_connector_no_wwpns(self):
+ """validate_connector() throws exception when it has no wwpns."""
+ connector = {'wwnns': ["not empty"]}
+ self.assertRaises(exception.VolumeDriverException,
+ self.driver.validate_connector, connector)
+
+ def test_validate_connector_empty_wwpns(self):
+ """validate_connector() throws exception when it has empty wwpns."""
+ connector = {'wwpns': [],
+ 'wwnns': ["not empty"]}
+ self.assertRaises(exception.VolumeDriverException,
+ self.driver.validate_connector, connector)
+
+ def test_validate_connector_no_wwnns(self):
+ """validate_connector() throws exception when it has no wwnns."""
+ connector = {'wwpns': ["not empty"]}
+ self.assertRaises(exception.VolumeDriverException,
+ self.driver.validate_connector, connector)
+
+ def test_validate_connector_empty_wwnns(self):
+ """validate_connector() throws exception when it has empty wwnns."""
+ connector = {'wwnns': [],
+ 'wwpns': ["not empty"]}
+ self.assertRaises(exception.VolumeDriverException,
+ self.driver.validate_connector, connector)
+
class VolumePolicyTestCase(test.TestCase):
"""
msg = _("Driver must implement initialize_connection")
raise NotImplementedError(msg)
+
+ def validate_connector(self, connector):
+ """Fail if connector doesn't contain all the data needed by driver.
+
+ Do a check on the connector and ensure that it has wwnns, wwpns.
+ """
+ self.validate_connector_has_setting(connector, 'wwpns')
+ self.validate_connector_has_setting(connector, 'wwnns')
+
+ @staticmethod
+ def validate_connector_has_setting(connector, setting):
+ """Test for non-empty setting in connector."""
+ if setting not in connector or not connector[setting]:
+ msg = (_(
+ "FibreChannelDriver validate_connector failed. "
+ "No '%s'. Make sure HBA state is Online.") % setting)
+ LOG.error(msg)
+ raise exception.VolumeDriverException(message=msg)