fix: restore jwt login and control-plane checks

This commit is contained in:
Naeel
2026-04-27 09:00:46 +03:00
parent 221a42dd17
commit 6e2d070b05
6 changed files with 248 additions and 45 deletions
+78
View File
@@ -51,6 +51,15 @@ auth_call() {
-d "{\"token\":\"${token}\",\"env\":\"${env_name}\"}"
}
auth_get() {
local path="$1"
local token="$2"
local env_name="${3:-test}"
curl -s -w "\n%{http_code}" --max-time 45 "${BASE}${path}" \
-H "X-Auth-Token: ${token}" \
-H "X-Auth-Env: ${env_name}"
}
create_call() {
local sub="$1"
local body="$2"
@@ -112,6 +121,67 @@ wait_invoke_ok() {
return 1
}
wait_init_ready() {
local token="$1"
local env_name="${2:-test}"
local tries="$3"
local delay="$4"
local try debug_raw debug_code debug_body status_raw status_code status_body ready done dbg_ready exec_ready exec_pods router_ready router_pods
for try in $(seq 1 "$tries"); do
debug_raw=$(auth_get "/ns/debug" "$token" "$env_name")
debug_code=$(printf '%s' "$debug_raw" | tail -1)
debug_body=$(printf '%s' "$debug_raw" | sed '$d')
status_raw=$(auth_get "/ns/status" "$token" "$env_name")
status_code=$(printf '%s' "$status_raw" | tail -1)
status_body=$(printf '%s' "$status_raw" | sed '$d')
ready=$(json_field "$status_body" ready)
done=$(printf '%s' "$status_body" | python3 -c 'import json,sys
try:
data=json.load(sys.stdin)
print(sum(1 for s in data.get("stages", []) if s.get("done")))
except Exception:
print(0)')
dbg_ready=$(printf '%s' "$debug_body" | python3 -c 'import json,sys
try:
data=json.load(sys.stdin)
print(str(data.get("controlPlane", {}).get("ready", "")))
except Exception:
print("")')
exec_ready=$(printf '%s' "$debug_body" | python3 -c 'import json,sys
try:
data=json.load(sys.stdin)
print(str(data.get("controlPlane", {}).get("executor", {}).get("ready", "")))
except Exception:
print("")')
exec_pods=$(printf '%s' "$debug_body" | python3 -c 'import json,sys
try:
data=json.load(sys.stdin)
print(data.get("controlPlane", {}).get("executor", {}).get("podCount", ""))
except Exception:
print("")')
router_ready=$(printf '%s' "$debug_body" | python3 -c 'import json,sys
try:
data=json.load(sys.stdin)
print(str(data.get("controlPlane", {}).get("router", {}).get("ready", "")))
except Exception:
print("")')
router_pods=$(printf '%s' "$debug_body" | python3 -c 'import json,sys
try:
data=json.load(sys.stdin)
print(data.get("controlPlane", {}).get("router", {}).get("podCount", ""))
except Exception:
print("")')
echo " INIT_TRY=${try} status_http=${status_code} debug_http=${debug_code} ready=${ready} done=${done}/3 cp_ready=${dbg_ready} executor_ready=${exec_ready} executor_pods=${exec_pods} router_ready=${router_ready} router_pods=${router_pods}"
if [ "$status_code" = "200" ] && [ "$debug_code" = "200" ] && [ "$ready" = "True" -o "$ready" = "true" ]; then
return 0
fi
if [ "$try" -lt "$tries" ]; then
sleep "$delay"
fi
done
return 1
}
echo ""
echo "========================================"
echo " UI-like user flow tests"
@@ -133,6 +203,14 @@ NS=$(json_field "$BODY" namespace)
[ "$CODE" = "200" ] && pass "login valid token -> 200" || fail "login valid token -> got $CODE"
printf '%s' "$NS" | grep -q '^fission-' && pass "login returns namespace" || fail "login namespace malformed: ${NS}"
echo ""
echo ">>> T02b: первый вход ждёт init overlay до 3/3"
if wait_init_ready "$LOGIN_SUB" "test" 12 5; then
pass "init overlay path -> namespace ready 3/3"
else
fail "init overlay path did not reach 3/3"
fi
echo ""
echo ">>> T03: ошибки create, которые типичны для UI"
R=$(create_call "$NEG_SUB" '{"name":"","language":"python","code":"def main():\n return 1"}')