Giter Site home page Giter Site logo

robozilla's People

Contributors

jyejare avatar ldjebran avatar oshtaier avatar renzon avatar rochacbruno avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robozilla's Issues

Support a newer version of python-bugzilla

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

Do not pin python-bugzilla version in setup.py

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

RFE: Provide counts for qe_test_coverage from Bugzilla

I need a report that will print out how many (total) Bugzilla issues are affected by our Robottelo automation based on the following criteria:

  • End date of Now in UTC
  • Include only issues that contain flags sat-6.2 and sat-6.3 but these should be passed by the user
  • Exclude component Doc issues
  • include only issues that contain flags qe_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)))

Allow execution of a single file

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'

Bulk Request

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))
    

ErrorString is not an Exception

you cannot except ErrorString like this:

except ErrorString as error:

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'

BUG: Key error is thrown when "resolution" is not included on fields

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'

Providing feedback

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 :)

Add Support for API Keys

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.