summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClark Boylan <clark.boylan@gmail.com>2022-06-28 09:54:51 -0700
committerClark Boylan <clark.boylan@gmail.com>2022-06-28 09:54:51 -0700
commitc6737ced67c6aba846e3d104fa63bc80cefed435 (patch)
tree1c93c0b2bccbde20a05b79e30e87e2cea12462a0
parent6b167dd2f17d49dafec1a9756b04494ea77eea7d (diff)
downloadzuul-c6737ced67c6aba846e3d104fa63bc80cefed435.tar.gz
Report timing info for POST_FAILURE and TIMED_OUT builds
We previously only reported statsd timing info for SUCCESS and FAILURE builds. But it would be useful to get info for POST_FAILURE and TIMED_OUT builds as well. In particular with POST_FAILURE builds we can track how long they are running before they fail. Change-Id: I2fe443ac2f69f40b7419e5280a38958d3ac7c080
-rw-r--r--tests/unit/test_v3.py16
-rw-r--r--zuul/scheduler.py4
2 files changed, 19 insertions, 1 deletions
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index 24943b4ec..554e5ff3d 100644
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -6471,6 +6471,22 @@ class TestJobOutput(AnsibleZuulTestCase):
self.assertIn('Final playbook failed', log_output)
self.assertIn('Failure test', log_output)
+ def test_job_POST_FAILURE_reports_statsd(self):
+ """Test that POST_FAILURES output job stats."""
+ self.statsd.clear()
+ A = self.fake_gerrit.addFakeChange('org/project2', 'master', 'A')
+ self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
+ self.waitUntilSettled()
+ self.assertHistory([
+ dict(name='job-output-failure',
+ result='POST_FAILURE', changes='1,1'),
+ ], ordered=False)
+ post_failure_stat = 'zuul.tenant.tenant-one.pipeline.check.project.' \
+ 'review_example_com.org_project2.master.job.' \
+ 'job-output-failure.POST_FAILURE'
+ self.assertReportedStat(post_failure_stat, value='1', kind='c')
+ self.assertReportedStat(post_failure_stat, kind='ms')
+
class TestNoLog(AnsibleZuulTestCase):
tenant_config_file = 'config/ansible-no-log/main.yaml'
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index bfabcecc2..b436c356f 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -844,7 +844,9 @@ class Scheduler(threading.Thread):
jobkey,
'RETRY' if build.result is None else build.result
)
- if build.result in ['SUCCESS', 'FAILURE'] and build.start_time:
+ results_with_runtime = ['SUCCESS', 'FAILURE',
+ 'POST_FAILURE', 'TIMED_OUT']
+ if build.result in results_with_runtime and build.start_time:
dt = (build.end_time - build.start_time) * 1000
self.statsd.timing(key, dt)
self.statsd.incr(key)