From ce289c7cecdbd76ae28057ff7a696c4ea1a97f25 Mon Sep 17 00:00:00 2001 From: MDA2AV Date: Fri, 26 Jun 2026 23:47:55 +0100 Subject: [PATCH 1/3] Update validations, static tests for caching, refactor scripts --- scripts/lib/validate/assert.sh | 331 ++++ scripts/lib/validate/build.sh | 24 + scripts/lib/validate/checks/connection.sh | 88 + scripts/lib/validate/checks/database.sh | 213 ++ scripts/lib/validate/checks/gateway.sh | 415 ++++ scripts/lib/validate/checks/http2.sh | 163 ++ scripts/lib/validate/checks/json.sh | 198 ++ scripts/lib/validate/checks/static.sh | 113 ++ scripts/lib/validate/checks/upload.sh | 49 + scripts/lib/validate/checks/websocket.sh | 24 + scripts/lib/validate/container.sh | 188 ++ scripts/lib/validate/setup.sh | 87 + scripts/lib/validate/summary.sh | 8 + scripts/validate.sh | 1721 +---------------- .../implementation-rules/frameworks/tuned.md | 3 +- .../h1/isolated/static/implementation.md | 2 +- .../h2/static-h2/implementation.md | 2 +- .../h3/static-h3/implementation.md | 2 +- 18 files changed, 1933 insertions(+), 1698 deletions(-) create mode 100644 scripts/lib/validate/assert.sh create mode 100644 scripts/lib/validate/build.sh create mode 100644 scripts/lib/validate/checks/connection.sh create mode 100644 scripts/lib/validate/checks/database.sh create mode 100644 scripts/lib/validate/checks/gateway.sh create mode 100644 scripts/lib/validate/checks/http2.sh create mode 100644 scripts/lib/validate/checks/json.sh create mode 100644 scripts/lib/validate/checks/static.sh create mode 100644 scripts/lib/validate/checks/upload.sh create mode 100644 scripts/lib/validate/checks/websocket.sh create mode 100644 scripts/lib/validate/container.sh create mode 100644 scripts/lib/validate/setup.sh create mode 100644 scripts/lib/validate/summary.sh diff --git a/scripts/lib/validate/assert.sh b/scripts/lib/validate/assert.sh new file mode 100644 index 000000000..2d707d9f7 --- /dev/null +++ b/scripts/lib/validate/assert.sh @@ -0,0 +1,331 @@ +# scripts/lib/validate/assert.sh — DOCS_BASE, check helpers, wait_h2, static-freshness probe +# Part of the validate.sh suite — sourced by scripts/validate.sh, not run directly. + +# ───── Helpers ───── + +DOCS_BASE="https://www.http-arena.com/#doc=test-profiles" + +fail_with_link() { + local msg="$1" + local docs_url="$2" + echo " FAIL $msg" + if [ -n "$docs_url" ]; then + echo " → $docs_url" + fi + FAIL=$((FAIL + 1)) +} + +dump_debug() { + local trace="$1" + local response="$2" + if [ -n "$trace" ] && [ -s "$trace" ]; then + echo " ─── wire trace ───" + sed 's/^/ /' "$trace" + fi + if [ -n "$response" ]; then + echo " ─── response ───" + printf '%s\n' "$response" | sed 's/^/ /' + fi + [ -n "$trace" ] && rm -f "$trace" +} + +check() { + local label="$1" + local expected_body="$2" + local docs_url="$3" + shift 3 + local response trace + trace=$(mktemp) + response=$(curl -s --max-time 30 -D- --trace-ascii "$trace" "$@" || true) + local body + body=$(echo "$response" | tail -1) + + if [ "$body" = "$expected_body" ]; then + echo " PASS [$label]" + PASS=$((PASS + 1)) + rm -f "$trace" + else + fail_with_link "[$label]: expected body '$expected_body', got '$body'" "$docs_url" + dump_debug "$trace" "$response" + fi +} + +check_status() { + local label="$1" + local expected_status="$2" + local docs_url="$3" + shift 3 + local http_code trace body_file + trace=$(mktemp) + body_file=$(mktemp) + http_code=$(curl -s --max-time 30 -o "$body_file" -D "$body_file.hdr" -w '%{http_code}' --trace-ascii "$trace" "$@" || true) + + if [ "$http_code" = "$expected_status" ]; then + echo " PASS [$label] (HTTP $http_code)" + PASS=$((PASS + 1)) + rm -f "$trace" "$body_file" "$body_file.hdr" + else + fail_with_link "[$label]: expected HTTP $expected_status, got HTTP $http_code" "$docs_url" + local response="" + [ -s "$body_file.hdr" ] && response=$(cat "$body_file.hdr") + [ -s "$body_file" ] && response="${response}$(cat "$body_file")" + dump_debug "$trace" "$response" + rm -f "$body_file" "$body_file.hdr" + fi +} + +check_fragmented() { + # Send an HTTP request in multiple TCP writes with small pauses between + # them so the server's read loop sees partial, incomplete buffers and + # must reassemble across recv() calls. Exercises HTTP parser correctness + # under realistic network fragmentation (slow clients, small MTU, etc.). + # + # Usage: check_fragmented