Fixes LP#920812 - KeyError: 'overLimit' on 413 return
Turns out that over quota limit and over ratelimits
return different keys in the faults. This patch adds
a new exception for RateLimitExceeded that handles
413 returns when there is an overLimitFault key (and
not the overLimit key that is in the over Quota fault)
Change-Id: I64d10cb592512e7de71c5d8518131deee516d9b2
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index ea09cc0..a795e02 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -115,7 +115,12 @@
if resp.status == 413:
body = json.loads(body)
- raise exceptions.OverLimit(body['overLimit']['message'])
+ if 'overLimit' in body:
+ raise exceptions.OverLimit(body['overLimit']['message'])
+ else:
+ raise exceptions.RateLimitExceeded(
+ message=body['overLimitFault']['message'],
+ details=body['overLimitFault']['details'])
if resp.status in (500, 501):
body = json.loads(body)
diff --git a/tempest/exceptions.py b/tempest/exceptions.py
index f1becda..a3fabe3 100644
--- a/tempest/exceptions.py
+++ b/tempest/exceptions.py
@@ -52,6 +52,11 @@
message = "Endpoint not found"
+class RateLimitExceeded(TempestException):
+ message = ("Rate limit exceeded.\nMessage: %(message)s\n"
+ "Details: %(details)s")
+
+
class OverLimit(TempestException):
message = "Quota exceeded"