Made parse_jenkins_failure a non static
Replaces static implementation that received password and a member function that can make use of the config object. Change-Id: If9617b6db73eb49c5193f098d45e357a267529dd
This commit is contained in:
parent
9d37c88c8f
commit
3901d2fd93
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user