From: Lucas Alvares Gomes Date: Thu, 31 Jan 2013 00:16:15 +0000 (+0000) Subject: Add unit tests for ISCSIDriver._do_iscsi_discovery and ISCSIDriver._get_iscsi_properties X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=f2b94c0607dc521d38a95d93312325873e7abf63;p=openstack-build%2Fcinder-build.git Add unit tests for ISCSIDriver._do_iscsi_discovery and ISCSIDriver._get_iscsi_properties Change-Id: Id62124247e264a248ca071d45c03969ee75a31d3 --- diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 1f35c43f4..6170da2e9 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -41,6 +41,7 @@ from cinder import quota from cinder import test from cinder.tests import fake_flags from cinder.tests.image import fake as fake_image +from cinder.volume import driver from cinder.volume import iscsi QUOTAS = quota.QUOTAS @@ -944,6 +945,25 @@ class ISCSITestCase(DriverTestCase): return volume_id_list + def test_do_iscsi_discovery(self): + iscsi_driver = driver.ISCSIDriver() + iscsi_driver._execute = lambda *a, **kw: \ + ("%s dummy" % FLAGS.iscsi_ip_address, '') + volume = {"name": "dummy", + "host": "0.0.0.0"} + iscsi_driver._do_iscsi_discovery(volume) + + def test_get_iscsi_properties(self): + volume = {"provider_location": '', + "id": "0", + "provider_auth": "a b c"} + iscsi_driver = driver.ISCSIDriver() + iscsi_driver._do_iscsi_discovery = lambda v: "0.0.0.0:0000,0 iqn:iqn 0" + result = iscsi_driver._get_iscsi_properties(volume) + self.assertEquals(result["target_portal"], "0.0.0.0:0000") + self.assertEquals(result["target_iqn"], "iqn:iqn") + self.assertEquals(result["target_lun"], 0) + class VolumePolicyTestCase(test.TestCase):