From 52b8bb368f23a1e1ad47770fa81a66c1b878108e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Mon, 16 Nov 2026 12:53:30 -0300 Subject: [PATCH] test: the test client waits out the gateway's rate limit instead of failing upload_limits_test sends about 300 requests in a few seconds (70 upload starts and deletes, a 30-upload burst, 66 sheets), past nginx's 20 r/s with a burst of 100 per address. On a busy runner the gateway answered 429 and the suite failed (runs 298, 301, 302, and 303 twice). The shared client now waits a second and retries when the 429 is nginx's HTML page; the API's own 429s, which the suites check with expected=429, are unchanged, and so is the production limit. Co-Authored-By: Claude Opus 5.5 (1M context) --- tests/smoke_test.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) 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('