From 7881b819e349f472ca5184197241ef048ce16bf9 Mon Sep 17 00:00:00 2001 From: Aaron Rosen Date: Mon, 11 Jul 2016 12:06:31 -0700 Subject: [PATCH] Fix periodic falling test The method json.dumps() does not always return the same order of keys because in python dictionaries are unordered. This patch fixes this failing test by telling json.dumps to sort the response before returning. Change-Id: I13a4ce79cd4a8734094bef85ce0943fee25cbbc9 --- vmware_nsx/nsxlib/mh/lsn.py | 2 +- vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vmware_nsx/nsxlib/mh/lsn.py b/vmware_nsx/nsxlib/mh/lsn.py index 8fb4e039e4..a5f6f3e84b 100644 --- a/vmware_nsx/nsxlib/mh/lsn.py +++ b/vmware_nsx/nsxlib/mh/lsn.py @@ -106,7 +106,7 @@ def lsn_port_create(cluster, lsn_id, port_data): return nsxlib.do_request(HTTP_POST, nsxlib._build_uri_path(LSERVICESNODEPORT_RESOURCE, parent_resource_id=lsn_id), - jsonutils.dumps(port_obj), + jsonutils.dumps(port_obj, sort_keys=True), cluster=cluster)["uuid"] diff --git a/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py b/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py index ae87aa84fb..8b16b29ef6 100644 --- a/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py +++ b/vmware_nsx/tests/unit/nsxlib/mh/test_lsn.py @@ -157,7 +157,7 @@ class LSNTestCase(base.BaseTestCase): } self.mock_request.assert_called_once_with( "POST", "/ws.v1/lservices-node/%s/lport" % lsn_id, - jsonutils.dumps(port_obj), cluster=self.cluster) + jsonutils.dumps(port_obj, sort_keys=True), cluster=self.cluster) def test_lsn_port_delete(self): lsn_id = "foo_lsn_id"