Tests: Fix 3par tests with hash randomization
"fcwwns" does not have a deterministic order -- account for this in the unit test. Change-Id: Id5a961c66a62e289a96daa7437374768ef407bb6
This commit is contained in:
parent
d43d3c4df5
commit
91f19a8b75
@ -7727,9 +7727,8 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
|
|||||||
common,
|
common,
|
||||||
self.volume,
|
self.volume,
|
||||||
self.connector_multipath_enabled)
|
self.connector_multipath_enabled)
|
||||||
# On Python 3, hash is randomized, and so set() is used to get
|
|
||||||
# the expected order
|
fcwwns = ['123456789054321', '123456789012345']
|
||||||
fcwwns = list(set(('123456789054321', '123456789012345')))
|
|
||||||
expected = [
|
expected = [
|
||||||
mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'),
|
mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'),
|
||||||
mock.call.getCPG(HPE3PAR_CPG),
|
mock.call.getCPG(HPE3PAR_CPG),
|
||||||
@ -7737,10 +7736,21 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
|
|||||||
mock.call.queryHost(wwns=['123456789012345',
|
mock.call.queryHost(wwns=['123456789012345',
|
||||||
'123456789054321']),
|
'123456789054321']),
|
||||||
mock.call.modifyHost('fakehost',
|
mock.call.modifyHost('fakehost',
|
||||||
{'FCWWNs': fcwwns,
|
{'FCWWNs': mock.ANY,
|
||||||
'pathOperation': 1}),
|
'pathOperation': 1}),
|
||||||
mock.call.getHost('fakehost')]
|
mock.call.getHost('fakehost')]
|
||||||
|
|
||||||
|
# We don't know what order fcwwns is supplied in. Since
|
||||||
|
# there are only two members, test it both ways.
|
||||||
|
call1 = mock.call('fakehost', {'FCWWNs': fcwwns,
|
||||||
|
'pathOperation': 1})
|
||||||
|
fcwwns_rev = list(fcwwns)
|
||||||
|
fcwwns_rev.reverse()
|
||||||
|
call2 = mock.call('fakehost', {'FCWWNs': fcwwns_rev,
|
||||||
|
'pathOperation': 1})
|
||||||
|
self.assertTrue(call1 in mock_client.modifyHost.call_args_list or
|
||||||
|
call2 in mock_client.modifyHost.call_args_list)
|
||||||
|
|
||||||
mock_client.assert_has_calls(expected)
|
mock_client.assert_has_calls(expected)
|
||||||
|
|
||||||
self.assertEqual(self.FAKE_HOST, host['name'])
|
self.assertEqual(self.FAKE_HOST, host['name'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user