-
Notifications
You must be signed in to change notification settings - Fork 21
[Iris 2.0] Bug Manager
Bug Manager
Ionut Budeanu, Silviu Checherita (mentoring)
The integration system with Bugzilla and GitHub will provide a simple API to determine GitHub and Bugzilla bug status, which can be used to determine whether a test should be run.
This API will be used to determine whether a test should be run. Currently we know that we have tests that are blocked by
a Bugzilla bug or a Github issue. At the beginning of each test there will be a hook where we'll check the bug or issue status and depends on the response received from API we'll know if the bug is still reproducible or is fixed in order for test to be run.
Our current system to determine if a test should run it's a really time consumer. This feature will make the bug status identification process a lot easier because everything will be verified automatically in manner of seconds and in the future we'll no longer need to verify the bug status manually.
"flags": [`
`{`
`"name": "blocker",`
`"status": "?",`
`"id": 2906,`
`"setter": "[email protected]",`
`"creation_date": "2014-09-28T21:03:47Z"`
`}`
`],`
`"resolution": "INVALID",`
`"id": 35,`
`"version": "1.0",`
`"status": "RESOLVED",`
`"platform": "All",`
`"classification": "Unclassified",`
`"cc_detail": [
The information needed from the above example contains fields like id
, status
and paltform
.
These fields will be retrieved using the bugzilla library with which we can log in to the Bugzilla
using an API key
provided by the Bugzilla platform. Also with this library we can parse the response JSON and we can retrieve various information like in the above example.
{
"id": 1,
"state": "open",
"title": "Found a bug",
"body": "I'm having a problem with this.",
"user": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat"
}
The library used for identifying the id
and the needed info from this response including fields like state
and title
, it's called PyGithub. With this library we can access the needed repo and also we can parse the JSON
response in order to extract various information.
The API token can be created here.
For determine on which platform the issue is reproducible we'll check if the issue title contains [platform]
.
[Win]Github API test issue
Both libraries bugzilla
and PyGithub
handle errors by throwing an Exception
. Each method will contain a try-except block where we'll gonna treat those exceptions. In case of a connection failure inside of the is_blocked
method we'll treat a custom BugManagerException
that will return always True
(if the connection fails the issue will be treated as blocked).
def get_bugzilla_bug(id):
try:
...
except Exception:
raise BugManagerError('Bugzilla API call failed')
def is_blocked(id):
try:
...
except BugManagerError:
return True
- Overview
The implementation starts by creating a new Python module named bug_management
which will be under the api
package. The absolute path is represented like this: your_iris_directory/iris2/targets/firefox/bug_manager.py
.
Inside of it, the structure is based on 3 main methods: get_github_issue()
, get_bugzilla_bug()
and is_blocked()
.
First two methods will deliver the information received from the both REST API's: bugzilla and github and inside of the third one is created some logic in order to determine if a test should run based on the responses received from the API's.
Information like API key
or url
will be held inside of the config.ini
file.
- New sections for config.ini file
[GitHub]
github_key=github_token
[Bugzilla]
api_key=bugzilla_api_key
bugzilla_url=https://bugzilla.mozilla.org/rest/
A bug status can be determined without a login but there are some circumstances where some bugs requires from user to be logged in. Also this functionality can help us in the future.
- Sample Code
# 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 github import Github
import bugzilla
from src.configuration.config_parser import get_config_property
from src.core.api.os_helpers import OSHelper
from src.core.api.errors import BugManagerError
api_key = get_config_property('Bugzilla', 'api_key')
base_url = get_config_property('Bugzilla', 'bugzilla_url')
g = Github(get_config_property('GitHub', 'github_key'))
bugzilla_os = {'win': 'Windows 10', 'win7': 'Windows 7', 'linux': 'Linux', 'mac': 'macOS'}
def get_github_issue(id):
try:
repo = [x for x in g.get_user().get_repos() if x.name == 'iris2']
if len(repo) > 0:
return repo[0].get_issue(id)
else:
return None
except Exception:
raise BugManagerError('Github API call failed')
def get_bugzilla_bug(id):
try:
b = bugzilla.Bugzilla(url=base_url, api_key=api_key)
return b.get_bug(id)
except Exception:
raise BugManagerError('Bugzilla API call failed')
def is_blocked(id):
try:
if 'issue_' in id:
bug = get_github_issue(id).state
if bug.state == 'closed':
return False
else:
if OSHelper.get_os() in bug.title:
return True
else:
return False
else:
bug = get_bugzilla_bug(id)
print(bug.status, bug.platform)
if bug.status in ['CLOSED', 'RESOLVED']:
return False
else:
if bugzilla_os[OSHelper.get_os()] == bug.platform or bug.platform in ['All', 'Unspecified']:
return True
else:
return False
except BugManagerError:
return True
- New and/or changed files and directories
New Python Module inside of the Firefox package (iris2/targets/firefox/bug_manager.py
).
- Control Center
N/A
- Localization
No.
- Documentation
No.
- Bootstrap
No.
- Setup
This implementation will require 2 new Python libraries:
- Dependencies on other people/teams/software.
Waiting for the necessary support from Iris 2. Also the possibility to change the implementation and/or adding new libraries i think can represent a small risk.
- Other factors that could influence functionality or schedule.
The only thing that can affect our current design is the library changes and updates.
- xxxx-xx-xx Spec due date (this)
- xxxx-xx-xx Implementation
- xxxx-xx-xx Code review
- xxxx-xx-xx Testing
- xxxx-xx-xx Final check-in date
Installation
Running Iris
- Basic workflow
- Useful examples
- Using the Control Center - coming soon
- Runtime argument list - coming soon
Contributing to Iris
- Iris APIs - coming soon
- Creating images
- Code style guide - coming soon
- Getting code into Iris
- Communicating with the team - coming soon