satelliteqe / robozilla Goto Github PK
View Code? Open in Web Editor NEWRobottelo Bugzilla Parser
License: Other
Robottelo Bugzilla Parser
License: Other
Results can be filtered to avoid if is None and default dict can be used to avoid in tests
Bugzilla 5 has API keys, we should add support to this.
Shouldn't be to hard (pass api_key
instead of password
to RHBugzilla
).
However we seem to be locked to a version of python-bugzilla
that doesn't support this, so we need to probably solve that first (see #44)
Error example:
reader = BZReader(
bz_credentials,
include_fields=[
'id', 'status', 'whiteboard', 'flags', 'cf_clone_of', 'blocks'
]
)
# Fetch the bug and place it in the cache.
try:
_bugzilla[bug_id] = reader.get_bug_data(bug_id)
if not bz_credentials:
raise BZUnauthenticatedCall(
_bugzilla[bug_id],
'Unauthenticated call made to BZ API, no flags data will '
'be available'
)
except Fault as err:
raise BugFetchError(
'Could not fetch bug. Error: {0}'.format(err.faultString)
)
except ExpatError as err:
raise BugFetchError(
'Could not interpret bug. Error: {0}'
.format(ErrorString(err.code))
)
except (TypeError, ValueError): # pragma: no cover
raise BugFetchError(
'Could not connect to {0}'.format(BUGZILLA_URL)
)
File "/home/renzo/PycharmProjects/venvs/robottelo/lib/python2.7/site-packages/robozilla/bz.py", line 203, in set_bug_data_fields
if bug_data['resolution']:
KeyError: 'resolution'
Hi @ldjebran,
I took a look at the output generated by your script but when you asked me to take a look at your project, I forgot to ask you for some context :) Is this what we would run ahead of running a test suite to fetch the Bugzilla issues (and their statuses) so that we can exclude tests affected by WONTFIX
issues? If so, then 👍
I wasn't sure if you wanted me to also review the code, but if you do, please let me know :)
I need a report that will print out how many (total) Bugzilla issues are affected by our Robottelo
automation based on the following criteria:
Now
in UTCsat-6.2
and sat-6.3
but these should be passed by the usercomponent
Doc issuesqe_test_coverage-
, qe_test_coverage?
and qe_test_coverage?
Example for a report:
$ robozilla coverage --exclude-components Doc --include-flags sat-6.2,sat-6.3,qe_test_coverage+ --end-date={Now|2017-02-24|+1h}
qe_test_coverage- = 69
qe_test_coverage+ = 53
qe_test_coverage? = 1231
Here's what I wrote:
from __future__ import print_function
import bugzilla
import os
import urllib
REJECTED = "qe_test_coverage-"
AUTOMATED = "qe_test_coverage+"
BACKLOG = "qe_test_coverage?"
BUGZILLA_URL = "https://bugzilla.redhat.com/xmlrpc.cgi"
BUGZILLA_QUERY_URL = "https://bugzilla.redhat.com/query.cgi"
TEST_COVERAGE_URL = (
"{0}?classification=Red%20Hat"
"&f1=flagtypes.name"
"&f10=component"
"&f6=OP"
"&f7=flagtypes.name"
"&f8=flagtypes.name"
"&f9=CP"
"&j6=OR"
"&n10=1"
"&o1=substring"
"&o10=casesubstring"
"&o7=substring"
"&o8=substring"
"&product=Red%20Hat%20Satellite%206"
"&query_format=advanced"
"&v1={1}"
"&v10=Doc"
"&v7=sat-6.3"
"&v8=sat-6.2"
"&known_name={1}"
)
user = os.environ.get('BUGZILLA_USER_NAME', None)
password = os.environ.get('BUGZILLA_USER_PASSWORD', None)
bz = bugzilla.Bugzilla(url=BUGZILLA_URL)
session = bz.login(user=user, password=password)
for coverage_type in [REJECTED, AUTOMATED, BACKLOG]:
url = TEST_COVERAGE_URL.format(
BUGZILLA_QUERY_URL,
urllib.parse.quote(coverage_type))
query = bz.url_to_query(url)
query["include_fields"] = ["id", "summary", "flags"]
bugs = bz.query(query)
print("{} = {}".format(coverage_type, len(bugs)))
as in this @renzon example: https://github.com/renzon/pytest-decorator/blob/master/test_decorator.py
Instead of doing an API call for every BZ_ID we can call API in bulk getting information for each 100 Bzs at time.
import bugzilla
from robottelo.config import settings
BUGZILLA_URL = "https://bugzilla.redhat.com/xmlrpc.cgi"
bz_credentials = settings.bugzilla.get_credentials()
bz_conn = bugzilla.RHBugzilla(**bz_credentials)
bz_conn.connect(BUGZILLA_URL)
# here is where we create a list of lists having 100 BZ ids each
bz_list = [['1332185', '1386919', ...], [more 100 BZs, ... ], [more 100 Bzs]]
query = bz_conn.build_query(product="Red Hat Satellite 6")
query['bug_id_type'] = 'anyexact'
bug_objects = []
for bz_ids in bz_list:
query['bug_id'] = bz_ids
bug_objects.extend(bz_conn.query(query))
Hi, as this is a library meant to be used in external scenarios we cannot pin the version of library in setup.py
So we need to change setup.py to
requirements = [
'python_bugzilla',
'six'
]
and also make it compatible with changes in the new bugzilla 2.0.0 whichy requires URL to be passed when instantiating the class.
from this
def _get_connection(self):
# bz_credentials to be defined, for the moment connect as anonymous
if not self._connection:
bz_conn = bugzilla.RHBugzilla(**self.credentials)
bz_conn.connect(BUGZILLA_URL)
self._connection = bz_conn
return self._connection
to this
def _get_connection(self):
# bz_credentials to be defined, for the moment connect as anonymous
if not self._connection:
bz_conn = bugzilla.RHBugzilla(url=None, **self.credentials)
bz_conn.connect(BUGZILLA_URL)
self._connection = bz_conn
return self._connection
Using
url=None
makes it compatible with all versions of python-bugzilla I guess
brocha@localhost(rob63) :~/P/robozilla|master✓
➤ robozilla ../robottelo/tests/foreman/api/test_activationkey.py
/home/brocha/Projects/robozilla
Traceback (most recent call last):
File "/home/brocha/.virtualenvs/rob63/bin/robozilla", line 11, in <module>
load_entry_point('robozilla', 'console_scripts', 'robozilla')()
File "/home/brocha/Projects/robozilla/robozilla/scan.py", line 29, in main
parser.parse(report=True)
File "/home/brocha/Projects/robozilla/robozilla/parser.py", line 55, in parse
for file_path in self.files_provider.get_files():
File "/home/brocha/Projects/robozilla/robozilla/providers/fs.py", line 20, in get_files
for name in sorted(os.listdir(scan_path)):
OSError: [Errno 20] Not a directory: '../robottelo/tests/foreman/api/test_activationkey.py'
you cannot except ErrorString like this:
Line 188 in 49f9a3f
because ErrorString is not an Exception, it is a function
>>> from xml.parsers.expat import ErrorString
>>> type(ErrorString)
<class 'builtin_function_or_method'>
>>> try:
... raise Exception()
... except ErrorString:
... pass
...
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
Exception
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
TypeError: catching classes that do not inherit from BaseException is not allowed
>>> ErrorString(1)
'out of memory'
parser show only the bug of the last file only, and must show all the files where the bug was found
Get bug data mask all exceptions from such connection. A warning message can be logged so users can be aware of connection problem.
We seem to be locked to an older version of python-bugzilla (1.2.2) that doesn't support some features (like api keys). We should upgrade to a newer version that has better support of bugzilla 5
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.