whiskers.git / backend / worker / tools / crosscheck
crosscheck41 lines · 1.6 KB · raw
1#!/usr/bin/env bash
2# The whole cross-host check: build the Worker once, then ask native `whiskersd`, `wrangler dev` and
3# `celld dev` the same questions with `hostcheck`, and compare their transcripts byte for byte.
4#
5#     nix develop ~/whiskers#backend -c backend/worker/tools/crosscheck
6#
7# Each host starts from an erased state. Output: $WHISKERS_SPIKE_STATE/out (default /tmp/whiskers-cellflare/out).
8set -euo pipefail
9here="$(cd "$(dirname "$0")/.." && pwd)"
10root="$(cd "$here/../.." && pwd)"
11state="${WHISKERS_SPIKE_STATE:-/tmp/whiskers-cellflare}"
12out="$state/out"
13mkdir -p "$out"
14host="$here/tools/host"
15
16(cd "$here" && worker-build --release)
17(cd "$root" && cargo build -p whiskersd)
18(cd "$root/backend/http-conformance" && cargo build --release)
19check="$root/backend/http-conformance/target/release/hostcheck"
20
21status=0
22declare -A port=([native]=8803 [wrangler]=8802 [celld]=8801)
23for h in native wrangler celld; do
24  "$host" "$h" fresh
25  extra=()
26  [ "$h" = native ] && extra=(--single-household)
27  "$check" --base "http://127.0.0.1:${port[$h]}" --label "$h" --out "$out" "${extra[@]}" \
28    --restart-cmd "$host $h restart >/dev/null" | tee "$out/$h.report" || status=1
29  "$host" "$h" stop
30done
31
32for pair in "native celld" "native wrangler" "celld wrangler"; do
33  set -- $pair
34  if cmp -s "$out/$1.transcript" "$out/$2.transcript"; then
35    echo "TRANSCRIPT $1 == $2 (byte for byte, $(wc -c < "$out/$1.transcript") bytes)"
36  else
37    echo "TRANSCRIPT $1 != $2"; status=1
38    diff <(cut -c1-300 "$out/$1.transcript") <(cut -c1-300 "$out/$2.transcript") | head -20 || true
39  fi
40done
41exit $status