From 1414f5d9a8d709ff66c8d80cd3dc087d2a717d31 Mon Sep 17 00:00:00 2001 From: Sean Dague Date: Tue, 14 Jul 2015 14:40:26 -0400 Subject: [PATCH] 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 --- nova/tests/unit/objects/test_instance.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/nova/tests/unit/objects/test_instance.py b/nova/tests/unit/objects/test_instance.py index 92c08e55b6..e65156668c 100644 --- a/nova/tests/unit/objects/test_instance.py +++ b/nova/tests/unit/objects/test_instance.py @@ -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()