diff --git a/elasticRecheck.py b/elasticRecheck.py index 22fc3162..afa33d55 100755 --- a/elasticRecheck.py +++ b/elasticRecheck.py @@ -54,6 +54,7 @@ class Stream(object): for line in event['comment'].split('\n'): if "FAILURE" in line and ("python2" in line or "pep8" in line): # Unit Test Failure + print "SKIPPING %s" % line found = False break if "FAILURE" in line and "tempest-devstack" in line: @@ -265,7 +266,6 @@ class RequiredFiles(object): def main(): - #classifier.test() config = ConfigParser.ConfigParser() if len(sys.argv) is 2: config_path = sys.argv[1] diff --git a/queries.json b/queries.json index 682a5e78..875834ab 100644 --- a/queries.json +++ b/queries.json @@ -9,7 +9,7 @@ }, { "bug": "1227915", - "query": "\"already exists in volume group\" AND @fields.build_status:\"FAILURE\" AND @fields.loglevel:\"ERROR\" AND @fields.filename:\"logs/screen-c-vol.txt\"" + "query": "@message:\"already exists in volume group\" AND @fields.build_status:\"FAILURE\" AND @fields.loglevel:\"ERROR\" AND @fields.filename:\"logs/screen-c-vol.txt\"" }, { @@ -18,7 +18,7 @@ }, { "bug": "1226791", - "query": "@message:\"KeyError: 'nova'\" AND @fields.filename:\"logs/screen-n-api.txt\" AND @fields.build_status:\"FAILURE\" AND \"_describe_availability_zones_verbose\"" + "query": "@message:\"KeyError: 'nova'\" AND @fields.filename:\"logs/screen-n-api.txt\" AND @fields.build_status:\"FAILURE\" AND @message:\"_describe_availability_zones_verbose\"" }, { "bug": "1225664", diff --git a/tests/test_queries.py b/tests/test_queries.py new file mode 100644 index 00000000..4b74bbd8 --- /dev/null +++ b/tests/test_queries.py @@ -0,0 +1,29 @@ +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import elasticRecheck +import testtools + + +class TestQueries(testtools.TestCase): + def setUp(self): + super(TestQueries, self).setUp() + self.classifier = elasticRecheck.Classifier('queries.json') + + def test_queries(self): + for x in self.classifier.queries: + print "Looking for bug: https://bugs.launchpad.net/bugs/%s" % x['bug'] + query = self.classifier._apply_template(self.classifier.general_template, x['query']) + results = self.classifier.es.search(query, size='10') + self.assertTrue(int(results['hits']['total']) > 0, ("unable to find hits for bug %s" % x['bug']))