diff --git a/tests/smoke_test.py b/tests/smoke_test.py index d91e1b0..fe03581 100644 --- a/tests/smoke_test.py +++ b/tests/smoke_test.py @@ -57,15 +57,21 @@ class Client: self.operator_client=Client() self.operator_client.call('/operator/login',{'email':os.environ.get('OPERATOR_EMAIL','operator@example.test'),'password':os.environ.get('OPERATOR_PASSWORD','local-operator-only')}) return self.operator_client.call(path,body,expected=expected,method=method) - request=Request(BASE+'/api'+path,data=None if body is None else json.dumps(body).encode(), - headers=headers,method=method) - try: - with self.opener.open(request,timeout=30) as response: - assert response.status==expected,(path,response.status,expected) - return json.load(response) - except HTTPError as exc: - if exc.code!=expected:raise AssertionError((path,exc.code,exc.read().decode())) from exc - return json.load(exc) + for attempt in range(20): + request=Request(BASE+'/api'+path,data=None if body is None else json.dumps(body).encode(), + headers=headers,method=method) + try: + with self.opener.open(request,timeout=30) as response: + assert response.status==expected,(path,response.status,expected) + return json.load(response) + except HTTPError as exc: + if exc.code==expected:return json.load(exc) + text=exc.read().decode() + # The gateway's own limit (nginx, 20 r/s per address, burst 100) is + # an HTML page, not the API's JSON: a fast suite waits for it. + if exc.code==429 and text.lstrip().startswith('