mirror of
https://github.com/curl/curl.git
synced 2026-08-12 08:50:54 +03:00
curl: fix --test-event --parallel
(in debug-builds) Fix implementation in curl using libuv to process parallel transfers. Add pytest capabilities to run test cases with --test-event. - fix uv_timer handling to carry correct 'data' pointing to uv context. - fix uv_loop handling to reap and add transfers when possible - fix return code when a transfer errored Closes #14413
This commit is contained in:
parent
1b25448760
commit
b102763c19
4 changed files with 95 additions and 19 deletions
|
|
@ -87,18 +87,19 @@ class TestDownload:
|
|||
r.check_response(http_status=200, count=100, connect_count=1)
|
||||
|
||||
# download 100 files parallel
|
||||
@pytest.mark.parametrize("proto", ['h2', 'h3'])
|
||||
def test_02_04_download_100_parallel(self, env: Env,
|
||||
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])
|
||||
def test_02_04_download_20_parallel(self, env: Env,
|
||||
httpd, nghttpx, repeat, proto):
|
||||
if proto == 'h3' and not env.have_h3():
|
||||
pytest.skip("h3 not supported")
|
||||
max_parallel = 50
|
||||
count = 20
|
||||
max_parallel = 10
|
||||
curl = CurlClient(env=env)
|
||||
urln = f'https://{env.authority_for(env.domain1, proto)}/data.json?[0-99]'
|
||||
urln = f'https://{env.authority_for(env.domain1, proto)}/data.json?[0-{count-1}]'
|
||||
r = curl.http_download(urls=[urln], alpn_proto=proto, extra_args=[
|
||||
'--parallel', '--parallel-max', f'{max_parallel}'
|
||||
])
|
||||
r.check_response(http_status=200, count=100)
|
||||
r.check_response(http_status=200, count=count)
|
||||
if proto == 'http/1.1':
|
||||
# http/1.1 parallel transfers will open multiple connections
|
||||
assert r.total_connects > 1, r.dump_logs()
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class LocalClient:
|
|||
self.name = name
|
||||
self.path = os.path.join(env.project_dir, f'tests/http/clients/{name}')
|
||||
self.env = env
|
||||
self._run_env= run_env
|
||||
self._run_env = run_env
|
||||
self._timeout = timeout if timeout else env.test_timeout
|
||||
self._curl = os.environ['CURL'] if 'CURL' in os.environ else env.curl
|
||||
self._run_dir = run_dir if run_dir else os.path.join(env.gen_dir, name)
|
||||
|
|
@ -92,12 +92,18 @@ class LocalClient:
|
|||
exception = None
|
||||
myargs = [self.path]
|
||||
myargs.extend(args)
|
||||
run_env = None
|
||||
if self._run_env:
|
||||
run_env = self._run_env.copy()
|
||||
for key in ['CURL_DEBUG']:
|
||||
if key in os.environ and key not in run_env:
|
||||
run_env[key] = os.environ[key]
|
||||
try:
|
||||
with open(self._stdoutfile, 'w') as cout:
|
||||
with open(self._stderrfile, 'w') as cerr:
|
||||
p = subprocess.run(myargs, stderr=cerr, stdout=cout,
|
||||
cwd=self._run_dir, shell=False,
|
||||
input=None, env=self._run_env,
|
||||
input=None, env=run_env,
|
||||
timeout=self._timeout)
|
||||
exitcode = p.returncode
|
||||
except subprocess.TimeoutExpired:
|
||||
|
|
|
|||
|
|
@ -824,6 +824,9 @@ class CurlClient:
|
|||
urls = [urls]
|
||||
|
||||
args = [self._curl, "-s", "--path-as-is"]
|
||||
if 'CURL_TEST_EVENT' in os.environ:
|
||||
args.append('--test-event')
|
||||
|
||||
if with_headers:
|
||||
args.extend(["-D", self._headerfile])
|
||||
if def_tracing is not False and not self._silent:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue