Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apis/bugzilla_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,16 @@ def closeBug(url, apikey, bugID, resolution, comment, dup_id=None):
raise Exception(j)


def findOpenBugs(url, bugIDs):
r = requests.get(url + "bug?resolution=---&id=%s&include_fields=id" % ",".join([str(b) for b in bugIDs]))
def openBugsMetadata(url, bugIDs):
r = requests.get(url + "bug?resolution=---&id=%s&include_fields=id,assigned_to" % ",".join([str(b) for b in bugIDs]))

try:
j = json.loads(r.text)
except Exception as e:
raise Exception("Could not decode a bugzilla response as JSON: " + r.text) from e

try:
return [b['id'] for b in j['bugs']]
return {b['id']: b for b in j['bugs']}
except KeyError as e:
raise Exception(j) from e

Expand Down
6 changes: 3 additions & 3 deletions components/bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from apis.bugzilla_api import fileBug, commentOnBug, closeBug, findOpenBugs, markFFVersionAffected
from apis.bugzilla_api import fileBug, commentOnBug, closeBug, openBugsMetadata, markFFVersionAffected
from components.providerbase import BaseProvider, INeedsLoggingProvider
from components.logging import LogLevel, logEntryExit

Expand Down Expand Up @@ -241,10 +241,10 @@ def dupe_bug(self, bug_id, comment, dup_id):
closeBug(self.config['url'], self.config['apikey'], bug_id, 'DUPLICATE', comment, dup_id=dup_id)

@logEntryExit
def find_open_bugs(self, bug_ids):
def find_open_bugs_info(self, bug_ids):
filtered_ids = [b for b in bug_ids if b > 0]
if len(filtered_ids) > 0:
return findOpenBugs(self.config['url'], filtered_ids)
return openBugsMetadata(self.config['url'], filtered_ids)
return []

@logEntryExit
Expand Down
4 changes: 2 additions & 2 deletions tasktypes/commitalert.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def process_task(self, library, task):

# ==========================================================================================
# We need to mark previously opened bugs as affected or not.
open_bugs = self.bugzillaProvider.find_open_bugs([j.bugzilla_id for j in all_library_jobs])
open_bugs = self.bugzillaProvider.find_open_bugs_info([j.bugzilla_id for j in all_library_jobs])
jobs_with_open_bugs = [j for j in all_library_jobs if j.bugzilla_id in open_bugs]
self.logger.log("We need to potentially update the FF version on %s open bugs." % len(open_bugs), level=LogLevel.Info)
for j in jobs_with_open_bugs:
Expand Down Expand Up @@ -103,7 +103,7 @@ def _process_new_commits(self, library, task, new_commits, all_library_jobs):
raise Exception("In a commit-alert task for library %s I got a filter '%s' I don't know how to handle." % (library.name, task.filter))

depends_on = all_library_jobs[0].bugzilla_id if all_library_jobs else None
open_dependencies = self.bugzillaProvider.find_open_bugs([j.bugzilla_id for j in all_library_jobs])
open_dependencies = self.bugzillaProvider.find_open_bugs_info([j.bugzilla_id for j in all_library_jobs])

description = CommentTemplates.EXAMINE_COMMITS_BODY(library, task, self.scmProvider.build_bug_description(filtered_commits, 65534 - 500), open_dependencies)

Expand Down
10 changes: 6 additions & 4 deletions tasktypes/vendoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ def process_task(self, library, task):

# Collect all the existing jobs, and figure out which have open bugs
all_jobs = self.dbProvider.get_all_jobs_for_library(library, JOBTYPE.VENDORING)
open_bugs = self.bugzillaProvider.find_open_bugs([j.bugzilla_id for j in all_jobs])
open_bugs = self.bugzillaProvider.find_open_bugs_info([j.bugzilla_id for j in all_jobs])
for j in all_jobs:
j.bugzilla_is_open = j.bugzilla_id in open_bugs
j.bugzilla_assignee = open_bugs[j.bugzilla_id]['assigned_to_detail']['email'] if j.bugzilla_id in open_bugs else None
j.bugzilla_assignee = None if j.bugzilla_assignee in ["[email protected]", "[email protected]"] else j.bugzilla_assignee

# Get the list of all jobs we want to do something about
all_jobs_not_done = [j for j in all_jobs if j.status != JOBSTATUS.DONE or j.bugzilla_is_open]
Expand Down Expand Up @@ -599,7 +601,7 @@ def _process_unclassified_failures(self, library, task, existing_job, comment_li
existing_job.bugzilla_id,
CommentTemplates.DONE_UNCLASSIFIED_FAILURE(comment, library),
needinfo=library.maintainer_bz if existing_job.bugzilla_is_open else None,
assignee=library.maintainer_bz if existing_job.bugzilla_is_open else None)
assignee=(existing_job.bugzilla_assignee or library.maintainer_bz) if existing_job.bugzilla_is_open else None)

self.dbProvider.update_job_status(existing_job, JOBSTATUS.DONE, JOBOUTCOME.UNCLASSIFIED_FAILURES)

Expand All @@ -617,7 +619,7 @@ def _process_classified_failures(self, library, task, existing_job, comment_line
self.bugzillaProvider.comment_on_bug(
existing_job.bugzilla_id,
CommentTemplates.DONE_CLASSIFIED_FAILURE(comment, library),
assignee=library.maintainer_bz if existing_job.bugzilla_is_open else None)
assignee=(existing_job.bugzilla_assignee or library.maintainer_bz) if existing_job.bugzilla_is_open else None)

self.dbProvider.update_job_status(existing_job, JOBSTATUS.DONE, JOBOUTCOME.CLASSIFIED_FAILURES)

Expand All @@ -642,7 +644,7 @@ def _process_success(self, library, task, existing_job, comment_lines):
self.bugzillaProvider.comment_on_bug(
existing_job.bugzilla_id,
CommentTemplates.DONE_ALL_SUCCESS(),
assignee=library.maintainer_bz if existing_job.bugzilla_is_open else None)
assignee=(existing_job.bugzilla_assignee or library.maintainer_bz) if existing_job.bugzilla_is_open else None)

self.dbProvider.update_job_status(existing_job, JOBSTATUS.DONE, JOBOUTCOME.ALL_SUCCESS)

Expand Down
8 changes: 4 additions & 4 deletions tests/bugzilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def do_POST(self):
assert False, "Got a path %s I didn't expect" % self.path

def do_GET(self):
expectedPath_find = "/bug?resolution=---&id=1,2,3&include_fields=id"
expectedPath_find = "/bug?resolution=---&id="

self.send_response(200)
self.send_header("Content-type", "application/json")
self.end_headers()

if expectedPath_find == self.path:
self.wfile.write('{"bugs":[{"id":2}]}'.encode())
if expectedPath_find in self.path:
self.wfile.write('{"bugs":[{"id":2,"assigned_to_detail":{"id":578488,"email":"[email protected]","real_name":"Tom Ritter [:tjr]","name":"[email protected]","nick":"tjr"},"assigned_to":"[email protected]"}],"faults":[]}'.encode())
else:
assert False, "Got a path %s I didn't expect" % self.path

Expand Down Expand Up @@ -184,7 +184,7 @@ def testStatus(self):
self.bugzillaProvider.mark_ff_version_affected(456, 76)

def testGet(self):
self.assertEqual([2], self.bugzillaProvider.find_open_bugs([1, 2, 3]))
self.assertEqual({2: {'id': 2, "assigned_to_detail": {"id": 578488, "email": "[email protected]", "real_name": "Tom Ritter [:tjr]", "name": "[email protected]", "nick": "tjr"}, "assigned_to": "[email protected]"}}, self.bugzillaProvider.find_open_bugs_info([1, 2, 3]))

def testClose(self):
self.bugzillaProvider.wontfix_bug(7890, "Hello World")
Expand Down
Loading