Skip to content

Commit d9958b2

Browse files
icingnbaws
authored andcommitted
pytest: make test_07_22 more lenient to exit codes
Depending on timing when the server aborting the connection is detected, the reported curl exit code may vary. Check for the possible set of expected codes instead of a single one. Closes curl#17083
1 parent 1cc5eb1 commit d9958b2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

tests/http/test_07_upload.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,9 @@ def test_07_22_upload_parallel_fail(self, env: Env, httpd, nghttpx, proto):
274274
f'/curltest/tweak?status=400&delay=5ms&chunks=1&body_error=reset&id=[0-{count-1}]'
275275
r = curl.http_upload(urls=[url], data=f'@{fdata}', alpn_proto=proto,
276276
extra_args=['--parallel'])
277-
exp_exit = 92 if proto == 'h2' else 95
278-
r.check_stats(count=count, exitcode=exp_exit)
277+
# depending on timing and protocol, we might get CURLE_PARTIAL_FILE or
278+
# CURLE_HTTP3 or CURLE_HTTP2_STREAM
279+
r.check_stats(count=count, exitcode=[18, 92, 95])
279280

280281
# PUT 100k
281282
@pytest.mark.parametrize("proto", ['http/1.1', 'h2', 'h3'])

tests/http/testenv/curl.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,13 @@ def check_response(self, http_status: Optional[int] = 200,
386386
f'were made\n{self.dump_logs()}'
387387

388388
def check_stats(self, count: int, http_status: Optional[int] = None,
389-
exitcode: Optional[int] = None,
389+
exitcode: Optional[Union[int, List[int]]] = None,
390390
remote_port: Optional[int] = None,
391391
remote_ip: Optional[str] = None):
392392
if exitcode is None:
393393
self.check_exit_code(0)
394+
elif isinstance(exitcode, int):
395+
exitcode = [exitcode]
394396
assert len(self.stats) == count, \
395397
f'stats count: expected {count}, got {len(self.stats)}\n{self.dump_logs()}'
396398
if http_status is not None:
@@ -403,7 +405,7 @@ def check_stats(self, count: int, http_status: Optional[int] = None,
403405
if exitcode is not None:
404406
for idx, x in enumerate(self.stats):
405407
if 'exitcode' in x:
406-
assert x['exitcode'] == exitcode, \
408+
assert x['exitcode'] in exitcode, \
407409
f'status #{idx} exitcode: expected {exitcode}, '\
408410
f'got {x["exitcode"]}\n{self.dump_stat(x)}'
409411
if remote_port is not None:

0 commit comments

Comments
 (0)