def classify(self, change_number, patch_number,
                 build_short_uuid, recent=False):
        """Returns either empty list or list with matched bugs."""
        self.log.debug("Entering classify")
        # Reload each time
        self.queries = loader.load(self.queries_dir)
        bug_matches = []
        engine = sqlalchemy.create_engine(self.config.db_uri)
        Session = orm.sessionmaker(bind=engine)
        session = Session()
        for x in self.queries:
            if x.get('suppress-notification'):
                continue
            self.log.debug(
                "Looking for bug: https://bugs.launchpad.net/bugs/%s"
                % x['bug'])
            query = qb.single_patch(x['query'], change_number, patch_number,
                                    build_short_uuid)
            results = self.es.search(query, size='10', recent=recent)
            if len(results) > 0:
                if x.get('test_ids', None):
                    test_ids = x['test_ids']
                    self.log.debug(
                        "For bug %s checking subunit2sql for failures on "
                        "test_ids: %s" % (x['bug'], test_ids))
                    if check_failed_test_ids_for_job(build_short_uuid,
                                                     test_ids, session):
                        bug_matches.append(x['bug'])
                else:
                    bug_matches.append(x['bug'])

        return bug_matches
Пример #2
0
    def classify(self,
                 change_number,
                 patch_number,
                 build_short_uuid,
                 recent=False):
        """Returns either empty list or list with matched bugs."""
        self.log.debug("Entering classify")
        # Reload each time
        self.queries = loader.load(self.queries_dir)
        bug_matches = []
        engine = sqlalchemy.create_engine(self.db_uri)
        Session = orm.sessionmaker(bind=engine)
        session = Session()
        for x in self.queries:
            if x.get('suppress-notification'):
                continue
            self.log.debug(
                "Looking for bug: https://bugs.launchpad.net/bugs/%s" %
                x['bug'])
            query = qb.single_patch(x['query'], change_number, patch_number,
                                    build_short_uuid)
            results = self.es.search(query, size='10', recent=recent)
            if len(results) > 0:
                if x.get('test_ids', None):
                    test_ids = x['test_ids']
                    self.log.debug(
                        "For bug %s checking subunit2sql for failures on "
                        "test_ids: %s" % (x['bug'], test_ids))
                    if check_failed_test_ids_for_job(build_short_uuid,
                                                     test_ids, session):
                        bug_matches.append(x['bug'])
                else:
                    bug_matches.append(x['bug'])

        return bug_matches
Пример #3
0
    def test_load_queries(self):
        queries = loader.load("queries")

        self.assertGreater(len(queries), 0)
        for q in queries:
            self.assertIsNotNone(q['bug'])
            self.assertIsNotNone(q['query'])
Пример #4
0
    def test_grenade_compat(self):
        # grenade logs are in logs/new/ and logs/old, while devstack is in
        # logs/. To make sure queries will work with both, one should use
        # filename:logs*screen... (no quotes)
        queries = loader.load("queries")

        for q in queries:
            # Use assertTrue because you can specify a custom message
            self.assertTrue("filename:\"logs/screen-" not in q['query'],
                            msg=("for bug %s" % q['bug']))
Пример #5
0
    def test_load_queries(self):
        queries = loader.load("queries")

        self.assertGreater(len(queries), 0)
        for q in queries:
            self.assertIsNotNone(q['bug'])
            self.assertIsNotNone(q['query'])
            # check for the allow-nonvoting flag
            if 'allow-nonvoting' in q:
                self.assertNotIn('voting:1', q['query'])
            else:
                self.assertIn('voting:1', q['query'])
Пример #6
0
 def classify(self, change_number, patch_number,
              build_short_uuid, recent=False):
     """Returns either empty list or list with matched bugs."""
     self.log.debug("Entering classify")
     #Reload each time
     self.queries = loader.load(self.queries_dir)
     bug_matches = []
     for x in self.queries:
         if x.get('suppress-notification'):
             continue
         self.log.debug(
             "Looking for bug: https://bugs.launchpad.net/bugs/%s"
             % x['bug'])
         query = qb.single_patch(x['query'], change_number, patch_number,
                                 build_short_uuid)
         results = self.es.search(query, size='10', recent=recent)
         if len(results) > 0:
             bug_matches.append(x['bug'])
     return bug_matches
Пример #7
0
 def __init__(self, queries_dir, es_url=None, db_uri=None):
     self.es_url = es_url or ES_URL
     self.db_uri = db_uri or DB_URI
     self.es = results.SearchEngine(self.es_url)
     self.queries_dir = queries_dir
     self.queries = loader.load(self.queries_dir)
Пример #8
0
 def __init__(self, url):
     self._yaml = loader.load('elastic_recheck/tests/unit/queries')
     self._queries = {}
     for item in self._yaml:
         self._queries[item['query'].rstrip()] = item['bug']
 def __init__(self, queries_dir, config=None):
     self.config = config or er_conf.Config()
     self.es = results.SearchEngine(self.config.es_url)
     self.queries_dir = queries_dir
     self.queries = loader.load(self.queries_dir)
Пример #10
0
 def __init__(self, queries_dir, es_url=None, db_uri=None):
     self.es_url = es_url or ES_URL
     self.db_uri = db_uri or DB_URI
     self.es = results.SearchEngine(self.es_url)
     self.queries_dir = queries_dir
     self.queries = loader.load(self.queries_dir)
Пример #11
0
 def __init__(self, queries_dir):
     self.es = results.SearchEngine(ES_URL)
     self.queries_dir = queries_dir
     self.queries = loader.load(self.queries_dir)