tests: smoke.sh — 9 тестов для реестра
This commit is contained in:
Executable
+87
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env bash
|
||||
# Smoke tests for Terraform Registry
|
||||
# Usage: bash tests/smoke.sh [DOMAIN]
|
||||
set -euo pipefail
|
||||
|
||||
DOMAIN="${1:-https://go-registry.containerk8s.dev.nubes.ru}"
|
||||
PASS=0
|
||||
FAIL=0
|
||||
|
||||
check() {
|
||||
local name="$1"
|
||||
if eval "$2" &>/dev/null; then
|
||||
echo "✅ $name"
|
||||
((PASS++))
|
||||
else
|
||||
echo "❌ $name"
|
||||
((FAIL++))
|
||||
fi
|
||||
}
|
||||
|
||||
echo "=== Registry Smoke Tests: $DOMAIN ==="
|
||||
echo
|
||||
|
||||
# 1. Root page
|
||||
check "GET /" \
|
||||
"curl -s --max-time 5 '$DOMAIN/' | grep -q ONLINE"
|
||||
|
||||
# 2. Healthz
|
||||
check "GET /healthz → ok" \
|
||||
"test 'ok' = \"\$(curl -s --max-time 5 '$DOMAIN/healthz')\""
|
||||
|
||||
# 3. Readyz
|
||||
check "GET /readyz → ok" \
|
||||
"test 'ok' = \"\$(curl -s --max-time 5 '$DOMAIN/readyz')\""
|
||||
|
||||
# 4. Discovery
|
||||
check "GET /.well-known/terraform.json" \
|
||||
"curl -s --max-time 5 '$DOMAIN/.well-known/terraform.json' | grep -q '/v1/providers/'"
|
||||
|
||||
# 5. Versions
|
||||
check "GET /v1/providers/nubes-test/nubes/versions" \
|
||||
"curl -s --max-time 10 '$DOMAIN/v1/providers/nubes-test/nubes/versions' | \
|
||||
python3 -c \"
|
||||
import sys,json
|
||||
d=json.load(sys.stdin)
|
||||
vs=[v['version'] for v in d['versions']]
|
||||
assert d['id']=='nubes-test/nubes'
|
||||
assert len(vs)>=1
|
||||
assert vs==sorted(vs), 'not sorted'
|
||||
for v in d['versions']:
|
||||
p=[x['os'] for x in v['platforms']]
|
||||
assert 'linux' in p and 'darwin' in p and 'windows' in p
|
||||
print('OK')
|
||||
\""
|
||||
|
||||
# 6. Download metadata
|
||||
check "GET /v1/providers/.../5.1.17/download/linux/amd64" \
|
||||
"curl -s --max-time 10 '$DOMAIN/v1/providers/nubes-test/nubes/5.1.17/download/linux/amd64' | \
|
||||
python3 -c \"
|
||||
import sys,json
|
||||
d=json.load(sys.stdin)
|
||||
assert d['os']=='linux' and d['arch']=='amd64'
|
||||
assert len(d['shasum'])==64
|
||||
assert 'download_url' in d
|
||||
keys=d['signing_keys']['gpg_public_keys']
|
||||
assert len(keys)==2
|
||||
assert keys[0]['key_id']=='3EC4673EB798238A'
|
||||
assert keys[1]['key_id']=='CB3A0DF161ECC416'
|
||||
print('OK')
|
||||
\""
|
||||
|
||||
# 7. Proxy download
|
||||
check "GET /v1/proxy — download zip" \
|
||||
"url=\$(curl -s --max-time 5 '$DOMAIN/v1/providers/nubes-test/nubes/5.1.17/download/linux/amd64' | python3 -c \"import sys,json; print(json.load(sys.stdin)['download_url'])\") && \
|
||||
test '200' = \"\$(curl -s --max-time 15 -o /dev/null -w '%{http_code}' \"\$url\")\""
|
||||
|
||||
# 8. 404 for unknown provider
|
||||
check "GET unknown → 404" \
|
||||
"test '404' = \"\$(curl -s --max-time 5 -o /dev/null -w '%{http_code}' '$DOMAIN/v1/providers/nosuch/noversion/versions')\""
|
||||
|
||||
# 9. Missing key param → 400
|
||||
check "GET /v1/proxy без key → 400" \
|
||||
"test '400' = \"\$(curl -s --max-time 5 -o /dev/null -w '%{http_code}' '$DOMAIN/v1/proxy')\""
|
||||
|
||||
echo
|
||||
echo "=== $PASS PASS, $FAIL FAIL ==="
|
||||
exit $FAIL
|
||||
Reference in New Issue
Block a user