mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-12 01:45:14 +02:00
OMNIGRAPH_CLUSTER boots the container from a mounted cluster directory's applied revision — checked first and exclusive (exit 64 when combined with OMNIGRAPH_TARGET_URI/CONFIG/TARGET), the entrypoint-level mirror of the server's mode-inference rule 0. The omnigraph CLI joins the image so the day-2 loop (cluster apply/approve/status, data loads by explicit URI) runs in-container via docker/ECS exec or railway shell — no omnigraph.yaml required, which the cluster-local-config PR pins. entrypoint_test gains the cluster case plus all three exclusivity refusals. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
85 lines
2.8 KiB
Bash
Executable file
85 lines
2.8 KiB
Bash
Executable file
#!/bin/sh
|
|
# Self-contained test for docker/entrypoint.sh argument composition.
|
|
# Runs the entrypoint against a stub server that echoes its args, and
|
|
# asserts the forwarded argv for each startup mode. No Docker required.
|
|
#
|
|
# sh docker/entrypoint_test.sh
|
|
#
|
|
# Exits 0 on success, 1 on the first mismatch.
|
|
set -eu
|
|
|
|
here=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
entrypoint="$here/entrypoint.sh"
|
|
|
|
work=$(mktemp -d)
|
|
trap 'rm -rf "$work"' EXIT
|
|
mkdir -p "$work/bin"
|
|
cat > "$work/bin/omnigraph-server" <<'EOF'
|
|
#!/bin/sh
|
|
echo "ARGS: $*"
|
|
EOF
|
|
chmod +x "$work/bin/omnigraph-server"
|
|
|
|
# Run the real entrypoint with SERVER_BIN pointed at the stub.
|
|
ep="$work/entrypoint.sh"
|
|
sed "s#SERVER_BIN=\"/usr/local/bin/omnigraph-server\"#SERVER_BIN=\"$work/bin/omnigraph-server\"#" \
|
|
"$entrypoint" > "$ep"
|
|
|
|
fail=0
|
|
check() {
|
|
desc=$1; want=$2; got=$3
|
|
if [ "$got" != "$want" ]; then
|
|
echo "FAIL: $desc"
|
|
echo " want: $want"
|
|
echo " got: $got"
|
|
fail=1
|
|
else
|
|
echo "ok: $desc"
|
|
fi
|
|
}
|
|
|
|
got=$(OMNIGRAPH_TARGET_URI="s3://b/g" OMNIGRAPH_BIND="0.0.0.0:8080" sh "$ep")
|
|
check "TARGET_URI only (legacy)" \
|
|
"ARGS: s3://b/g --bind 0.0.0.0:8080" "$got"
|
|
|
|
got=$(OMNIGRAPH_TARGET_URI="s3://b/g" OMNIGRAPH_CONFIG="/etc/omnigraph/omnigraph.yaml" OMNIGRAPH_BIND="0.0.0.0:8080" sh "$ep")
|
|
check "TARGET_URI + CONFIG composes (policy)" \
|
|
"ARGS: s3://b/g --config /etc/omnigraph/omnigraph.yaml --bind 0.0.0.0:8080" "$got"
|
|
|
|
got=$(OMNIGRAPH_CONFIG="/etc/omnigraph/omnigraph.yaml" OMNIGRAPH_BIND="0.0.0.0:8080" sh "$ep")
|
|
check "CONFIG only" \
|
|
"ARGS: --config /etc/omnigraph/omnigraph.yaml --bind 0.0.0.0:8080" "$got"
|
|
|
|
got=$(OMNIGRAPH_CONFIG="/etc/omnigraph/omnigraph.yaml" OMNIGRAPH_TARGET="active" OMNIGRAPH_BIND="0.0.0.0:8080" sh "$ep")
|
|
check "CONFIG + TARGET" \
|
|
"ARGS: --config /etc/omnigraph/omnigraph.yaml --target active --bind 0.0.0.0:8080" "$got"
|
|
|
|
got=$(sh "$ep" some-uri --bind 1.2.3.4:9 --extra)
|
|
check "explicit args passthrough" \
|
|
"ARGS: some-uri --bind 1.2.3.4:9 --extra" "$got"
|
|
|
|
got=$(OMNIGRAPH_CLUSTER="/var/lib/omnigraph/company-brain" OMNIGRAPH_BIND="0.0.0.0:8080" sh "$ep")
|
|
check "CLUSTER only (Phase 5 mode switch)" \
|
|
"ARGS: --cluster /var/lib/omnigraph/company-brain --bind 0.0.0.0:8080" "$got"
|
|
|
|
# Exclusivity: OMNIGRAPH_CLUSTER refuses every combination, exit 64.
|
|
for combo in "OMNIGRAPH_TARGET_URI=s3://b/g" "OMNIGRAPH_CONFIG=/etc/o.yaml" "OMNIGRAPH_TARGET=active"; do
|
|
if out=$(env "$combo" OMNIGRAPH_CLUSTER="/data/cluster" sh "$ep" 2>&1); then
|
|
echo "FAIL: CLUSTER + ${combo%%=*} unexpectedly succeeded: $out"
|
|
fail=1
|
|
else
|
|
status=$?
|
|
if [ "$status" -ne 64 ]; then
|
|
echo "FAIL: CLUSTER + ${combo%%=*} exited $status, want 64"
|
|
fail=1
|
|
else
|
|
echo "ok: CLUSTER + ${combo%%=*} refused (64)"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
if [ "$fail" -ne 0 ]; then
|
|
echo "entrypoint_test: FAILED"
|
|
exit 1
|
|
fi
|
|
echo "entrypoint_test: all cases passed"
|