Merge "Include enqueue and report timestamps in MQTT msg"

This commit is contained in:
Zuul 2018-10-15 15:03:36 +00:00 committed by Gerrit Code Review
commit 47de21ae22
2 changed files with 5 additions and 0 deletions

View File

@ -492,6 +492,8 @@ class TestMQTTConnection(ZuulTestCase):
'test')
self.assertEquals(mqtt_payload['buildset']['builds'][0]['result'],
'SUCCESS')
self.assertIn('timestamp', mqtt_payload)
self.assertIn('enqueue_time', mqtt_payload)
def test_mqtt_invalid_topic(self):
in_repo_conf = textwrap.dedent(

View File

@ -13,6 +13,7 @@
# under the License.
import logging
import time
import voluptuous as v
from zuul.reporter import BaseReporter
@ -28,6 +29,7 @@ class MQTTReporter(BaseReporter):
self.log.debug("Report change %s, params %s" %
(item.change, self.config))
message = {
'timestamp': time.time(),
'action': self._action,
'tenant': item.pipeline.tenant.name,
'zuul_ref': item.current_build_set.ref,
@ -40,6 +42,7 @@ class MQTTReporter(BaseReporter):
'ref': getattr(item.change, 'ref', ''),
'message': self._formatItemReport(
item, with_jobs=False),
'enqueue_time': item.enqueue_time,
'buildset': {
'uuid': item.current_build_set.uuid,
'builds': []