Merge "Made parse_jenkins_failure a non static"

This commit is contained in:
Zuul 2020-09-17 07:21:36 +00:00 committed by Gerrit Code Review
commit dc942c06f1
2 changed files with 7 additions and 8 deletions

View File

@ -206,14 +206,13 @@ class Stream(object):
if thread:
self.gerrit.startWatching()
@staticmethod
def parse_jenkins_failure(event, ci_username=er_conf.CI_USERNAME):
def parse_jenkins_failure(self, event):
"""Is this comment a jenkins failure comment."""
if event.get('type', '') != 'comment-added':
return False
username = event['author'].get('username', '')
if (username not in [ci_username, 'zuul']):
if (username not in [self.config.ci_username, 'zuul']):
return False
if not ("Build failed" in
@ -320,8 +319,7 @@ class Stream(object):
while True:
event = self.gerrit.getEvent()
failed_jobs = Stream.parse_jenkins_failure(
event, ci_username=self.config.ci_username)
failed_jobs = self.parse_jenkins_failure(event)
if not failed_jobs:
# nothing to see here, lets try the next event
continue

View File

@ -102,11 +102,12 @@ class TestStream(tests.TestCase):
events = j['events']
self.assertFalse(
elasticRecheck.Stream.parse_jenkins_failure(events[1]))
elasticRecheck.Stream("", "", "").parse_jenkins_failure(events[1]))
self.assertFalse(
elasticRecheck.Stream.parse_jenkins_failure(events[2]))
elasticRecheck.Stream("", "", "").parse_jenkins_failure(events[2]))
jobs = elasticRecheck.Stream.parse_jenkins_failure(events[0])
jobs = elasticRecheck.Stream("", "", "").parse_jenkins_failure(
events[0])
job_names = [x.name for x in jobs]
self.assertIn('check-requirements-integration-dsvm', job_names)
self.assertIn('check-tempest-dsvm-full', job_names)