summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@redhat.com>2018-11-30 16:23:38 -0800
committerTobias Henkel <tobias.henkel@bmw.de>2018-12-01 15:28:05 +0100
commit505c32e4b23ef81f7b4a13f91c6d062d3f1fa4fc (patch)
treec52f811adb745808a40c9968e8684d4a8bd32c30
parentc996adcb5ee8dc068206539272e6b688dd710054 (diff)
Fix updating relative priority
This code path was untested and had some typos. Correct them and ensure the path is tested. Change-Id: Ib4a283f739b12295f480684b9b93ad8a60abf350
Notes
Notes (review): Code-Review+2: Tobias Henkel <tobias.henkel@bmw.de> Code-Review+2: Monty Taylor <mordred@inaugust.com> Workflow+1: Monty Taylor <mordred@inaugust.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Sat, 01 Dec 2018 15:43:25 +0000 Reviewed-on: https://review.openstack.org/621319 Project: openstack-infra/zuul Branch: refs/heads/master
-rw-r--r--tests/unit/test_scheduler.py19
-rw-r--r--zuul/manager/__init__.py7
-rw-r--r--zuul/zk.py2
3 files changed, 25 insertions, 3 deletions
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index 81ca3b8..670b7fc 100644
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -5149,6 +5149,7 @@ For CI problems and help debugging, contact ci@example.org"""
5149 self.fake_nodepool.unpause() 5149 self.fake_nodepool.unpause()
5150 self.waitUntilSettled() 5150 self.waitUntilSettled()
5151 5151
5152 @simple_layout('layouts/two-projects-integrated.yaml')
5152 def test_nodepool_relative_priority_check(self): 5153 def test_nodepool_relative_priority_check(self):
5153 "Test that nodes are requested at the relative priority" 5154 "Test that nodes are requested at the relative priority"
5154 5155
@@ -5182,6 +5183,24 @@ For CI problems and help debugging, contact ci@example.org"""
5182 self.assertEqual(reqs[2]['_oid'], '200-0000000001') 5183 self.assertEqual(reqs[2]['_oid'], '200-0000000001')
5183 self.assertEqual(reqs[2]['relative_priority'], 1) 5184 self.assertEqual(reqs[2]['relative_priority'], 1)
5184 5185
5186 # Fulfill only the first request
5187 self.fake_nodepool.fulfillRequest(reqs[0])
5188 for x in iterate_timeout(30, 'fulfill request'):
5189 self.log.debug(len(self.sched.nodepool.requests))
5190 if len(self.sched.nodepool.requests) < 3:
5191 break
5192 self.waitUntilSettled()
5193
5194 reqs = self.fake_nodepool.getNodeRequests()
5195
5196 # Change B, now first change for project, equal priority.
5197 self.assertEqual(reqs[0]['_oid'], '200-0000000001')
5198 self.assertEqual(reqs[0]['relative_priority'], 0)
5199
5200 # Change C, now first change for project1, equal priority.
5201 self.assertEqual(reqs[1]['_oid'], '200-0000000002')
5202 self.assertEqual(reqs[1]['relative_priority'], 0)
5203
5185 self.fake_nodepool.unpause() 5204 self.fake_nodepool.unpause()
5186 self.waitUntilSettled() 5205 self.waitUntilSettled()
5187 5206
diff --git a/zuul/manager/__init__.py b/zuul/manager/__init__.py
index 353c470..90d02d1 100644
--- a/zuul/manager/__init__.py
+++ b/zuul/manager/__init__.py
@@ -88,7 +88,10 @@ class PipelineManager(object):
88 def getNodePriority(self, item): 88 def getNodePriority(self, item):
89 items = self.pipeline.getAllItems() 89 items = self.pipeline.getAllItems()
90 items = [i for i in items if i.change.project == item.change.project] 90 items = [i for i in items if i.change.project == item.change.project]
91 return items.index(item) 91 for idx, val in enumerate(items):
92 if item == val:
93 return idx
94 return len(items)
92 95
93 def isChangeAlreadyInPipeline(self, change): 96 def isChangeAlreadyInPipeline(self, change):
94 # Checks live items in the pipeline 97 # Checks live items in the pipeline
@@ -700,7 +703,7 @@ class PipelineManager(object):
700 priority = item.getNodePriority() 703 priority = item.getNodePriority()
701 for node_request in item.current_build_set.node_requests.values(): 704 for node_request in item.current_build_set.node_requests.values():
702 if node_request.relative_priority != priority: 705 if node_request.relative_priority != priority:
703 self.sched.nodepool.reviseNodeRequest( 706 self.sched.nodepool.reviseRequest(
704 node_request, priority) 707 node_request, priority)
705 return (changed, nnfi) 708 return (changed, nnfi)
706 709
diff --git a/zuul/zk.py b/zuul/zk.py
index f1ff4c8..6586641 100644
--- a/zuul/zk.py
+++ b/zuul/zk.py
@@ -217,7 +217,7 @@ class ZooKeeper(object):
217 :param NodeRequest node_request: The request to update. 217 :param NodeRequest node_request: The request to update.
218 ''' 218 '''
219 219
220 path = '%s/%s' % (self.NODE_REQUEST_ROOT, node_request.id) 220 path = '%s/%s' % (self.REQUEST_ROOT, node_request.id)
221 self.client.set(path, self._dictToStr(node_request.toDict())) 221 self.client.set(path, self._dictToStr(node_request.toDict()))
222 222
223 def updateNodeRequest(self, node_request, data=None): 223 def updateNodeRequest(self, node_request, data=None):