diff options
author | Scott Moser <smoser@ubuntu.com> | 2015-08-31 13:57:05 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2015-08-31 13:57:05 -0400 |
commit | 7820a43baf94e11ce458476a442edd726a406aba (patch) | |
tree | 2c8c711ef80b9d8ee44221596c8e9e512332d986 /tests/unittests | |
parent | 50bcb0f77d29a76a03946c6da13b15be25257402 (diff) | |
download | vyos-cloud-init-7820a43baf94e11ce458476a442edd726a406aba.tar.gz vyos-cloud-init-7820a43baf94e11ce458476a442edd726a406aba.zip |
events: add timestamp and origin, support file posting
This adds 'timestamp' and 'origin' to events.
The timestamp is simply that, a floating point timestamp of when
the event occurred.
The origin indicates the source / reporter of this. It is useful
to have a single endpoint with multiple different things reporting
to it. For example, MAAS will configure cloud-init and curtin
to report to the same endpoint and then it can differenciate who
made the post. Admittedly, they could use multiple endpoints, but
this this seems sane.
Also, add support for posting files at the close of an event.
This is utilized in curtin to post a log file when the install is
done. files are posted on success or fail of the event.
Diffstat (limited to 'tests/unittests')
-rw-r--r-- | tests/unittests/test_reporting.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/unittests/test_reporting.py b/tests/unittests/test_reporting.py index bb67ef73..0a441adf 100644 --- a/tests/unittests/test_reporting.py +++ b/tests/unittests/test_reporting.py @@ -241,7 +241,8 @@ class TestReportingEventStack(TestCase): self.assertEqual( [mock.call('myname', 'mydesc')], report_start.call_args_list) self.assertEqual( - [mock.call('myname', 'mydesc', events.status.SUCCESS)], + [mock.call('myname', 'mydesc', events.status.SUCCESS, + post_files=[])], report_finish.call_args_list) @mock.patch('cloudinit.reporting.events.report_finish_event') @@ -256,7 +257,7 @@ class TestReportingEventStack(TestCase): pass self.assertEqual([mock.call(name, desc)], report_start.call_args_list) self.assertEqual( - [mock.call(name, desc, events.status.FAIL)], + [mock.call(name, desc, events.status.FAIL, post_files=[])], report_finish.call_args_list) @mock.patch('cloudinit.reporting.events.report_finish_event') @@ -272,7 +273,7 @@ class TestReportingEventStack(TestCase): pass self.assertEqual([mock.call(name, desc)], report_start.call_args_list) self.assertEqual( - [mock.call(name, desc, events.status.WARN)], + [mock.call(name, desc, events.status.WARN, post_files=[])], report_finish.call_args_list) @mock.patch('cloudinit.reporting.events.report_start_event') @@ -301,7 +302,7 @@ class TestReportingEventStack(TestCase): child.result = events.status.WARN report_finish.assert_called_with( - "topname", "topdesc", events.status.WARN) + "topname", "topdesc", events.status.WARN, post_files=[]) @mock.patch('cloudinit.reporting.events.report_finish_event') def test_message_used_in_finish(self, report_finish): @@ -309,7 +310,8 @@ class TestReportingEventStack(TestCase): message="mymessage"): pass self.assertEqual( - [mock.call("myname", "mymessage", events.status.SUCCESS)], + [mock.call("myname", "mymessage", events.status.SUCCESS, + post_files=[])], report_finish.call_args_list) @mock.patch('cloudinit.reporting.events.report_finish_event') @@ -317,7 +319,8 @@ class TestReportingEventStack(TestCase): with events.ReportEventStack("myname", "mydesc") as c: c.message = "all good" self.assertEqual( - [mock.call("myname", "all good", events.status.SUCCESS)], + [mock.call("myname", "all good", events.status.SUCCESS, + post_files=[])], report_finish.call_args_list) @mock.patch('cloudinit.reporting.events.report_start_event') |