From d841ffcbacdcd3a222ac1f428b6a3de8b7203b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Sat, 8 Aug 2026 22:25:48 +0400 Subject: [PATCH] =?UTF-8?q?tests:=20smoke.sh=20=E2=80=94=209=20=D1=82?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=BE=D0=B2=20=D0=B4=D0=BB=D1=8F=20=D1=80?= =?UTF-8?q?=D0=B5=D0=B5=D1=81=D1=82=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/smoke.sh | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 tests/smoke.sh diff --git a/tests/smoke.sh b/tests/smoke.sh new file mode 100755 index 0000000..27b99d1 --- /dev/null +++ b/tests/smoke.sh @@ -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