]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Make _build_uri_path output predictable
authorarmando-migliaccio <armamig@gmail.com>
Mon, 4 Aug 2014 19:24:19 +0000 (12:24 -0700)
committerArmando Migliaccio <armamig@gmail.com>
Tue, 5 Aug 2014 13:47:03 +0000 (13:47 +0000)
This is done by ensuring that filters are
serialized in their alphabetical order.

Tweak tests affected by this.

This is done in the context as defined by
etherpad: neutron-random-hashseed

Partial-bug: #1348818

Change-Id: Ibe79716a340195ca0365f276ef6e3e728f1a94a1

neutron/plugins/vmware/nsxlib/__init__.py
neutron/tests/unit/vmware/nsxlib/test_l2gateway.py
neutron/tests/unit/vmware/nsxlib/test_lsn.py
neutron/tests/unit/vmware/test_nsx_utils.py

index b09460b59392bf620ecc3f331c0e3fed821e07ea..e455965e64f74ff7cb6cda67b03673e4dcf65761 100644 (file)
@@ -56,7 +56,10 @@ def _build_uri_path(resource,
     params.append(relations and "relations=%s" % relations)
     params.append(types and "types=%s" % types)
     if filters:
-        params.extend(['%s=%s' % (k, v) for (k, v) in filters.iteritems()])
+        sorted_filters = [
+            '%s=%s' % (k, filters[k]) for k in sorted(filters.keys())
+        ]
+        params.extend(sorted_filters)
     uri_path = "%s/%s" % (URI_PREFIX, res_path)
     non_empty_params = [x for x in params if x is not None]
     if non_empty_params:
index 477233d6fa32a9b8aac441f7c0b7c1d4121f6cc4..e3b92f25f8133c96a04ce8c1f5256685200a75be 100644 (file)
@@ -281,7 +281,7 @@ class L2GatewayTestCase(base.NsxlibTestCase):
                 "GET",
                 ("/ws.v1/transport-node?fields=uuid,tags&"
                  "relations=TransportNodeStatus&"
-                 "tag_scope=os_tid&tag=ssc_napoli&"
+                 "tag=ssc_napoli&tag_scope=os_tid&"
                  "_page_length=1000&tag_scope=quantum"),
                 cluster=self.fake_cluster)
 
index 41c50b6c3be8f90fb4137d9332a27617c907f170..6a26efa30381189dd2c889a48e0e249a2f65ee34 100644 (file)
@@ -81,8 +81,8 @@ class LSNTestCase(base.BaseTestCase):
         self.assertEqual(lsn_id, result)
         self.mock_request.assert_called_once_with(
             "GET",
-            ("/ws.v1/lservices-node?fields=uuid&tag_scope="
-             "n_network_id&tag=%s" % net_id),
+            ("/ws.v1/lservices-node?fields=uuid&tag=%s&"
+             "tag_scope=n_network_id" % net_id),
             cluster=self.cluster)
 
     def test_lsn_for_network_get_none(self):
@@ -179,8 +179,8 @@ class LSNTestCase(base.BaseTestCase):
         self.assertEqual(result, port_id)
         self.mock_request.assert_called_once_with(
             "GET",
-            ("/ws.v1/lservices-node/%s/lport?fields=uuid&tag_scope=%s&"
-             "tag=%s" % (lsn_id, filters["tag_scope"], filters["tag"])),
+            ("/ws.v1/lservices-node/%s/lport?fields=uuid&tag=%s&"
+             "tag_scope=%s" % (lsn_id, filters["tag"], filters["tag_scope"])),
             cluster=self.cluster)
 
     def test_lsn_port_get_with_filters_return_none(self):
index 569af8f7eb3d70891ccb64dd216f027373e63e66..44b72bfa01d00346b22647fe4e44a65c96e1acbe 100644 (file)
@@ -220,7 +220,7 @@ class NsxUtilsTestCase(base.BaseTestCase):
         filters = {"tag": 'foo', "tag_scope": "scope_foo"}
         result = nsxlib._build_uri_path('RESOURCE', filters=filters)
         expected = (
-            "%s/%s?tag_scope=scope_foo&tag=foo" %
+            "%s/%s?tag=foo&tag_scope=scope_foo" %
             (nsxlib.URI_PREFIX, 'RESOURCE'))
         self.assertEqual(expected, result)