diff options
author | Zuul <zuul@review.opendev.org> | 2022-07-06 18:53:30 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2022-07-06 18:53:30 +0000 |
commit | e2a827e48a8ecfda12b2fe3da18c0d4e41cfd753 (patch) | |
tree | 37aae5d244ae750074bdbfaf0e93984b560fe7fd | |
parent | 35bee00c8e83f554d8a57dbfe476f43e3c7e7e6d (diff) | |
parent | c6737ced67c6aba846e3d104fa63bc80cefed435 (diff) | |
download | zuul-e2a827e48a8ecfda12b2fe3da18c0d4e41cfd753.tar.gz |
Merge "Report timing info for POST_FAILURE and TIMED_OUT builds"
-rw-r--r-- | tests/unit/test_v3.py | 16 | ||||
-rw-r--r-- | zuul/scheduler.py | 4 |
2 files changed, 19 insertions, 1 deletions
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py index ac10eda47..9fd8ea1d3 100644 --- a/tests/unit/test_v3.py +++ b/tests/unit/test_v3.py @@ -6503,6 +6503,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) |