Tests: Fix XIV test failure with hash randomization

_get_fc_targets creates a set() from target_wwpns.
It then sorts the contents of that set using a comparison that
only checks the last digit of the entry.

This is not a stable sort, so the order of the list output
from _get_fc_targets is non-deterministic.

This appears to be fine in practice, so just fix the unit test.

Needed-By: I4c7396f9d8e58ac8420754503f8ed60cd7473426
Change-Id: I281ad59fa518f936aa8d1b518acf61800ba949f5
This commit is contained in:
Eric Harney 2018-01-04 11:38:32 -05:00
parent b6d2ec994c
commit 405cd37823

View File

@ -1439,8 +1439,9 @@ class XIVProxyTest(test.TestCase):
p.ibm_storage_cli.cmd.host_connectivity_list.return_value = ( p.ibm_storage_cli.cmd.host_connectivity_list.return_value = (
HOST_CONNECTIVITY_LIST) HOST_CONNECTIVITY_LIST)
fc_targets = p._get_fc_targets(host) fc_targets = p._get_fc_targets(host)
self.assertEqual(FC_TARGETS_OPTIMIZED_WITH_HOST, fc_targets, six.assertCountEqual(self,
"FC targets are different from the expected") FC_TARGETS_OPTIMIZED_WITH_HOST, fc_targets,
"FC targets are different from the expected")
def test_get_fc_targets_returns_host_all_wwpns_list(self): def test_get_fc_targets_returns_host_all_wwpns_list(self):
driver = mock.MagicMock() driver = mock.MagicMock()
@ -1459,8 +1460,9 @@ class XIVProxyTest(test.TestCase):
p.ibm_storage_cli.cmd.host_connectivity_list.return_value = ( p.ibm_storage_cli.cmd.host_connectivity_list.return_value = (
HOST_CONNECTIVITY_LIST_UNKNOWN_HOST) HOST_CONNECTIVITY_LIST_UNKNOWN_HOST)
fc_targets = p._get_fc_targets(host) fc_targets = p._get_fc_targets(host)
self.assertEqual(FC_TARGETS_OPTIMIZED, fc_targets, six.assertCountEqual(self,
"FC targets are different from the expected") FC_TARGETS_OPTIMIZED, fc_targets,
"FC targets are different from the expected")
def test_define_ports_returns_sorted_wwpns_list(self): def test_define_ports_returns_sorted_wwpns_list(self):
driver = mock.MagicMock() driver = mock.MagicMock()