diff options
author | Naveed Massjouni <naveedm9@gmail.com> | 2012-01-12 17:22:11 +0000 |
---|---|---|
committer | Naveed Massjouni <naveedm9@gmail.com> | 2012-01-13 20:04:04 +0000 |
commit | 72f96b0d37ce870f52a9b6b05fb698fcac062f43 (patch) | |
tree | d86cccdc8d8f0d8590f4a5b34bcd04fde793acd5 | |
parent | 6c898e6abf44caa176790e9cd4505aeed145397c (diff) | |
download | nova-72f96b0d37ce870f52a9b6b05fb698fcac062f43.tar.gz nova-72f96b0d37ce870f52a9b6b05fb698fcac062f43.tar.xz nova-72f96b0d37ce870f52a9b6b05fb698fcac062f43.zip |
Prefixing the request id with 'req-' to decrease confusion when looking
at logs.
Change-Id: Ic29b9c6b83c4572d17c0b48fb509063d279d3a78
-rw-r--r-- | nova/context.py | 2 | ||||
-rw-r--r-- | nova/tests/api/openstack/test_wsgi.py | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/nova/context.py b/nova/context.py index 79ad0934d..b0c0603a8 100644 --- a/nova/context.py +++ b/nova/context.py @@ -59,7 +59,7 @@ class RequestContext(object): timestamp = utils.parse_strtime(timestamp) self.timestamp = timestamp if not request_id: - request_id = unicode(uuid.uuid4()) + request_id = 'req-' + str(utils.gen_uuid()) self.request_id = request_id self.auth_token = auth_token self.strategy = strategy diff --git a/nova/tests/api/openstack/test_wsgi.py b/nova/tests/api/openstack/test_wsgi.py index 2d5f33eee..84c009040 100644 --- a/nova/tests/api/openstack/test_wsgi.py +++ b/nova/tests/api/openstack/test_wsgi.py @@ -225,12 +225,22 @@ class RequestHeadersDeserializerTest(test.TestCase): class ResponseHeadersSerializerTest(test.TestCase): def test_request_id(self): serializer = wsgi.ResponseHeadersSerializer() + context = nova.context.get_admin_context() req = webob.Request.blank('/', environ={'nova.context': context}) res = webob.Response(request=req) serializer.serialize(res, {}, 'foo') - self.assertTrue( - utils.is_uuid_like(res.headers['X-Compute-Request-Id'])) + h1 = res.headers.get('X-Compute-Request-Id') + self.assertTrue(h1) + + context = nova.context.get_admin_context() + req = webob.Request.blank('/', environ={'nova.context': context}) + res = webob.Response(request=req) + serializer.serialize(res, {}, 'foo') + h2 = res.headers.get('X-Compute-Request-Id') + self.assertTrue(h2) + + self.assertNotEqual(h1, h2) class JSONSerializer(object): |