mirror of
https://github.com/curl/curl.git
synced 2026-08-05 01:16:19 +03:00
pytest-xdist: pytest in parallel
Require now pytest-xdist from tests/http/requirements.txt and run pytest in 'auto' parallel mode (counts cpu cores). For CI runs, set the worker count to 4, overriding the core count of 2 exposed in the images. - use Filelock to generate allocated ports at start for all workers and have subsequent workers just read the file and take the ports for their slot - make httpd config clearing a function fixture so every test starts with a clean httpd config - have fixture `configures_httpd` as parameter of test cases that configure httpd anyway, saving one reload - add pytest-xdist and filelock to required pyhton modules - add installs to ruff CI - give live checks waiting for a server to start up longer time - add fixtures to tests that rely on a server - do not stop servers unnecessarily. failures may not start them properly again, leading to unexpected fails in whatever follows - add a https: port to httpd that is *not* back by QUIC to allow failover tests without stopping the QUIC server Closes #17295
This commit is contained in:
parent
f0bf43e209
commit
30ef79ed93
39 changed files with 644 additions and 449 deletions
|
|
@ -36,13 +36,6 @@ log = logging.getLogger(__name__)
|
|||
|
||||
class TestBasic:
|
||||
|
||||
@pytest.fixture(autouse=True, scope='class')
|
||||
def _class_scope(self, env, httpd, nghttpx):
|
||||
if env.have_h3():
|
||||
nghttpx.start_if_needed()
|
||||
httpd.clear_extra_configs()
|
||||
httpd.reload()
|
||||
|
||||
# simple http: GET
|
||||
def test_01_01_http_get(self, env: Env, httpd):
|
||||
curl = CurlClient(env=env)
|
||||
|
|
@ -99,7 +92,8 @@ class TestBasic:
|
|||
r.check_stats(http_status=200, count=1,
|
||||
remote_port=env.port_for(alpn_proto=proto),
|
||||
remote_ip='127.0.0.1')
|
||||
assert r.stats[0]['time_connect'] > 0, f'{r.stats[0]}'
|
||||
# there are cases where time_connect is reported as 0
|
||||
assert r.stats[0]['time_connect'] >= 0, f'{r.stats[0]}'
|
||||
assert r.stats[0]['time_appconnect'] > 0, f'{r.stats[0]}'
|
||||
|
||||
# simple https: HEAD
|
||||
|
|
@ -162,7 +156,7 @@ class TestBasic:
|
|||
pytest.skip("h3 not supported")
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}' \
|
||||
f'/curltest/tweak?x-hd={48 * 1024}'
|
||||
f'/curltest/tweak?x-hd={48 * 1024}'
|
||||
r = curl.http_get(url=url, alpn_proto=proto, extra_args=[])
|
||||
r.check_exit_code(0)
|
||||
assert len(r.responses) == 1, f'{r.responses}'
|
||||
|
|
@ -172,14 +166,14 @@ class TestBasic:
|
|||
@pytest.mark.skipif(condition=not Env.httpd_is_at_least('2.4.64'),
|
||||
reason='httpd must be at least 2.4.64')
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2'])
|
||||
def test_01_12_xlarge_resp_headers(self, env: Env, httpd, proto):
|
||||
def test_01_12_xlarge_resp_headers(self, env: Env, httpd, configures_httpd, proto):
|
||||
httpd.set_extra_config('base', [
|
||||
f'H2MaxHeaderBlockLen {130 * 1024}',
|
||||
])
|
||||
httpd.reload()
|
||||
httpd.reload_if_config_changed()
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}' \
|
||||
f'/curltest/tweak?x-hd={128 * 1024}'
|
||||
f'/curltest/tweak?x-hd={128 * 1024}'
|
||||
r = curl.http_get(url=url, alpn_proto=proto, extra_args=[])
|
||||
r.check_exit_code(0)
|
||||
assert len(r.responses) == 1, f'{r.responses}'
|
||||
|
|
@ -189,15 +183,15 @@ class TestBasic:
|
|||
@pytest.mark.skipif(condition=not Env.httpd_is_at_least('2.4.64'),
|
||||
reason='httpd must be at least 2.4.64')
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2'])
|
||||
def test_01_13_megalarge_resp_headers(self, env: Env, httpd, proto):
|
||||
def test_01_13_megalarge_resp_headers(self, env: Env, httpd, configures_httpd, proto):
|
||||
httpd.set_extra_config('base', [
|
||||
'LogLevel http2:trace2',
|
||||
f'H2MaxHeaderBlockLen {130 * 1024}',
|
||||
])
|
||||
httpd.reload()
|
||||
httpd.reload_if_config_changed()
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}' \
|
||||
f'/curltest/tweak?x-hd1={128 * 1024}'
|
||||
f'/curltest/tweak?x-hd1={128 * 1024}'
|
||||
r = curl.http_get(url=url, alpn_proto=proto, extra_args=[])
|
||||
if proto == 'h2':
|
||||
r.check_exit_code(16) # CURLE_HTTP2
|
||||
|
|
@ -209,15 +203,15 @@ class TestBasic:
|
|||
@pytest.mark.skipif(condition=not Env.httpd_is_at_least('2.4.64'),
|
||||
reason='httpd must be at least 2.4.64')
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2'])
|
||||
def test_01_14_gigalarge_resp_headers(self, env: Env, httpd, proto):
|
||||
def test_01_14_gigalarge_resp_headers(self, env: Env, httpd, configures_httpd, proto):
|
||||
httpd.set_extra_config('base', [
|
||||
'LogLevel http2:trace2',
|
||||
f'H2MaxHeaderBlockLen {1024 * 1024}',
|
||||
])
|
||||
httpd.reload()
|
||||
httpd.reload_if_config_changed()
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}' \
|
||||
f'/curltest/tweak?x-hd={256 * 1024}'
|
||||
f'/curltest/tweak?x-hd={256 * 1024}'
|
||||
r = curl.http_get(url=url, alpn_proto=proto, extra_args=[])
|
||||
if proto == 'h2':
|
||||
r.check_exit_code(16) # CURLE_HTTP2
|
||||
|
|
@ -228,15 +222,15 @@ class TestBasic:
|
|||
@pytest.mark.skipif(condition=not Env.httpd_is_at_least('2.4.64'),
|
||||
reason='httpd must be at least 2.4.64')
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2'])
|
||||
def test_01_15_gigalarge_resp_headers(self, env: Env, httpd, proto):
|
||||
def test_01_15_gigalarge_resp_headers(self, env: Env, httpd, configures_httpd, proto):
|
||||
httpd.set_extra_config('base', [
|
||||
'LogLevel http2:trace2',
|
||||
f'H2MaxHeaderBlockLen {1024 * 1024}',
|
||||
])
|
||||
httpd.reload()
|
||||
httpd.reload_if_config_changed()
|
||||
curl = CurlClient(env=env)
|
||||
url = f'https://{env.authority_for(env.domain1, proto)}' \
|
||||
f'/curltest/tweak?x-hd1={256 * 1024}'
|
||||
f'/curltest/tweak?x-hd1={256 * 1024}'
|
||||
r = curl.http_get(url=url, alpn_proto=proto, extra_args=[])
|
||||
if proto == 'h2':
|
||||
r.check_exit_code(16) # CURLE_HTTP2
|
||||
|
|
@ -245,7 +239,7 @@ class TestBasic:
|
|||
|
||||
# http: invalid request headers, GET, issue #16998
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_01_16_inv_req_get(self, env: Env, httpd, proto):
|
||||
def test_01_16_inv_req_get(self, env: Env, httpd, nghttpx, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
curl = CurlClient(env=env)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue