Don't count non-live queue items in tenant list
The queue size in the tenant list should not include non-live items. The initial thought was to exclude non-active items. However non-active items in fact are queued items which are not in the active window of a dependent pipeline. Thus they should be counted. The thing we want to exclude is non-live items. Change that and add a test case for that. Change-Id: Ic63f0247fefca2cb3c8ea6c63eb405c4c4cf8dc0
This commit is contained in:
parent
b4a9b697d0
commit
0c7ef364b3
|
@ -16,6 +16,7 @@
|
|||
# under the License.
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import threading
|
||||
import os
|
||||
import urllib.parse
|
||||
|
@ -233,6 +234,24 @@ class TestWeb(BaseTestWeb):
|
|||
self.assertEqual(3, data[0]['projects'])
|
||||
self.assertEqual(0, data[0]['queue'])
|
||||
|
||||
# test that non-live items are not counted
|
||||
self.executor_server.hold_jobs_in_build = True
|
||||
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
|
||||
B = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
|
||||
B.setDependsOn(A, 1)
|
||||
self.fake_gerrit.addEvent(B.getPatchsetCreatedEvent(1))
|
||||
self.waitUntilSettled()
|
||||
|
||||
req = urllib.request.Request(
|
||||
"http://127.0.0.1:%s/api/tenants" % self.port)
|
||||
f = urllib.request.urlopen(req)
|
||||
data = f.read().decode('utf8')
|
||||
data = json.loads(data)
|
||||
|
||||
self.assertEqual('tenant-one', data[0]['name'])
|
||||
self.assertEqual(3, data[0]['projects'])
|
||||
self.assertEqual(1, data[0]['queue'])
|
||||
|
||||
def test_web_bad_url(self):
|
||||
# do we 404 correctly
|
||||
resp = self.get_url("status/foo")
|
||||
|
|
|
@ -312,7 +312,7 @@ class RPCListener(object):
|
|||
for pipeline_name, pipeline in tenant.layout.pipelines.items():
|
||||
for queue in pipeline.queues:
|
||||
for item in queue.queue:
|
||||
if item.active:
|
||||
if item.live:
|
||||
queue_size += 1
|
||||
|
||||
output.append({'name': tenant_name,
|
||||
|
|
Loading…
Reference in New Issue