make test_save_updates_numa_topology stable across python versions

test_save_updates_numa_topology has a rather complex nova object to
represent numa. This includes items which are sets, but must be
converted to lists for json. This is not a stable output operation
across all space and time. The mock comparator was failing here some
times because of it.

Instead, we can manually inspect the parameter in question with our
json comparator to ensure that it is correct.

Closes-Bug: #1473949

Change-Id: Ibfa441356d10417e2b1e092826562ad03d8cfd02
This commit is contained in:
Sean Dague
2015-07-14 14:40:26 -04:00
parent 42d91ebee0
commit 1414f5d9a8

View File

@@ -455,8 +455,19 @@ class _TestInstanceObject(object):
context=self.context, id=123, uuid='fake-uuid')
inst.numa_topology = fake_obj_numa_topology
inst.save()
# NOTE(sdague): the json representation of nova object for
# NUMA isn't stable from a string comparison
# perspective. There are sets which get converted to lists,
# and based on platform differences may show up in different
# orders. So we can't have mock do the comparison. Instead
# manually compare the final parameter using our json equality
# operator which does the right thing here.
mock_extra_update.assert_called_once_with(
self.context, inst.uuid, {'numa_topology': jsonified})
self.context, inst.uuid, mock.ANY)
called_arg = mock_extra_update.call_args_list[0][0][2]['numa_topology']
self.assertJsonEqual(called_arg, jsonified)
mock_extra_update.reset_mock()
inst.numa_topology = None
inst.save()