Fix smoke test JSON parsing
This commit is contained in:
@@ -84,10 +84,7 @@ extract_json_line() {
|
||||
json_get() {
|
||||
local key="$1"
|
||||
if command -v python3 >/dev/null 2>&1; then
|
||||
python3 - "$key" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
|
||||
python3 -c 'import json,sys
|
||||
key=sys.argv[1]
|
||||
try:
|
||||
data=json.load(sys.stdin)
|
||||
@@ -99,7 +96,7 @@ if isinstance(val, bool):
|
||||
print("true" if val else "false")
|
||||
else:
|
||||
print(val)
|
||||
PY
|
||||
' "$key"
|
||||
elif command -v jq >/dev/null 2>&1; then
|
||||
jq -r --arg key "$key" '.[$key] // empty'
|
||||
else
|
||||
@@ -144,8 +141,7 @@ check_api() {
|
||||
return
|
||||
fi
|
||||
if command -v python3 >/dev/null 2>&1; then
|
||||
if printf "%s" "$body" | python3 - <<'PY'
|
||||
import json, sys
|
||||
if printf "%s" "$body" | python3 -c 'import json,sys
|
||||
try:
|
||||
data=json.load(sys.stdin)
|
||||
except Exception:
|
||||
@@ -154,7 +150,7 @@ for key in ("services", "hostname", "uptime_seconds"):
|
||||
if key in data:
|
||||
sys.exit(0)
|
||||
sys.exit(1)
|
||||
PY
|
||||
'
|
||||
then
|
||||
status OK "API responds with JSON"
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user