Skip to content

Commit

Permalink
Fix jenkinscheck not populating consecutive_failures
Browse files Browse the repository at this point in the history
Jenkins checks were always passing due to a bug in 0.11.12
  • Loading branch information
frankh committed May 23, 2018
1 parent a938fe0 commit 6dd06e8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
master
------

* Fix bug where jenkins checks were always passing
* Reduce Arachnys branding a bit
* Fix 404 page for logged out users
* Style forms with django-bootstrap-form
Expand Down
1 change: 1 addition & 0 deletions cabot/cabotapp/models/jenkins_check_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def _run(self):
status = get_job_status(self.jenkins_config, self.name)
active = status['active']
result.job_number = status['job_number']
result.consecutive_failures = status['consecutive_failures']
if status['status_code'] == 404:
result.error = u'Job %s not found on Jenkins' % self.name
result.succeeded = False
Expand Down
25 changes: 14 additions & 11 deletions cabot/cabotapp/tests/tests_jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jenkins
from cabot.cabotapp import jenkins as cabot_jenkins
from cabot.cabotapp.models import JenkinsConfig
from cabot.cabotapp.models.jenkins_check_plugin import JenkinsStatusCheck
from django.utils import timezone
from freezegun import freeze_time
from mock import create_autospec, patch
Expand Down Expand Up @@ -67,17 +68,19 @@ def test_job_failing(self, mock_jenkins):
u'result': u'SUCCESS'
}

status = cabot_jenkins.get_job_status(self.mock_config, 'foo')

expected = {
'active': True,
'succeeded': False,
'job_number': 12,
'blocked_build_time': None,
'consecutive_failures': 1,
'status_code': 200
}
self.assertEqual(status, expected)
jenkins_check = JenkinsStatusCheck(
name="foo",
jenkins_config=JenkinsConfig(
name="name",
jenkins_api="a",
jenkins_user="u",
jenkins_pass="p"
)
)
result = JenkinsStatusCheck._run(jenkins_check)

self.assertEqual(result.consecutive_failures, 1)
self.assertFalse(result.succeeded)

@freeze_time('2017-03-02 10:30')
@patch("cabot.cabotapp.jenkins._get_jenkins_client")
Expand Down

1 comment on commit 6dd06e8

@JeanFred
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, jeez, that was unfortunate ^_^"

Please sign in to comment.