fix: run_stress_test.sh — tf_output_json для объектных outputs, fix pipeline в assert_step
This commit is contained in:
+16
-9
@@ -194,6 +194,12 @@ tf_output() {
|
|||||||
(cd "$chdir" && terraform output -raw "$key" 2>/dev/null) || echo ""
|
(cd "$chdir" && terraform output -raw "$key" 2>/dev/null) || echo ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# tf_output_json — для объектных/map outputs (-raw не работает для них)
|
||||||
|
tf_output_json() {
|
||||||
|
local chdir="$1" key="$2"
|
||||||
|
(cd "$chdir" && terraform output -json "$key" 2>/dev/null) || echo "{}"
|
||||||
|
}
|
||||||
|
|
||||||
# ── Утилиты: счётчик шагов ────────────────────────────────────────────────────
|
# ── Утилиты: счётчик шагов ────────────────────────────────────────────────────
|
||||||
STEP_NUM=0
|
STEP_NUM=0
|
||||||
STEP_FAILS=0
|
STEP_FAILS=0
|
||||||
@@ -495,9 +501,10 @@ test_notes_python() {
|
|||||||
assert_step "apply OK" tf_apply "${log}-r1-apply.log" "$dir" || { RESULTS[$ex]="FAIL: R1 apply"; return 1; }
|
assert_step "apply OK" tf_apply "${log}-r1-apply.log" "$dir" || { RESULTS[$ex]="FAIL: R1 apply"; return 1; }
|
||||||
|
|
||||||
# Проверяем DB init джобы
|
# Проверяем DB init джобы
|
||||||
|
# db_init_*_status — объектные outputs {phase, message}: нужен -json, не -raw
|
||||||
local tbl_phase idx_phase
|
local tbl_phase idx_phase
|
||||||
tbl_phase=$(tf_output "$dir" "db_init_table_status" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('phase','?'))" 2>/dev/null || echo "?")
|
tbl_phase=$(tf_output_json "$dir" "db_init_table_status" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('phase','?'))" 2>/dev/null || echo "?")
|
||||||
idx_phase=$(tf_output "$dir" "db_init_index_status" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('phase','?'))" 2>/dev/null || echo "?")
|
idx_phase=$(tf_output_json "$dir" "db_init_index_status" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('phase','?'))" 2>/dev/null || echo "?")
|
||||||
next_step "[R1] DB init jobs check"
|
next_step "[R1] DB init jobs check"
|
||||||
assert_step "table init Succeeded" [ "$tbl_phase" = "Succeeded" ]
|
assert_step "table init Succeeded" [ "$tbl_phase" = "Succeeded" ]
|
||||||
assert_step "index init Succeeded" [ "$idx_phase" = "Succeeded" ]
|
assert_step "index init Succeeded" [ "$idx_phase" = "Succeeded" ]
|
||||||
@@ -515,9 +522,9 @@ test_notes_python() {
|
|||||||
add1=$(http_post "${notes_url}/add?title=StressTest1&body=body1" '{}')
|
add1=$(http_post "${notes_url}/add?title=StressTest1&body=body1" '{}')
|
||||||
add2=$(http_post "${notes_url}/add?title=StressTest2&body=body2" '{}')
|
add2=$(http_post "${notes_url}/add?title=StressTest2&body=body2" '{}')
|
||||||
add3=$(http_post "${notes_url}/add?title=StressTest3&body=body3" '{}')
|
add3=$(http_post "${notes_url}/add?title=StressTest3&body=body3" '{}')
|
||||||
assert_step "add note1 OK" echo "$add1" | grep -qiE '"id"|"created|created_at'
|
assert_step "add note1 OK" bash -c "[[ '$add1' =~ \"id\"|created ]]"
|
||||||
assert_step "add note2 OK" echo "$add2" | grep -qiE '"id"|"created|created_at'
|
assert_step "add note2 OK" bash -c "[[ '$add2' =~ \"id\"|created ]]"
|
||||||
assert_step "add note3 OK" echo "$add3" | grep -qiE '"id"|"created|created_at'
|
assert_step "add note3 OK" bash -c "[[ '$add3' =~ \"id\"|created ]]"
|
||||||
info " add1: $add1"
|
info " add1: $add1"
|
||||||
info " add2: $add2"
|
info " add2: $add2"
|
||||||
|
|
||||||
@@ -525,7 +532,7 @@ test_notes_python() {
|
|||||||
next_step "[R1] CRUD: list notes"
|
next_step "[R1] CRUD: list notes"
|
||||||
local listed
|
local listed
|
||||||
listed=$(http_get "$notes_list_url")
|
listed=$(http_get "$notes_list_url")
|
||||||
assert_step "list contains StressTest" echo "$listed" | grep -q 'StressTest'
|
assert_step "list contains StressTest" bash -c "grep -q 'StressTest' <<< '$listed'"
|
||||||
info " list (первые 200 символов): ${listed:0:200}"
|
info " list (первые 200 символов): ${listed:0:200}"
|
||||||
|
|
||||||
# Update nota1 (если вернулся id)
|
# Update nota1 (если вернулся id)
|
||||||
@@ -535,7 +542,7 @@ test_notes_python() {
|
|||||||
next_step "[R1] CRUD: update note id=$note_id"
|
next_step "[R1] CRUD: update note id=$note_id"
|
||||||
local updated
|
local updated
|
||||||
updated=$(http_post "${notes_url}/update?id=${note_id}&title=StressUpdated&body=updated_body" '{}')
|
updated=$(http_post "${notes_url}/update?id=${note_id}&title=StressUpdated&body=updated_body" '{}')
|
||||||
assert_step "update OK" echo "$updated" | grep -qiE '"updated|ok|success|StressUpdated'
|
assert_step "update OK" bash -c "grep -qiE 'updated|ok|success|StressUpdated|rows_affected' <<< '$updated'"
|
||||||
info " update: $updated"
|
info " update: $updated"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -569,13 +576,13 @@ test_notes_python() {
|
|||||||
# CRUD после модификаций
|
# CRUD после модификаций
|
||||||
next_step "[R2] CRUD: list после модификаций"
|
next_step "[R2] CRUD: list после модификаций"
|
||||||
listed=$(http_get "$notes_list_url")
|
listed=$(http_get "$notes_list_url")
|
||||||
assert_step "list still works" echo "$listed" | grep -qiE '"id"|\[\]'
|
assert_step "list still works" bash -c "grep -qiE '\"id\"|\[\]|\[' <<< '$listed'"
|
||||||
info " list: ${listed:0:200}"
|
info " list: ${listed:0:200}"
|
||||||
|
|
||||||
next_step "[R2] CRUD: add ещё запись"
|
next_step "[R2] CRUD: add ещё запись"
|
||||||
local add4
|
local add4
|
||||||
add4=$(http_post "${notes_url}/add?title=PostMod&body=after_modifications" '{}')
|
add4=$(http_post "${notes_url}/add?title=PostMod&body=after_modifications" '{}')
|
||||||
assert_step "add after mod OK" echo "$add4" | grep -qiE '"id"|"created'
|
assert_step "add after mod OK" bash -c "[[ '$add4' =~ \"id\"|created ]]"
|
||||||
|
|
||||||
restore_all_backups "$ex"
|
restore_all_backups "$ex"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user