tests/http: fix HTTP/3 proxy pytest failures with h2o

Fix pytest failures in HTTP/3 proxy tests when h2o is not installed,
misconfigured, or fails to start at runtime.

This prevents:
- FileNotFoundError when h2o document root does not exist
- Fixture setup errors when h2o is configured but cannot start
- Unused test data file creation when h2o is absent or broken
- CI aborts on systems where h2o exists but is not runnable

Bug: https://github.com/curl/curl/pull/21789#issuecomment-4559098879
Bug: https://github.com/curl/curl/pull/21789#issuecomment-4559161907

Follow-up to e78b1b3ecc #21153

Closes #21791
This commit is contained in:
Aritra Basu 2026-05-27 20:35:44 -04:00 committed by Viktor Szakats
parent 9591ff123d
commit 91facd7bb3
No known key found for this signature in database
4 changed files with 30 additions and 18 deletions

View file

@ -909,6 +909,7 @@ class Env:
) -> str:
if line_length < 11:
raise RuntimeError("line_length less than 11 not supported")
os.makedirs(indir, exist_ok=True)
fpath = os.path.join(indir, fname)
s10 = "0123456789"
s = round((line_length / 10) + 1) * s10

View file

@ -241,6 +241,11 @@ class H2oServer(H2o):
super().__init__(
env=env, name="h2o-server", domain=env.domain1, cred_name=env.domain1
)
self._docs_dir = os.path.join(self.env.gen_dir, "docs")
@property
def docs_dir(self):
return self._docs_dir
def initial_start(self):
super().initial_start()
@ -261,11 +266,10 @@ class H2oServer(H2o):
def write_config(self):
creds = self.env.get_credentials(self._cred_name)
assert creds # convince pytype this is not None
doc_root = os.path.join(self.env.gen_dir, "docs")
self._mkpath(doc_root)
self._mkpath(self._docs_dir)
self._mkpath(self._run_dir)
# Create a simple test file
with open(os.path.join(doc_root, "data.json"), "w") as f:
with open(os.path.join(self._docs_dir, "data.json"), "w") as f:
f.write('{"message": "Hello from h2o HTTP/3 server"}\n')
with open(self._conf_file, "w") as fd:
fd.write(f"""# h2o HTTP/3 server configuration
@ -289,7 +293,7 @@ hosts:
"{self._domain}":
paths:
"/":
file.dir: {doc_root}
file.dir: {self._docs_dir}
http2-reprioritize-blocking-assets: ON