Skip to content

Commit

Permalink
Fix blocked build behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
dbuxton committed Jan 30, 2014
1 parent 8ed09a8 commit fba0b12
Show file tree
Hide file tree
Showing 3 changed files with 497 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/cabotapp/jenkins.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ def get_job_status(jobname):
if status['queueItem'] and status['queueItem']['blocked']:
time_blocked_since = datetime.utcfromtimestamp(
float(status['queueItem']['inQueueSince']) / 1000).replace(tzinfo=timezone.utc)
ret['time_blocked'] = timezone.now() - time_blocked_since
ret['blocked_build_time'] = timezone.now() - time_blocked_since
return ret
16 changes: 16 additions & 0 deletions app/cabotapp/tests/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ def fake_jenkins_response(*args, **kwargs):
return resp


def jenkins_blocked_response(*args, **kwargs):
resp = Mock()
resp.json = json.loads(get_content('jenkins_blocked_response.json'))
resp.status_code = 200
return resp


def fake_http_200_response(*args, **kwargs):
resp = Mock()
resp.content = get_content('http_response.html')
Expand Down Expand Up @@ -182,6 +189,15 @@ def test_jenkins_run(self):
self.assertEqual(len(checkresults), 1)
self.assertFalse(self.jenkins_check.last_result().succeeded)

@patch('cabotapp.jenkins.requests.get', jenkins_blocked_response)
def test_jenkins_blocked_build(self):
checkresults = self.jenkins_check.statuscheckresult_set.all()
self.assertEqual(len(checkresults), 0)
self.jenkins_check.run()
checkresults = self.jenkins_check.statuscheckresult_set.all()
self.assertEqual(len(checkresults), 1)
self.assertFalse(self.jenkins_check.last_result().succeeded)

@patch('cabotapp.models.requests.get', throws_timeout)
def test_timeout_handling_in_jenkins(self):
checkresults = self.jenkins_check.statuscheckresult_set.all()
Expand Down
Loading

0 comments on commit fba0b12

Please sign in to comment.