test: diagnose proxy startup failures

This commit is contained in:
2026-09-22 15:27:49 +08:00
parent 42021538b2
commit 52d603c31e

View File

@@ -10,6 +10,7 @@ import shutil
import socket import socket
import ssl import ssl
import subprocess import subprocess
import sys
import tempfile import tempfile
import time import time
@@ -194,6 +195,7 @@ def main() -> None:
try: try:
backend_port = wait_for_native(backend, 120) backend_port = wait_for_native(backend, 120)
write_nginx_config(directory / "nginx.conf", backend_port, edge_port) write_nginx_config(directory / "nginx.conf", backend_port, edge_port)
print(f"proxy backend=127.0.0.1:{backend_port} edge=127.0.0.1:{edge_port}", flush=True)
nginx = subprocess.Popen( nginx = subprocess.Popen(
[ [
"docker", "run", "--rm", "--pull=missing", "--name", nginx_name, "docker", "run", "--rm", "--pull=missing", "--name", nginx_name,
@@ -218,7 +220,18 @@ def main() -> None:
else: else:
raise RuntimeError("Nginx did not start listening") raise RuntimeError("Nginx did not start listening")
try:
wait_for_proxy(edge_port, 30) wait_for_proxy(edge_port, 30)
except Exception as error:
nginx_logs = subprocess.run(
["docker", "logs", nginx_name], capture_output=True, text=True, check=False
).stdout[-2000:]
backend_logs = subprocess.run(
["docker", "logs", backend_name], capture_output=True, text=True, check=False
).stdout[-2000:]
raise RuntimeError(
f"{error}; nginx logs={nginx_logs!r}; backend logs={backend_logs!r}"
) from error
verify_keep_alive(edge_port) verify_keep_alive(edge_port)
verify_timeout(edge_port) verify_timeout(edge_port)
print("PASS Nginx TLS proxy, Keep-Alive and upstream timeout", flush=True) print("PASS Nginx TLS proxy, Keep-Alive and upstream timeout", flush=True)