From 1f06d022916ae0182fea496da44ba43f8dd62379 Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Sat, 14 Sep 2013 00:36:17 -0700 Subject: [PATCH] Use log_url to make sure looking at right job --- README.md | 2 -- elasticRecheck.py | 18 ++++++++++++------ tests/test_classifier.py | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6918a5e5..0f31be20 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,7 @@ Future Work ------------ - IRC bot output to #openstack-qa with output - Pull in list of queries from a more flexible source, so a commit isn't needed to update each time -- https://bugs.launchpad.net/openstack-ci/+bug/1225108 - Turn into a server app -- Comment on classified failures saying what the issue probably is - Make unit tests robust and not need internet Dependencies diff --git a/elasticRecheck.py b/elasticRecheck.py index 6f52b40b..c63377ff 100755 --- a/elasticRecheck.py +++ b/elasticRecheck.py @@ -118,7 +118,7 @@ class Classifier(): except KeyError: print "build_name %s" % x["_source"]['@fields']['build_name'] - def classify(self, change_number, patch_number): + def classify(self, change_number, patch_number, comment): """Returns either None or a bug number""" #Reload each time self.queries = json.loads(open('queries.json').read()) @@ -134,10 +134,16 @@ class Classifier(): print "Looking for bug: https://bugs.launchpad.net/bugs/%s" % x['bug'] query = self._apply_template(self.targeted_template, (x['query'], change_number, patch_number)) - results = self.es.search(query, size='1') - if results['hits']['total']>0: - print "Found bug!" - return x['bug'] + results = self.es.search(query, size='10') + for result in results['hits']['hits']: + url = result["_source"]['@fields']['log_url'] + print result + if self._prep_url(url) in comment: + print "found bug!" + return x['bug'] + + def _prep_url(self, url): + return '/'.join(url.split('/')[:-1]) def main(): @@ -150,7 +156,7 @@ def main(): rev = event['patchSet']['number'] print "=======================" print "https://review.openstack.org/#/c/%(change)s/%(rev)s" % locals() - bug_number = classifier.classify(change, rev) + bug_number = classifier.classify(change, rev, event['comment']) if bug_number is None: print "unable to classify failure" else: diff --git a/tests/test_classifier.py b/tests/test_classifier.py index 4f9a0d32..c4695279 100644 --- a/tests/test_classifier.py +++ b/tests/test_classifier.py @@ -17,6 +17,7 @@ class TestClassifier(testtools.TestCase): #self.assertFalse(True) def test_classify(self): - bug_number = self.classifier.classify('46581', '1') + bug_number = self.classifier.classify('43258', '13', + ' blah http://logs.openstack.org/58/43258/13/check/gate-tempest-devstack-vm-neutron/55a7887') self.assertEqual(bug_number, '1211915')