From: john-griffith Date: Sat, 25 Jan 2014 02:12:01 +0000 (-0700) Subject: Fix up the way we do iqn variable in unit test X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=89d9b0a4e0e8f7ac8a227100016031a7ae6e8341;p=openstack-build%2Fcinder-build.git Fix up the way we do iqn variable in unit test A recent bug was reported when a developer was trying to work with the iscsi target unit tests. There were two problems discovered, one of which has been addressed by the dependent patch of this commit (https://review.openstack.org/#/c/68223/) which fixed the inconsistencies in the string we used for iqn's in our test. This patch addresses another issue that's somewhat related and was exposed when the developer tried to use the "self.target_name" variable instead of hard-coding the iqn's in the tests. The problem is that the target_name variable uses an invalid format for the iqn based on cinder-defaults. It neglected to use the volume_name prefix (in this case: "volume-"). This patch modifies the self.target_name variable to be more accurate with what we would see in real usage, it also modifies the test to just use this variable rather than hard coding it and running the risk of having mismatches again in the future. Change-Id: I392d423d5c0f58b7a21ee0c477609265002faa0c --- diff --git a/cinder/tests/test_iscsi.py b/cinder/tests/test_iscsi.py index cc072fabf..a4c2e0f32 100644 --- a/cinder/tests/test_iscsi.py +++ b/cinder/tests/test_iscsi.py @@ -29,7 +29,7 @@ class TargetAdminTestCase(object): self.cmds = [] self.tid = 1 - self.target_name = 'iqn.2011-09.org.foo.bar:blaa' + self.target_name = 'iqn.2011-09.org.foo.bar:volume-blaa' self.lun = 10 self.path = '/foo' self.vol_id = 'blaa' @@ -112,9 +112,9 @@ class TgtAdmTestCase(test.TestCase, TargetAdminTestCase): self.flags(iscsi_helper='tgtadm') self.flags(volumes_dir=self.persist_tempdir) self.script_template = "\n".join([ - 'tgt-admin --update iqn.2011-09.org.foo.bar:blaa', + 'tgt-admin --update %(target_name)s', 'tgt-admin --force ' - '--delete iqn.2011-09.org.foo.bar:volume-blaa', + '--delete %(target_name)s', 'tgtadm --lld iscsi --op show --mode target']) def tearDown(self): @@ -198,8 +198,8 @@ class LioAdmTestCase(test.TestCase, TargetAdminTestCase): self.flags(iscsi_helper='lioadm') self.script_template = "\n".join([ 'cinder-rtstool create ' - '/foo iqn.2011-09.org.foo.bar:blaa test_id test_pass', - 'cinder-rtstool delete iqn.2011-09.org.foo.bar:volume-blaa']) + '%(path)s %(target_name)s test_id test_pass', + 'cinder-rtstool delete %(target_name)s']) class ISERTgtAdmTestCase(TgtAdmTestCase):