]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add unit tests for ISCSIDriver._do_iscsi_discovery and ISCSIDriver._get_iscsi_properties
authorLucas Alvares Gomes <lucasagomes@gmail.com>
Thu, 31 Jan 2013 00:16:15 +0000 (00:16 +0000)
committerLucas Alvares Gomes <lucasagomes@gmail.com>
Thu, 31 Jan 2013 13:26:43 +0000 (13:26 +0000)
Change-Id: Id62124247e264a248ca071d45c03969ee75a31d3

cinder/tests/test_volume.py

index 1f35c43f4edd27a9ff0d8d6082838591155390b5..6170da2e9c647ada539883c2e2c9ae5a1f8bfe3e 100644 (file)
@@ -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):