From 682f5a3effe544f0affabe384fcd3d4ee7d408f9 Mon Sep 17 00:00:00 2001 From: Angus Lees Date: Thu, 28 Aug 2014 14:39:52 +1000 Subject: [PATCH] Fix incorrect int/tuple comparison during binary search The code contains an incorrect int/tuple comparison during the binary search, which completely breaks the "priority" feature. (Apparently python2 thinks int < tuple is not an error and always True.) Change-Id: Ic404b38eabc87b105c7c2443b6177071b26d97ce Closes-Bug: #1386946 --- neutron/plugins/bigswitch/tests/test_server.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/neutron/plugins/bigswitch/tests/test_server.py b/neutron/plugins/bigswitch/tests/test_server.py index 392ab92e9..497043565 100755 --- a/neutron/plugins/bigswitch/tests/test_server.py +++ b/neutron/plugins/bigswitch/tests/test_server.py @@ -45,12 +45,12 @@ class TestNetworkCtrl(object): def match(self, prior, method_regexp, uri_regexp, handler, data=None, multi=True): - """Add to the list of exptected inputs. + """Add to the list of expected inputs. The incoming request is matched in the order of priority. For same priority, match the oldest match request first. - :param prior: intgere priority of this match (e.g. 100) + :param prior: integer priority of this match (e.g. 100) :param method_regexp: regexp to match method (e.g. 'PUT|POST') :param uri_regexp: regexp to match uri (e.g. '/quantum/v?.?/') :param handler: function with signature: @@ -75,7 +75,7 @@ class TestNetworkCtrl(object): lo, hi = 0, len(self.matches) while lo < hi: mid = (lo + hi) // 2 - if prior < self.matches[mid]: + if prior < self.matches[mid][0]: hi = mid else: lo = mid + 1 @@ -91,8 +91,8 @@ class TestNetworkCtrl(object): retstatus = self.default_status retbody = self.default_response for i in moves.xrange(len(self.matches)): - (prior, method_regexp, uri_regexp, handler, data, multi) = \ - self.matches[i] + (unused_prior, method_regexp, uri_regexp, handler, data, + multi) = self.matches[i] if re.match(method_regexp, method) and re.match(uri_regexp, uri): kwargs = { 'data': data, -- 2.45.2