test: добавлен префикс test- ко всем тестовым пользователям для явной идентификации и cleanup
This commit is contained in:
@@ -58,9 +58,9 @@ invoke_call() {
|
|||||||
echo "=== MULTIUSER TEST START run=$RUN_ID count=$COUNT ==="
|
echo "=== MULTIUSER TEST START run=$RUN_ID count=$COUNT ==="
|
||||||
|
|
||||||
for i in $(seq 1 "$COUNT"); do
|
for i in $(seq 1 "$COUNT"); do
|
||||||
USERS+=("${RUN_ID}-u${i}@test.local")
|
USERS+=("test-${RUN_ID}-u${i}@test.local")
|
||||||
(
|
(
|
||||||
U="${RUN_ID}-u${i}@test.local"
|
U="test-${RUN_ID}-u${i}@test.local"
|
||||||
CODE=$(init_call "${U}")
|
CODE=$(init_call "${U}")
|
||||||
echo "$i:$CODE:$U" > "${TMP}/init-$i"
|
echo "$i:$CODE:$U" > "${TMP}/init-$i"
|
||||||
) &
|
) &
|
||||||
@@ -81,7 +81,7 @@ echo "INIT_OK=$INIT_OK/$COUNT"
|
|||||||
|
|
||||||
for i in $(seq 1 "$COUNT"); do
|
for i in $(seq 1 "$COUNT"); do
|
||||||
(
|
(
|
||||||
U="${RUN_ID}-u${i}@test.local"
|
U="test-${RUN_ID}-u${i}@test.local"
|
||||||
FN="mtfn-${RUN_ID}-${i}"
|
FN="mtfn-${RUN_ID}-${i}"
|
||||||
CODE_TEXT=$(printf 'def main():\n return "ok-%s-%s"\n' "$RUN_ID" "$i")
|
CODE_TEXT=$(printf 'def main():\n return "ok-%s-%s"\n' "$RUN_ID" "$i")
|
||||||
CODE_JSON=$(printf '%s' "$CODE_TEXT" | json_escape)
|
CODE_JSON=$(printf '%s' "$CODE_TEXT" | json_escape)
|
||||||
@@ -108,7 +108,7 @@ sleep 8
|
|||||||
|
|
||||||
for i in $(seq 1 "$COUNT"); do
|
for i in $(seq 1 "$COUNT"); do
|
||||||
(
|
(
|
||||||
U="${RUN_ID}-u${i}@test.local"
|
U="test-${RUN_ID}-u${i}@test.local"
|
||||||
FN="mtfn-${RUN_ID}-${i}"
|
FN="mtfn-${RUN_ID}-${i}"
|
||||||
C=$(invoke_call "${U}" "${FN}")
|
C=$(invoke_call "${U}" "${FN}")
|
||||||
echo "$i:$C" > "${TMP}/invoke-$i"
|
echo "$i:$C" > "${TMP}/invoke-$i"
|
||||||
|
|||||||
@@ -52,9 +52,9 @@ invoke_call() {
|
|||||||
echo "=== USER JOURNEYS START run=$RUN_ID count=$COUNT ==="
|
echo "=== USER JOURNEYS START run=$RUN_ID count=$COUNT ==="
|
||||||
|
|
||||||
for i in $(seq 1 "$COUNT"); do
|
for i in $(seq 1 "$COUNT"); do
|
||||||
USERS+=("${RUN_ID}-u${i}@test.local")
|
USERS+=("test-${RUN_ID}-u${i}@test.local")
|
||||||
(
|
(
|
||||||
U="${RUN_ID}-u${i}@test.local"
|
U="test-${RUN_ID}-u${i}@test.local"
|
||||||
FN="journey-${RUN_ID}-${i}"
|
FN="journey-${RUN_ID}-${i}"
|
||||||
RESULT="PASS"
|
RESULT="PASS"
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ echo ">>> [1/4] Создаём NS для $COUNT пользователей па
|
|||||||
TMPDIR_RESULTS=$(mktemp -d)
|
TMPDIR_RESULTS=$(mktemp -d)
|
||||||
|
|
||||||
for i in $(seq 1 $COUNT); do
|
for i in $(seq 1 $COUNT); do
|
||||||
USER="${RUN_ID}-user${i}@test.local"
|
USER="test-test-test-${RUN_ID}-user${i}@test.local"
|
||||||
CREATED_USERS+=("$USER")
|
CREATED_USERS+=("$USER")
|
||||||
(
|
(
|
||||||
CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 30 \
|
CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 30 \
|
||||||
@@ -133,7 +133,7 @@ json_escape() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i in $(seq 1 $COUNT); do
|
for i in $(seq 1 $COUNT); do
|
||||||
USER="${USERS[$i]:-${RUN_ID}-user${i}@test.local}"
|
USER="${USERS[$i]:-test-test-${RUN_ID}-user${i}@test.local}"
|
||||||
FN_NAME="testfn-${RUN_ID}"
|
FN_NAME="testfn-${RUN_ID}"
|
||||||
(
|
(
|
||||||
# Создаём функцию
|
# Создаём функцию
|
||||||
@@ -175,7 +175,7 @@ echo ">>> [4/4] Параллельные вызовы всех $COUNT функц
|
|||||||
sleep 5
|
sleep 5
|
||||||
|
|
||||||
for i in $(seq 1 $COUNT); do
|
for i in $(seq 1 $COUNT); do
|
||||||
USER="${USERS[$i]:-${RUN_ID}-user${i}@test.local}"
|
USER="${USERS[$i]:-test-test-${RUN_ID}-user${i}@test.local}"
|
||||||
FN_NAME="testfn-${RUN_ID}"
|
FN_NAME="testfn-${RUN_ID}"
|
||||||
(
|
(
|
||||||
CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 30 \
|
CODE=$(curl -s -o /dev/null -w "%{http_code}" --max-time 30 \
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ RUN_ID="ui$(date +%s | tail -c 6)"
|
|||||||
PASS=0
|
PASS=0
|
||||||
FAIL=0
|
FAIL=0
|
||||||
|
|
||||||
LOGIN_SUB="ui-login-${RUN_ID}@test.local"
|
LOGIN_SUB="test-test-ui-login-${RUN_ID}@test.local"
|
||||||
LANG_SUB="ui-lang-${RUN_ID}@test.local"
|
LANG_SUB="test-test-ui-lang-${RUN_ID}@test.local"
|
||||||
NODE_SUB="ui-node-${RUN_ID}@test.local"
|
NODE_SUB="test-test-ui-node-${RUN_ID}@test.local"
|
||||||
STACK_SUB="ui-stack-${RUN_ID}@test.local"
|
STACK_SUB="test-test-ui-stack-${RUN_ID}@test.local"
|
||||||
NEG_SUB="ui-neg-${RUN_ID}@test.local"
|
NEG_SUB="test-test-ui-neg-${RUN_ID}@test.local"
|
||||||
|
|
||||||
pass() { PASS=$((PASS+1)); echo " PASS: $1"; }
|
pass() { PASS=$((PASS+1)); echo " PASS: $1"; }
|
||||||
fail() { FAIL=$((FAIL+1)); echo " FAIL: $1"; }
|
fail() { FAIL=$((FAIL+1)); echo " FAIL: $1"; }
|
||||||
|
|||||||
+19
-19
@@ -10,23 +10,23 @@ RUN_ID=$(echo "$RUN_ID" | sha256sum 2>/dev/null | head -c 8 || echo "${RUN_ID}"
|
|||||||
|
|
||||||
cleanup_namespaces() {
|
cleanup_namespaces() {
|
||||||
local subs=()
|
local subs=()
|
||||||
subs+=("alice@test.local" "routetest-alice@test.local" "routetest-bob@test.local")
|
subs+=("test-alice@test.local" "test-routetest-alice@test.local" "test-routetest-bob@test.local")
|
||||||
subs+=("val-user@test.local" "dup-user@test.local" "upd-user@test.local" "get-user@test.local")
|
subs+=("test-val-user@test.local" "test-dup-user@test.local" "test-upd-user@test.local" "test-get-user@test.local")
|
||||||
subs+=("ns-u1@test.local" "ns-u2@test.local" "alice-del@test.local" "carol-del@test.local")
|
subs+=("test-ns-u1@test.local" "test-ns-u2@test.local" "test-alice-del@test.local" "test-carol-del@test.local")
|
||||||
subs+=("py-user@test.local" "js-user@test.local" "ttl-user@test.local" "body-user@test.local")
|
subs+=("test-py-user@test.local" "test-js-user@test.local" "test-ttl-user@test.local" "test-body-user@test.local")
|
||||||
subs+=("stress-user@test.local" "brand-new-empty-user-xyzqwerty@test.local" "chain-user@test.local")
|
subs+=("test-stress-user@test.local" "test-brand-new-empty-user-xyzqwerty@test.local" "test-chain-user@test.local")
|
||||||
subs+=("dup2-user-${RUN_ID}@test.local" "name-user-${RUN_ID}@test.local")
|
subs+=("test-dup2-user-${RUN_ID}@test.local" "test-name-user-${RUN_ID}@test.local")
|
||||||
subs+=("len57-user-${RUN_ID}@test.local" "big-user-${RUN_ID}@test.local" "size-user-${RUN_ID}@test.local")
|
subs+=("test-len57-user-${RUN_ID}@test.local" "test-big-user-${RUN_ID}@test.local" "test-size-user-${RUN_ID}@test.local")
|
||||||
subs+=("ttl-exp-${RUN_ID}@test.local" "race-${RUN_ID}@test.local")
|
subs+=("test-ttl-exp-${RUN_ID}@test.local" "test-race-${RUN_ID}@test.local")
|
||||||
subs+=("mfunc-${RUN_ID}@test.local" "victim-${RUN_ID}@test.local" "attacker-${RUN_ID}@test.local")
|
subs+=("test-mfunc-${RUN_ID}@test.local" "test-victim-${RUN_ID}@test.local" "test-attacker-${RUN_ID}@test.local")
|
||||||
subs+=("lang-multi-${RUN_ID}@test.local" "lang-inv-${RUN_ID}@test.local")
|
subs+=("test-lang-multi-${RUN_ID}@test.local" "test-lang-inv-${RUN_ID}@test.local")
|
||||||
|
|
||||||
local uid
|
local uid
|
||||||
for uid in $(seq 1 10); do
|
for uid in $(seq 1 10); do
|
||||||
subs+=("u${uid}-${RUN_ID}@test.local")
|
subs+=("test-u${uid}-${RUN_ID}@test.local")
|
||||||
done
|
done
|
||||||
for uid in $(seq 1 3); do
|
for uid in $(seq 1 3); do
|
||||||
subs+=("fullcycle-u${uid}-${RUN_ID}@test.local")
|
subs+=("test-fullcycle-u${uid}-${RUN_ID}@test.local")
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -x "$NS_CLEANUP_SCRIPT" ]; then
|
if [ -x "$NS_CLEANUP_SCRIPT" ]; then
|
||||||
@@ -51,23 +51,23 @@ echo ""
|
|||||||
echo ">>> БЛОК A: Фиксы v0.6.8 — регресс"
|
echo ">>> БЛОК A: Фиксы v0.6.8 — регресс"
|
||||||
|
|
||||||
R=$(curl -s -w "\n%{http_code}" -X POST ${BASE}/functions/nonexistent-xyz-abc/invoke \
|
R=$(curl -s -w "\n%{http_code}" -X POST ${BASE}/functions/nonexistent-xyz-abc/invoke \
|
||||||
-H "X-Test-Sub: alice@test.local" -H "Content-Type: application/json" -d '{}')
|
-H "X-Test-Sub: test-alice@test.local" -H "Content-Type: application/json" -d '{}')
|
||||||
CODE=$(echo "$R" | tail -1); BODY=$(echo "$R" | head -1)
|
CODE=$(echo "$R" | tail -1); BODY=$(echo "$R" | head -1)
|
||||||
check_http "$CODE" "404" "INVOKE nonexistent → 404"
|
check_http "$CODE" "404" "INVOKE nonexistent → 404"
|
||||||
echo "$BODY" | grep -q "not found" && pass "INVOKE nonexistent — тело содержит 'not found'" || fail "INVOKE nonexistent — тело: $BODY"
|
echo "$BODY" | grep -q "not found" && pass "INVOKE nonexistent — тело содержит 'not found'" || fail "INVOKE nonexistent — тело: $BODY"
|
||||||
|
|
||||||
R=$(curl -s -w "\n%{http_code}" -X DELETE ${BASE}/functions/nonexistent-xyz-abc \
|
R=$(curl -s -w "\n%{http_code}" -X DELETE ${BASE}/functions/nonexistent-xyz-abc \
|
||||||
-H "X-Test-Sub: alice@test.local")
|
-H "X-Test-Sub: test-alice@test.local")
|
||||||
CODE=$(echo "$R" | tail -1)
|
CODE=$(echo "$R" | tail -1)
|
||||||
check_http "$CODE" "404" "DELETE nonexistent → 404"
|
check_http "$CODE" "404" "DELETE nonexistent → 404"
|
||||||
|
|
||||||
# Создаём изолированные функции и проверяем route isolation
|
# Создаём изолированные функции и проверяем route isolation
|
||||||
ISO_NAME="iso-${RUN_ID}"
|
ISO_NAME="iso-${RUN_ID}"
|
||||||
R_A=$(curl -s -X POST ${BASE}/functions \
|
R_A=$(curl -s -X POST ${BASE}/functions \
|
||||||
-H "X-Test-Sub: routetest-alice@test.local" -H "Content-Type: application/json" \
|
-H "X-Test-Sub: test-routetest-alice@test.local" -H "Content-Type: application/json" \
|
||||||
-d "{\"name\":\"${ISO_NAME}\",\"language\":\"nodejs\",\"code\":\"module.exports=async(ctx)=>({body:\\\"alice-iso\\\"})\",\"ttl\":\"5m\"}")
|
-d "{\"name\":\"${ISO_NAME}\",\"language\":\"nodejs\",\"code\":\"module.exports=async(ctx)=>({body:\\\"alice-iso\\\"})\",\"ttl\":\"5m\"}")
|
||||||
R_B=$(curl -s -X POST ${BASE}/functions \
|
R_B=$(curl -s -X POST ${BASE}/functions \
|
||||||
-H "X-Test-Sub: routetest-bob@test.local" -H "Content-Type: application/json" \
|
-H "X-Test-Sub: test-routetest-bob@test.local" -H "Content-Type: application/json" \
|
||||||
-d "{\"name\":\"${ISO_NAME}\",\"language\":\"nodejs\",\"code\":\"module.exports=async(ctx)=>({body:\\\"bob-iso\\\"})\",\"ttl\":\"5m\"}")
|
-d "{\"name\":\"${ISO_NAME}\",\"language\":\"nodejs\",\"code\":\"module.exports=async(ctx)=>({body:\\\"bob-iso\\\"})\",\"ttl\":\"5m\"}")
|
||||||
ROUTE_A=$(echo "$R_A" | python3 -c "import sys,json; print(json.load(sys.stdin).get('route','?'))" 2>/dev/null)
|
ROUTE_A=$(echo "$R_A" | python3 -c "import sys,json; print(json.load(sys.stdin).get('route','?'))" 2>/dev/null)
|
||||||
ROUTE_B=$(echo "$R_B" | python3 -c "import sys,json; print(json.load(sys.stdin).get('route','?'))" 2>/dev/null)
|
ROUTE_B=$(echo "$R_B" | python3 -c "import sys,json; print(json.load(sys.stdin).get('route','?'))" 2>/dev/null)
|
||||||
@@ -77,9 +77,9 @@ sleep 10
|
|||||||
|
|
||||||
# Invoke после изоляции
|
# Invoke после изоляции
|
||||||
INV_A=$(curl -s -X POST ${BASE}/functions/${ISO_NAME}/invoke \
|
INV_A=$(curl -s -X POST ${BASE}/functions/${ISO_NAME}/invoke \
|
||||||
-H "X-Test-Sub: routetest-alice@test.local" -H "Content-Type: application/json" -d '{}')
|
-H "X-Test-Sub: test-routetest-alice@test.local" -H "Content-Type: application/json" -d '{}')
|
||||||
INV_B=$(curl -s -X POST ${BASE}/functions/${ISO_NAME}/invoke \
|
INV_B=$(curl -s -X POST ${BASE}/functions/${ISO_NAME}/invoke \
|
||||||
-H "X-Test-Sub: routetest-bob@test.local" -H "Content-Type: application/json" -d '{}')
|
-H "X-Test-Sub: test-routetest-bob@test.local" -H "Content-Type: application/json" -d '{}')
|
||||||
BODY_A=$(echo "$INV_A" | python3 -c "import sys,json; print(json.load(sys.stdin).get('response_raw','?'))" 2>/dev/null)
|
BODY_A=$(echo "$INV_A" | python3 -c "import sys,json; print(json.load(sys.stdin).get('response_raw','?'))" 2>/dev/null)
|
||||||
BODY_B=$(echo "$INV_B" | python3 -c "import sys,json; print(json.load(sys.stdin).get('response_raw','?'))" 2>/dev/null)
|
BODY_B=$(echo "$INV_B" | python3 -c "import sys,json; print(json.load(sys.stdin).get('response_raw','?'))" 2>/dev/null)
|
||||||
[ "$BODY_A" = "alice-iso" ] && pass "Route isolation invoke — alice получает alice" || fail "Route isolation — alice получила: $BODY_A"
|
[ "$BODY_A" = "alice-iso" ] && pass "Route isolation invoke — alice получает alice" || fail "Route isolation — alice получила: $BODY_A"
|
||||||
@@ -90,7 +90,7 @@ echo ""
|
|||||||
echo ">>> БЛОК B: Валидация входных данных"
|
echo ">>> БЛОК B: Валидация входных данных"
|
||||||
|
|
||||||
R=$(curl -s -w "\n%{http_code}" -X POST ${BASE}/functions \
|
R=$(curl -s -w "\n%{http_code}" -X POST ${BASE}/functions \
|
||||||
-H "X-Test-Sub: val-user@test.local" -H "Content-Type: application/json" \
|
-H "X-Test-Sub: test-val-user@test.local" -H "Content-Type: application/json" \
|
||||||
-d '{"language":"nodejs","code":"x"}')
|
-d '{"language":"nodejs","code":"x"}')
|
||||||
CODE=$(echo "$R" | tail -1); check_http "$CODE" "400" "Создание без name → 400"
|
CODE=$(echo "$R" | tail -1); check_http "$CODE" "400" "Создание без name → 400"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user