summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoug Hellmann <doug@doughellmann.com>2018-01-21 14:02:40 -0500
committerDoug Hellmann <doug@doughellmann.com>2018-01-21 14:05:44 -0500
commit09ffdccb617023abdc679c00f8c29d83632cab1c (patch)
tree9de756aabfe3e81fd87b0d2bb32f2a7c61326352
parent0212fb37ac65a3e0860b4179d64565b5929b7be9 (diff)
downloadoslo-log-09ffdccb617023abdc679c00f8c29d83632cab1c.tar.gz
update structured logging tests to prove context id is included
Add checks to the tests for the JSONFormatter and FluentFormatter to prove that the request id information is included as part of the "context" portion of the data sent to the formatter. Change-Id: If740897dbf1c3c01ecbb75f8509444022f2f05ba Signed-off-by: Doug Hellmann <doug@doughellmann.com>
-rw-r--r--oslo_log/tests/unit/test_log.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/oslo_log/tests/unit/test_log.py b/oslo_log/tests/unit/test_log.py
index c827057..553ad10 100644
--- a/oslo_log/tests/unit/test_log.py
+++ b/oslo_log/tests/unit/test_log.py
@@ -448,6 +448,10 @@ class JSONFormatterTestCase(LogTestBase):
self.assertEqual(ctx.user_name, context['user_name'])
self.assertEqual(ctx.project_name, context['project_name'])
self.assertEqual('test-json', data['name'])
+ self.assertIn('request_id', context)
+ self.assertEqual(ctx.request_id, context['request_id'])
+ self.assertIn('global_request_id', context)
+ self.assertEqual(ctx.global_request_id, context['global_request_id'])
self.assertEqual(test_msg % test_data, data['message'])
self.assertEqual(test_msg, data['msg'])
@@ -634,6 +638,12 @@ class FluentFormatterTestCase(LogTestBase):
self.assertEqual(local_context.user, context['user'])
self.assertEqual('test-fluent', data['name'])
+ self.assertIn('request_id', context)
+ self.assertEqual(local_context.request_id, context['request_id'])
+ self.assertIn('global_request_id', context)
+ self.assertEqual(local_context.global_request_id,
+ context['global_request_id'])
+
self.assertEqual(test_msg % test_data, data['message'])
self.assertEqual('test_log.py', data['filename'])