Merge "Add exclude_results to buildsets api"
This commit is contained in:
commit
df000f7f62
@ -2102,6 +2102,30 @@ class TestBuildInfo(BaseTestWeb):
|
||||
"idx_min=%i" % idx_max).json()
|
||||
self.assertEqual(len(buildsets_query), 1, buildsets_query)
|
||||
|
||||
def test_web_list_buildsets_exclude_result(self):
|
||||
# Test the exclude_result filter
|
||||
# Generate some build records in the db.
|
||||
self.executor_server.hold_jobs_in_build = False
|
||||
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
|
||||
self.executor_server.failJob('project-merge', A)
|
||||
A.addApproval('Code-Review', 2)
|
||||
self.fake_gerrit.addEvent(A.addApproval('Approved', 1))
|
||||
self.waitUntilSettled()
|
||||
|
||||
B = self.fake_gerrit.addFakeChange('org/project1', 'master', 'B')
|
||||
B.addApproval('Code-Review', 2)
|
||||
self.fake_gerrit.addEvent(B.addApproval('Approved', 1))
|
||||
self.waitUntilSettled()
|
||||
|
||||
buildsets = self.get_url("api/tenant/tenant-one/buildsets").json()
|
||||
self.assertEqual(2, len(buildsets))
|
||||
self.assertEqual("org/project1", buildsets[0]["refs"][0]["project"])
|
||||
self.assertEqual("org/project", buildsets[1]["refs"][0]["project"])
|
||||
buildsets = self.get_url("api/tenant/tenant-one/buildsets?"
|
||||
"exclude_result=FAILURE").json()
|
||||
self.assertEqual(1, len(buildsets))
|
||||
self.assertEqual("org/project1", buildsets[0]["refs"][0]["project"])
|
||||
|
||||
def test_web_substring_search_buildsets(self):
|
||||
# Generate some build records in the db.
|
||||
self.add_base_changes()
|
||||
|
@ -431,7 +431,7 @@ class DatabaseSession(object):
|
||||
newrev=None, uuid=None, result=None, complete=None,
|
||||
updated_max=None,
|
||||
limit=50, offset=0, idx_min=None, idx_max=None,
|
||||
query_timeout=None):
|
||||
exclude_result=None, query_timeout=None):
|
||||
|
||||
buildset_table = self.connection.zuul_buildset_table
|
||||
buildset_ref_table = self.connection.zuul_buildset_ref_table
|
||||
@ -458,6 +458,7 @@ class DatabaseSession(object):
|
||||
q = self.listFilter(q, ref_table.c.newrev, newrev)
|
||||
q = self.listFilter(q, buildset_table.c.uuid, uuid)
|
||||
q = self.listFilter(q, buildset_table.c.result, result)
|
||||
q = self.exListFilter(q, buildset_table.c.result, exclude_result)
|
||||
if idx_min:
|
||||
q = q.filter(buildset_table.c.id >= idx_min)
|
||||
if idx_max:
|
||||
|
@ -2004,7 +2004,7 @@ class ZuulWebAPI(object):
|
||||
pipeline=None, change=None, branch=None,
|
||||
patchset=None, ref=None, newrev=None, uuid=None,
|
||||
result=None, complete=None, limit=50, skip=0,
|
||||
idx_min=None, idx_max=None):
|
||||
idx_min=None, idx_max=None, exclude_result=None):
|
||||
connection = self._get_connection()
|
||||
|
||||
if complete:
|
||||
@ -2021,7 +2021,7 @@ class ZuulWebAPI(object):
|
||||
change=change, branch=branch, patchset=patchset, ref=ref,
|
||||
newrev=newrev, uuid=uuid, result=result, complete=complete,
|
||||
limit=limit, offset=skip, idx_min=_idx_min, idx_max=_idx_max,
|
||||
query_timeout=self.query_timeout)
|
||||
exclude_result=exclude_result, query_timeout=self.query_timeout)
|
||||
|
||||
return [BuildsetConverter.toDict(b) for b in buildsets]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user