pytest: check 429 handling

Add a "limit" handler to httpd that responds 429 after 5 requests and
then 429s all requests for 2 seconds. After which another 4 requests are
served before 429 strikes again.

Closes #21357
This commit is contained in:
Stefan Eissing 2026-04-17 15:21:12 +02:00 committed by Daniel Stenberg
parent 6daf4bc7e2
commit e0b2ec2400
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 142 additions and 3 deletions

View file

@ -217,3 +217,15 @@ class TestErrors:
# - CURLE_RECV_ERROR (56) - some TLS backends fail with that
assert r.exit_code in [35, 56], \
f'unexpected error {r.exit_code}\n{r.dump_logs()}'
# Get a resource many times with limited requests
@pytest.mark.skipif(condition=not Env.have_h2_curl(), reason='curl without HTTP/2')
def test_05_10_limits(self, env: Env, httpd):
proto = 'h2'
count = 6
curl = CurlClient(env=env)
url = f'https://{env.authority_for(env.domain1, proto)}/curltest/limit?id=[0-{count-1}]'
r = curl.http_download(urls=[url], alpn_proto=proto, extra_args=[
'--parallel', '--retry', '5'
])
r.check_stats(count=count, http_status=200, exitcode=0)