make enqueue_time passable to addChange
When doing a doPromote we should keep the enqueue times of items.
However, the teardown and rebuild of the queues means that items
are fully destroyed and created a new.
Change the addChange api call so that it takes an optional enqueue
time to set on the item, which it can do internally once the new
item has gotten created.
This should address the issue where enqueue_times get lost when
we do a promote of the queue.
Now with unit tests! (Also ensured that if I removed the scheduler
change these tests failed, so the test is testing a correct thing)
Change-Id: I4dce23d00128280c7add922ca9ef5018b57d1cf3
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index 8d975aa..0b9e5a8 100755
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -3153,11 +3153,22 @@
self.waitUntilSettled()
+ items = self.sched.layout.pipelines['gate'].getAllItems()
+ enqueue_times = {}
+ for item in items:
+ enqueue_times[str(item.change)] = item.enqueue_time
+
client = zuul.rpcclient.RPCClient('127.0.0.1',
self.gearman_server.port)
r = client.promote(pipeline='gate',
change_ids=['2,1', '3,1'])
+ # ensure that enqueue times are durable
+ items = self.sched.layout.pipelines['gate'].getAllItems()
+ for item in items:
+ self.assertEqual(
+ enqueue_times[str(item.change)], item.enqueue_time)
+
self.worker.release('.*-merge')
self.waitUntilSettled()
self.worker.release('.*-merge')