]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Tests: Fix v6000 test failure with random hash seed
authorEric Harney <eharney@redhat.com>
Mon, 30 Mar 2015 19:45:39 +0000 (15:45 -0400)
committerEric Harney <eharney@redhat.com>
Tue, 31 Mar 2015 13:27:43 +0000 (09:27 -0400)
If PYTHONHASHSEED is set to a non-zero value, this test
will fail due to a dependency on dict ordering.

Rework the test to handle randomly ordered dictionaries.

Partial-Bug: #1348818

Change-Id: I92e780db5805e59ac9eef98a07cfbb7a4be54110

cinder/tests/test_v6000_fcp.py

index a1d66cc8e240035c0f9727eb51cce0934c839c4b..02fe11bb9a3c431ed6f7a8df63d51300c6da0ad7 100644 (file)
@@ -428,7 +428,6 @@ class V6000FCPDriverTestCase(test.TestCase):
     def test_build_initiator_target_map(self):
         """Successfully build a map when zoning is enabled."""
         expected_targ_wwns = FC_TARGET_WWPNS
-        expected_init_targ_map = FC_INITIATOR_TARGET_MAP
 
         self.driver.lookup_service = mock.Mock()
         self.driver.lookup_service.get_device_mapping_from_network.\
@@ -440,7 +439,18 @@ class V6000FCPDriverTestCase(test.TestCase):
         self.driver.lookup_service.get_device_mapping_from_network.\
             assert_called_with(CONNECTOR['wwpns'], self.driver.gateway_fc_wwns)
         self.assertEqual(set(expected_targ_wwns), set(targ_wwns))
-        self.assertEqual(expected_init_targ_map, init_targ_map)
+
+        i = FC_INITIATOR_WWPNS[0]
+        self.assertIn(FC_TARGET_WWPNS[0], init_targ_map[i])
+        self.assertIn(FC_TARGET_WWPNS[1], init_targ_map[i])
+        self.assertEqual(2, len(init_targ_map[i]))
+
+        i = FC_INITIATOR_WWPNS[1]
+        self.assertIn(FC_TARGET_WWPNS[2], init_targ_map[i])
+        self.assertIn(FC_TARGET_WWPNS[3], init_targ_map[i])
+        self.assertEqual(2, len(init_targ_map[i]))
+
+        self.assertEqual(2, len(init_targ_map))
 
     def test_build_initiator_target_map_no_lookup_service(self):
         """Successfully build a map when zoning is disabled."""