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:
|
if thread:
|
||||||
self.gerrit.startWatching()
|
self.gerrit.startWatching()
|
||||||
|
|
||||||
@staticmethod
|
def parse_jenkins_failure(self, event):
|
||||||
def parse_jenkins_failure(event, ci_username=er_conf.CI_USERNAME):
|
|
||||||
"""Is this comment a jenkins failure comment."""
|
"""Is this comment a jenkins failure comment."""
|
||||||
if event.get('type', '') != 'comment-added':
|
if event.get('type', '') != 'comment-added':
|
||||||
return False
|
return False
|
||||||
|
|
||||||
username = event['author'].get('username', '')
|
username = event['author'].get('username', '')
|
||||||
if (username not in [ci_username, 'zuul']):
|
if (username not in [self.config.ci_username, 'zuul']):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not ("Build failed" in
|
if not ("Build failed" in
|
||||||
@ -320,8 +319,7 @@ class Stream(object):
|
|||||||
while True:
|
while True:
|
||||||
event = self.gerrit.getEvent()
|
event = self.gerrit.getEvent()
|
||||||
|
|
||||||
failed_jobs = Stream.parse_jenkins_failure(
|
failed_jobs = self.parse_jenkins_failure(event)
|
||||||
event, ci_username=self.config.ci_username)
|
|
||||||
if not failed_jobs:
|
if not failed_jobs:
|
||||||
# nothing to see here, lets try the next event
|
# nothing to see here, lets try the next event
|
||||||
continue
|
continue
|
||||||
|
@ -102,11 +102,12 @@ class TestStream(tests.TestCase):
|
|||||||
events = j['events']
|
events = j['events']
|
||||||
|
|
||||||
self.assertFalse(
|
self.assertFalse(
|
||||||
elasticRecheck.Stream.parse_jenkins_failure(events[1]))
|
elasticRecheck.Stream("", "", "").parse_jenkins_failure(events[1]))
|
||||||
self.assertFalse(
|
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]
|
job_names = [x.name for x in jobs]
|
||||||
self.assertIn('check-requirements-integration-dsvm', job_names)
|
self.assertIn('check-requirements-integration-dsvm', job_names)
|
||||||
self.assertIn('check-tempest-dsvm-full', job_names)
|
self.assertIn('check-tempest-dsvm-full', job_names)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user