Add openfeature module: OpenFeature Java SDK 1.23.0 and flagd 0.19.0 on Spring Boot 4.2.0, targeting, 10% rollout, live reload, flagd-down behaviour, InMemoryProvider tests, with real transcripts

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b6ZEVHGaYy15HAxRzy
This commit is contained in:
Ankur Mhatre
2026-12-01 08:26:22 +05:30
co-authored by Claude Sonnet 5.5
parent 658bc52e2b
commit 24dc4ba3ff
29 changed files with 1175 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# End-to-end: a real flagd daemon, the Spring Boot app, curl, a live flag edit, then flagd killed.
# Writes output/09-http-demo.txt. Needs FLAGD_BIN (or flagd on PATH), JAVA_HOME on JDK 25, mvn.
set -eu
cd "$(dirname "$0")/.."
FLAGD="${FLAGD_BIN:-flagd}"
OUT=output/09-http-demo.txt
WORK="$(mktemp -d)"
cp flags/flags.json "$WORK/flags.json"
mkdir -p output
mvn -B -q -DskipTests package
"$FLAGD" start -f "file:$WORK/flags.json" > "$WORK/flagd.log" 2>&1 &
FLAGD_PID=$!
for i in $(seq 1 30); do (echo > /dev/tcp/localhost/8013) 2>/dev/null && break; sleep 1; done
java -jar target/openfeature-1.0.0.jar > "$WORK/app.log" 2>&1 &
APP_PID=$!
trap 'kill $APP_PID $FLAGD_PID 2>/dev/null || true' EXIT
for i in $(seq 1 60); do
curl -s -o /dev/null localhost:8080/checkout && break
sleep 1
done
sleep 2 # let the provider finish connecting
call() { # call <label> <header>...
local label="$1"; shift
local args=() shown=""
for h in "$@"; do args+=(-H "$h"); shown+="-H '$h' "; done
echo "\$ curl ${shown}localhost:8080/checkout # $label"
curl -s "${args[@]}" localhost:8080/checkout | python3 -c '
import json, sys
d = json.load(sys.stdin)
print(" page:", d["page"])
for k in ("newCheckout", "paymentFlowV2", "discountPercent", "banner"):
print(" %-16s %s" % (k + ":", json.dumps(d[k])))'
echo
}
{
echo "# 1. Three callers, one flag file"
call "anonymous" "X-User-Id: anon-1"
call "standard" "X-User-Id: u2" "X-Tier: standard"
call "premium" "X-User-Id: u3" "X-Tier: premium"
call "staff" "X-User-Id: u4" "X-Tier: standard" "X-Email: [email protected]"
echo "# 2. Edit the flag file: new-checkout defaultVariant off -> on (no restart, no deploy)"
sed -i '/"new-checkout"/,/"defaultVariant"/ s/"defaultVariant": "off"/"defaultVariant": "on"/' "$WORK/flags.json"
sleep 2
call "anonymous, after the edit" "X-User-Id: anon-1"
echo "# 3. Kill flagd"
kill "$FLAGD_PID"; wait "$FLAGD_PID" 2>/dev/null || true
sleep 2
call "premium, flagd gone" "X-User-Id: u3" "X-Tier: premium"
} > "$OUT" 2>&1
{
echo
echo "# Application log: provider events, then the first hook lines"
strip() { sed -E 's/^[^ ]+ +([A-Z]+) [0-9]+ --- \[[^]]*\] +/\1 /' | cut -c1-150; }
grep -E 'flag provider|flag configuration' "$WORK/app.log" | strip | head -8
echo "..."
grep -E ': flag=' "$WORK/app.log" | strip | head -4
} >> "$OUT"
echo "wrote $OUT"