Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Optional request headers:
| Header | Effect |
|---|---|
| `X-Mq-Method` | Method used toward the origin (default `GET`) |
| `X-Mq-Origin-Protocol` | Pins the origin protocol to `h1` or `h2` |
| `X-Mq-Origin-Protocol` | `h1` forces HTTP/1.1; `h2` (or no header) negotiates h2 or HTTP/1.1 |
| `X-Mq-Accept-Encoding` | Asks for compression on the download |
| `X-Mq-Forward-Cookie` | Forwards `Cookie` to the origin (withheld by default) |

Expand Down
9 changes: 4 additions & 5 deletions tests/integration/bench_ab_lanes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,10 @@ start_origin() {
# steps) for evidence that the extra MPQUIC path has been established before
# returning. The marker is:
#
# "mq_client: extra path up: bind <ip> -> path_id <n>"
# "mq_client: path up: bind <PATH_B_IP> -> path_id <n>"
#
# The bench passes --path PATH_A (primary bind, no log) and --path PATH_B
# (one extra path, logged once when mp-ready fires). We therefore poll for 1
# occurrence of "extra path up" in the client log. On timeout we continue but
# (one extra path, logged once when mp-ready fires). On timeout we continue but
# emit a loud stderr warning so the CSV row is flagged by the consumer.
start_pair() {
local tag="$1"; shift
Expand All @@ -182,12 +181,12 @@ start_pair() {
local waited=0 found=0 clog="${WORK}/client_${tag}.log"
while [ "${waited}" -lt 40 ]; do
sleep 0.2; waited=$((waited + 1))
if grep -q 'extra path up:' "${clog}" 2>/dev/null; then
if grep -qF "mq_client: path up: bind ${PATH_B_IP} " "${clog}" 2>/dev/null; then
found=1; break
fi
done
if [ "${found}" -eq 0 ]; then
note "bench_ab_lanes: WARNING: ${tag}: second path not confirmed at start (extra path up not seen after 8 s) — continuing, CSV row may be 1-path only"
note "bench_ab_lanes: WARNING: ${tag}: second path not confirmed at start (path up for ${PATH_B_IP} not seen after 8 s) — continuing, CSV row may be 1-path only"
fi
kill -0 "${SERVER_PID}" 2>/dev/null && kill -0 "${CLIENT_PID}" 2>/dev/null
}
Expand Down
88 changes: 5 additions & 83 deletions tests/integration/e2e_gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,13 @@ UPLOAD_SAVE="${WORK}/upload_saved.bin" # origin writes PUT bodies here
ORIGIN_PID=""
SERVER_PID=""
CLIENT_PID=""
DEMO_SERVER_PID="" # xquic demo_server for the gated case-13 h3 sub-case
TC_ON=0

cleanup() {
set +e
[ -n "${CLIENT_PID}" ] && kill "${CLIENT_PID}" 2>/dev/null
[ -n "${SERVER_PID}" ] && kill "${SERVER_PID}" 2>/dev/null
[ -n "${ORIGIN_PID}" ] && kill "${ORIGIN_PID}" 2>/dev/null
[ -n "${DEMO_SERVER_PID}" ] && kill "${DEMO_SERVER_PID}" 2>/dev/null
[ "${TC_ON}" -eq 1 ] && tc qdisc del dev lo root 2>/dev/null
wait 2>/dev/null
rm -rf "${WORK}"
Expand Down Expand Up @@ -615,14 +613,14 @@ ok 12 "X-Mq-Accept-Encoding: gzip compresses the download (content_encoding=gzip

# ── case 13: X-Mq-Origin-Protocol request-preference (no root) ───────────────
# Phase 6: the caller picks the origin HTTP version via X-Mq-Origin-Protocol.
# Two things are testable on the system (no-h3) libcurl build:
# Two things are tested:
# (a) an invalid value is rejected at the client with 400 + x-mq-error.
# (b) a valid h1 selection is read/relayed/mapped end-to-end (WIRING smoke).
# A real protocol SWITCH (h2/h3) cannot be proven here — the test origin (python
# A real protocol switch cannot be proven here — the test origin (python
# http.server) is HTTP/1.1-only, and the no-header default is ALSO h1 — so (b) is
# honestly a wiring smoke, NOT a switch-proof. The switch-proof is the GATED h3
# sub-case below (needs an h3-libcurl build + an h3 origin), which SKIPs on this
# build. (NB: this is the REQUEST-preference role of x-mq-origin-protocol; case 7
# honestly a wiring smoke, NOT a switch-proof. h2/h3 are preferences, not pins:
# the server offers h2 + http/1.1 via ALPN and has no HTTP/3 origin client.
# (NB: this is the REQUEST-preference role of x-mq-origin-protocol; case 7
# asserts the orthogonal RESPONSE-diagnostic role — both must hold.)

# ── (a) invalid value → 400 + x-mq-error: bad-origin-protocol ────────────────
Expand Down Expand Up @@ -666,82 +664,6 @@ if [ "${c13_found}" -ne 1 ]; then
fi
ok 13 "X-Mq-Origin-Protocol: invalid→400 (+x-mq-error); h1→honored (origin_protocol=h1, wiring smoke not switch-proof)"

# ── case 13 (h3): protocol SWITCH proof — GATED on an h3-libcurl build ────────
# This is the only honest switch-proof: select h3 to an h3-capable origin and
# assert the server actually negotiated h3 (mq.req origin_protocol=h3). It needs
# (1) the gateway built with MQPROXY_H3_CURL (server.log logs "HTTP3=yes" at
# startup), and
# (2) an h3 origin: xquic's demo_server (NOT built by default).
# On the system (no-h3) curl build this SKIPs with a note — it NEVER flips RESULT.
if grep -q 'HTTP3=yes' "${WORK}/server.log" 2>/dev/null; then
XQUIC_BUILD="${REPO_ROOT}/third_party/xquic/build"
# xquic builds demo_server under build/demo/ (the --target demo_server invocation
# below emits it there), NOT directly under build/.
DEMO_SERVER="${XQUIC_BUILD}/demo/demo_server"
if [ ! -x "${DEMO_SERVER}" ]; then
note "case 13 (h3): building demo_server (XQC_ENABLE_TESTING)..."
( cmake -S "${REPO_ROOT}/third_party/xquic" -B "${XQUIC_BUILD}" -DXQC_ENABLE_TESTING=ON >/dev/null 2>&1 \
&& cmake --build "${XQUIC_BUILD}" --target demo_server >/dev/null 2>&1 ) || \
note "case 13 (h3): demo_server build failed; see above."
fi
if [ -x "${DEMO_SERVER}" ]; then
H3_DIR="${WORK}/h3origin"
mkdir -p "${H3_DIR}"
cp "${ORIGIN_CERT}" "${H3_DIR}/server.crt"
cp "${ORIGIN_KEY}" "${H3_DIR}/server.key"
H3_SIZE=262144 # 256 KiB (gated h3 origin). The h3 grep below needs NO resp_bytes
# anchor: server.log is shared (not re-truncated here), but
# origin_protocol=h3 is emitted ONLY on a real HTTP/3 negotiation,
# which no other case exercises (all hit the h1 python origin).
head -c "${H3_SIZE}" /dev/zero >"${H3_DIR}/h3.bin"
H3_PORT="$(free_port udp)"
# `exec` so $! is the demo_server binary, NOT the subshell wrapper — otherwise
# the cleanup-trap kill would hit the wrapper and leak a stray QUIC server.
# (cert paths server.crt/server.key are CWD-relative, hence the cd.)
( cd "${H3_DIR}" && exec "${DEMO_SERVER}" -p "${H3_PORT}" -D "${H3_DIR}" >"${WORK}/demo_server.log" 2>&1 ) &
DEMO_SERVER_PID=$!
# Poll-based readiness (the script's idiom — no fixed sleep): retry the fetch
# until demo_server's QUIC listener is up (a not-yet-ready origin → non-200).
code13h3=000
H3_HDR="${WORK}/c13h3_headers.txt"
# Target https://localhost (NOT 127.0.0.1): the gateway sends SNI
# only for a hostname, never for an IP literal, and xquic's demo_server REQUIRES
# SNI (its cert callback errors "hostname is NULL" → CERT_CB_ERROR → 504). localhost
# resolves to 127.0.0.1 where demo_server listens, and the dual-SAN origin cert
# (IP:127.0.0.1,DNS:localhost) satisfies the gateway's hostname verification for it.
for _ in $(seq 1 25); do
code13h3="$(curl -s -o /dev/null -D "${H3_HDR}" -w '%{http_code}' --max-time 25 \
-X POST "http://${GW}/_mqproxy/fetch" -H "${AUTH}" \
-H "X-Mq-Target: https://localhost:${H3_PORT}/h3.bin" \
-H "X-Mq-Origin-Protocol: h3")"
[ "${code13h3}" = "200" ] && break
sleep 0.2
done
[ "${code13h3}" = "200" ] || fail 13 "h3 switch: fetch HTTP code = ${code13h3} (want 200); demo_server.log: $(tail -3 "${WORK}/demo_server.log" 2>/dev/null | tr '\n' '|')"
# Response-diagnostic header must ALSO report h3. Regression guard: this header
# is synthesized from resp_http_ver, which used to stay NONE until on_done —
# AFTER the response headers were already sent on the first body chunk — so
# http_ver_token defaulted to "http/1.1", mislabeling every body-bearing h2/h3
# response. (The mq.req metrics origin_protocol below is set at close/on_done and
# was always correct; only the RESPONSE header was wrong.)
grep -qi '^x-mq-origin-protocol:[[:space:]]*h3' "${H3_HDR}" || \
fail 13 "h3 switch: response x-mq-origin-protocol not h3; got: $(grep -i x-mq-origin-protocol "${H3_HDR}" || echo '<none>')"
c13h3_found=0
for _ in $(seq 1 25); do
if grep -Eq 'mq\.req .* origin_protocol=h3' "${WORK}/server.log"; then
c13h3_found=1; break
fi
sleep 0.2
done
[ "${c13h3_found}" -eq 1 ] || fail 13 "h3 switch: no mq.req origin_protocol=h3 in server.log"
ok 13 "X-Mq-Origin-Protocol: h3 → h3 negotiated (response header=h3 + mq.req origin_protocol=h3, SWITCH proof)"
else
note "case 13 (h3): demo_server unavailable — h3 SWITCH sub-case skipped (does not affect RESULT)."
fi
else
note "case 13 (h3): gateway built without h3-libcurl (HTTP3=no) — h3 SWITCH sub-case skipped (does not affect RESULT)."
fi

# ── case 14: X-Mq-Cache opt-in response cache (no root required) ──────────────
# Proves the minimal opt-in server-side cache end-to-end with a FALSIFIABLE
# origin-once assertion:
Expand Down
Loading