2121import time
2222import XenAPI
2323
24+ from util import sf_util
25+
2426# All tests inherit from cloudstackTestCase
2527from marvin .cloudstackTestCase import cloudstackTestCase
2628
3739
3840from solidfire import solidfire_element_api as sf_api
3941
42+ # Test 1: One June 6, 2016: Ran 1 test in 768.339s
43+ # Test 2: One June 6, 2016: Ran 1 test in 430.487s
44+ # Test 3: One June 6, 2016: Ran 1 test in 948.818s
45+ # Test 4: One June 6, 2016: Ran 1 test in 944.276s
4046
4147class TestData :
4248 account = "account"
@@ -238,7 +244,7 @@ def tearDownClass(cls):
238244 try :
239245 cleanup_resources (cls .apiClient , cls ._cleanup )
240246
241- cls . _purge_solidfire_volumes ( )
247+ sf_util . purge_solidfire_volumes ( cls . sf_client )
242248 except Exception as e :
243249 logging .debug ("Exception in tearDownClass(cls): %s" % e )
244250
@@ -286,7 +292,7 @@ def test_add_remove_host_with_solidfire_plugin_1(self):
286292
287293 root_volume = self ._get_root_volume (self .virtual_machine )
288294
289- sf_iscsi_name = self . _get_iqn ( root_volume )
295+ sf_iscsi_name = sf_util . get_iqn ( self . cs_api , root_volume , self )
290296
291297 self ._perform_add_remove_host (primary_storage .id , sf_iscsi_name )
292298
@@ -342,7 +348,7 @@ def test_add_remove_host_with_solidfire_plugin_3(self):
342348
343349 root_volume = self ._get_root_volume (self .virtual_machine )
344350
345- sf_iscsi_name = self . _get_iqn ( root_volume )
351+ sf_iscsi_name = sf_util . get_iqn ( self . cs_api , root_volume , self )
346352
347353 primarystorage2 = self .testdata [TestData .primaryStorage2 ]
348354
@@ -596,19 +602,6 @@ def _get_root_volume(self, vm):
596602
597603 self .assert_ (False , "Unable to locate the ROOT volume of the VM with the following ID: " + str (vm .id ))
598604
599- def _get_iqn (self , volume ):
600- # Get volume IQN
601- sf_iscsi_name_request = {'volumeid' : volume .id }
602- # put this commented line back once PR 1403 is in
603- # sf_iscsi_name_result = self.cs_api.getVolumeiScsiName(sf_iscsi_name_request)
604- sf_iscsi_name_result = self .cs_api .getSolidFireVolumeIscsiName (sf_iscsi_name_request )
605- # sf_iscsi_name = sf_iscsi_name_result['apivolumeiscsiname']['volumeiScsiName']
606- sf_iscsi_name = sf_iscsi_name_result ['apisolidfirevolumeiscsiname' ]['solidFireVolumeIscsiName' ]
607-
608- self ._check_iscsi_name (sf_iscsi_name )
609-
610- return sf_iscsi_name
611-
612605 def _get_iqn_2 (self , primary_storage ):
613606 sql_query = "Select path From storage_pool Where uuid = '" + str (primary_storage .id ) + "'"
614607
@@ -617,13 +610,6 @@ def _get_iqn_2(self, primary_storage):
617610
618611 return sql_result [0 ][0 ]
619612
620- def _check_iscsi_name (self , sf_iscsi_name ):
621- self .assertEqual (
622- sf_iscsi_name [0 ],
623- "/" ,
624- "The iSCSI name needs to start with a forward slash."
625- )
626-
627613 def _get_host_iscsi_iqns (self ):
628614 hosts = self .xen_session .xenapi .host .get_all ()
629615
@@ -687,24 +673,3 @@ def _verifyVag(self, host_iscsi_iqns, sf_vag_initiators):
687673 for host_iscsi_iqn in host_iscsi_iqns :
688674 # an error should occur if host_iscsi_iqn is not in sf_vag_initiators
689675 sf_vag_initiators .index (host_iscsi_iqn )
690-
691- def _check_list (self , in_list , expected_size_of_list , err_msg ):
692- self .assertEqual (
693- isinstance (in_list , list ),
694- True ,
695- "'in_list' is not a list."
696- )
697-
698- self .assertEqual (
699- len (in_list ),
700- expected_size_of_list ,
701- err_msg
702- )
703-
704- @classmethod
705- def _purge_solidfire_volumes (cls ):
706- deleted_volumes = cls .sf_client .list_deleted_volumes ()
707-
708- for deleted_volume in deleted_volumes :
709- cls .sf_client .purge_deleted_volume (deleted_volume ['volumeID' ])
710-
0 commit comments