summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/context.py2
-rw-r--r--nova/tests/api/openstack/test_wsgi.py14
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):