From 8a64bff2dc28b43b3ed4fa7b65da1a9ea29677cc Mon Sep 17 00:00:00 2001 From: Samuel Merritt Date: Wed, 27 Nov 2013 17:23:59 -0800 Subject: [PATCH] Report transaction ID in failure exceptions This way, when something fails in Jenkins, you have some chance of searching the logs for the relevant transaction. Change-Id: I3cf606cb4963e32b5c6ac3deda08e73541b3ff7d --- test/functional/swift_test_client.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/test/functional/swift_test_client.py b/test/functional/swift_test_client.py index 6251c39d2a..0232dbabb0 100644 --- a/test/functional/swift_test_client.py +++ b/test/functional/swift_test_client.py @@ -45,14 +45,23 @@ class ResponseError(Exception): self.reason = response.reason self.method = method self.path = path + self.headers = response.getheaders() + + for name, value in self.headers: + if name.lower() == 'x-trans-id': + self.txid = value + break + else: + self.txid = None + super(ResponseError, self).__init__() def __str__(self): return repr(self) def __repr__(self): - return '%d: %r (%r %r)' % (self.status, self.reason, self.method, - self.path) + return '%d: %r (%r %r) txid=%s' % ( + self.status, self.reason, self.method, self.path, self.txid) def listing_empty(method):