test: port network suite to uce cli runner

This commit is contained in:
udo
2026-06-13 22:58:35 +00:00
parent b1856c1725
commit 6bb4f7f0ad
14 changed files with 541 additions and 891 deletions
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
socket_path="${UCE_CLI_SOCKET:-/run/uce/cli.sock}"
if [[ -z "${UCE_CLI_SOCKET:-}" && -r /etc/uce/settings.cfg ]]; then
configured_socket=$(awk -F= '/^[[:space:]]*CLI_SOCKET_PATH[[:space:]]*=/ {gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2); print $2; exit}' /etc/uce/settings.cfg)
if [[ -n "${configured_socket:-}" ]]; then
socket_path="$configured_socket"
fi
fi
include_kill=0
action="run"
while [[ $# -gt 0 ]]; do
case "$1" in
--include-wasm-kill|--include-kill)
include_kill=1
shift
;;
--list)
action="list"
shift
;;
-h|--help)
cat <<'USAGE'
Usage: scripts/run_cli_tests.sh [--include-wasm-kill] [--list]
Runs the UCE unit-based test suite through the runtime CLI socket.
USAGE
exit 0
;;
*)
echo "unknown option: $1" >&2
exit 2
;;
esac
done
if [[ ! -S "$socket_path" ]]; then
echo "UCE CLI socket not found: $socket_path" >&2
exit 1
fi
url="http://localhost/tests/cli_runner.uce?action=${action}&include_kill=${include_kill}"
exec curl -sS --fail-with-body --unix-socket "$socket_path" "$url"
+38 -59
View File
@@ -25,56 +25,46 @@ trap restore_on_error EXIT
set_backend() {
local enabled="$1"
python3 - "$CONFIG" "$enabled" <<'PY'
import sys
from pathlib import Path
path = Path(sys.argv[1])
enabled = sys.argv[2]
s = path.read_text()
lines = s.splitlines()
found = False
for i, line in enumerate(lines):
if line.startswith('WASM_BACKEND_ENABLED='):
lines[i] = f'WASM_BACKEND_ENABLED={enabled}'
found = True
if not found:
lines.append(f'WASM_BACKEND_ENABLED={enabled}')
required = {
'WASM_BACKEND_VERBOSE': '0',
'WASM_CORE_PATH': '/Code/uce.openfu.com/uce/bin/wasm/core.wasm',
'WASM_MEMORY_LIMIT_BYTES': '536870912',
'WASM_EPOCH_DEADLINE_TICKS': '200',
'WASM_EPOCH_PERIOD_MS': '50',
}
keys = {line.split('=', 1)[0] for line in lines if '=' in line}
for key, value in required.items():
if key not in keys:
lines.append(f'{key}={value}')
path.write_text('\n'.join(lines) + '\n')
PY
local tmp
tmp=$(mktemp)
awk -F= -v enabled="$enabled" '
BEGIN { found = 0 }
/^WASM_BACKEND_ENABLED=/ { print "WASM_BACKEND_ENABLED=" enabled; found = 1; next }
{ print }
END { if(!found) print "WASM_BACKEND_ENABLED=" enabled }
' "$CONFIG" > "$tmp"
for kv in \
'WASM_BACKEND_VERBOSE=0' \
'WASM_CORE_PATH=/Code/uce.openfu.com/uce/bin/wasm/core.wasm' \
'WASM_MEMORY_LIMIT_BYTES=536870912' \
'WASM_EPOCH_DEADLINE_TICKS=200' \
'WASM_EPOCH_PERIOD_MS=50'
do
key=${kv%%=*}
if ! grep -q "^${key}=" "$tmp"; then
printf '%s\n' "$kv" >> "$tmp"
fi
done
cat "$tmp" > "$CONFIG"
rm -f "$tmp"
systemctl restart uce.service >/dev/null
sleep 1
}
summarize_json() {
python3 - "$1" <<'PY'
import json, sys
rows = json.load(open(sys.argv[1]))
print(f"{sys.argv[1]}: {sum(1 for r in rows if r.get('ok'))}/{len(rows)}")
PY
summary_total() {
awk '/^Summary:/ { print $2; found=1 } END { if(!found) print 0 }' "$1"
}
# Native reference baseline.
set_backend 0
python3 tests/run_network_tests.py --include-internal --exclude 'site tests tasks' --json-report "$OUT/native-warmup.json" >/dev/null || true
python3 tests/run_network_tests.py --include-internal --json-report "$OUT/native-network.json"
scripts/run_cli_tests.sh > "$OUT/native-warmup.txt" || true
scripts/run_cli_tests.sh > "$OUT/native-network.txt"
python3 tests/wasm_benchmark.py --out-dir "$OUT/native-benchmark" --samples "${UCE_W5_BENCH_SAMPLES:-20}" --timeout 30 >/dev/null
# WASM default backend with W5 native fallbacks for host-owned surfaces.
set_backend 1
UCE_INCLUDE_WASM_KILL=1 python3 tests/run_network_tests.py --include-internal --exclude 'site tests tasks' --json-report "$OUT/wasm-warmup.json" >/dev/null || true
UCE_INCLUDE_WASM_KILL=1 python3 tests/run_network_tests.py --include-internal --json-report "$OUT/wasm-network.json"
python3 tests/run_network_tests.py --include-internal --match starter --json-report "$OUT/wasm-starter.json"
scripts/run_cli_tests.sh --include-wasm-kill > "$OUT/wasm-warmup.txt" || true
scripts/run_cli_tests.sh --include-wasm-kill > "$OUT/wasm-network.txt"
python3 tests/wasm_benchmark.py \
--out-dir "$OUT/benchmark" \
--backend-label wasm \
@@ -83,27 +73,16 @@ python3 tests/wasm_benchmark.py \
--timeout 30
python3 tests/wasm_site_audit.py --out-dir "$OUT" >/dev/null
python3 - "$OUT" <<'PY'
import json, sys
from pathlib import Path
out = Path(sys.argv[1])
network = json.loads((out / 'wasm-network.json').read_text())
starter = json.loads((out / 'wasm-starter.json').read_text())
bench = json.loads((out / 'benchmark' / 'benchmark.json').read_text())
failures = [r for r in network if not r.get('ok')] + [r for r in starter if not r.get('ok')] + [r for r in bench if not r.get('ok')]
structural = []
if len(network) < 80: structural.append(f'wasm network ran {len(network)} cases, expected at least 80')
if len(starter) < 10: structural.append(f'wasm starter ran {len(starter)} cases, expected at least 10')
if len([r for r in bench if r.get('backend') == 'wasm']) < 3: structural.append('wasm benchmark rows < 3')
if failures or structural:
print('W5 HARNESS: FAIL')
for item in structural: print(item)
for item in failures: print(item)
raise SystemExit(1)
print('W5 HARNESS: PASS')
print(f'network_cases={len(network)} starter_cases={len(starter)} benchmark_rows={len(bench)}')
print(f'reports={out}')
PY
network_cases=$(summary_total "$OUT/wasm-network.txt")
if [ "$network_cases" -lt 80 ]; then
echo "W5 HARNESS: FAIL"
echo "wasm network ran $network_cases cases, expected at least 80"
exit 1
fi
echo 'W5 HARNESS: PASS'
echo "network_cases=$network_cases benchmark_rows=see benchmark.json"
echo "reports=$OUT"
if [ "${UCE_W5_KEEP_BACKEND:-0}" = "1" ]; then
trap - EXIT