fix(ci): use printf|ssh for smoke tests (heredoc breaks YAML block scalar)
This commit is contained in:
@@ -256,40 +256,25 @@ jobs:
|
|||||||
|
|
||||||
- name: Run smoke tests
|
- name: Run smoke tests
|
||||||
run: |
|
run: |
|
||||||
DOCKER="ssh nasts /volume1/@appstore/ContainerManager/usr/bin/docker"
|
|
||||||
echo "=== Running smoke tests via docker exec ==="
|
echo "=== Running smoke tests via docker exec ==="
|
||||||
|
DOCKER="ssh nasts /volume1/@appstore/ContainerManager/usr/bin/docker"
|
||||||
|
|
||||||
# Test 1: Health check
|
# Test 1: Health check
|
||||||
echo "1. Testing health endpoint..."
|
echo "1. Testing health endpoint..."
|
||||||
$DOCKER exec nas-dashboard-dev python3 -c "import urllib.request,json; d=json.loads(urllib.request.urlopen('http://localhost:4000/api/health',timeout=5).read()); assert d['status']=='ok', f'unexpected: {d}'" && echo "✅ Health check passed" || { echo "❌ Health check failed"; $DOCKER logs nas-dashboard-dev --tail 50; exit 1; }
|
printf 'import urllib.request, json\nd = json.loads(urllib.request.urlopen(\"http://localhost:4000/api/health\", timeout=5).read())\nassert d.get(\"status\") == \"ok\"\n' | $DOCKER exec -i nas-dashboard-dev python3 && echo "✅ Health check passed" || { echo "❌ Health check failed"; $DOCKER logs nas-dashboard-dev --tail 50; exit 1; }
|
||||||
|
|
||||||
# Test 2: Frontend loads
|
# Test 2: Frontend loads
|
||||||
echo "2. Testing frontend loads..."
|
echo "2. Testing frontend loads..."
|
||||||
$DOCKER exec nas-dashboard-dev python3 -c "import urllib.request; html=urllib.request.urlopen('http://localhost:4000/',timeout=5).read().decode(); assert 'NAS Dashboard' in html, f'missing NAS Dashboard'" && echo "✅ Frontend loads" || { echo "❌ Frontend failed to load"; exit 1; }
|
printf 'import urllib.request\nhtml = urllib.request.urlopen(\"http://localhost:4000/\", timeout=5).read().decode()\nassert \"NAS Dashboard\" in html\n' | $DOCKER exec -i nas-dashboard-dev python3 && echo "✅ Frontend loads" || { echo "❌ Frontend failed to load"; exit 1; }
|
||||||
|
|
||||||
# Test 3: API endpoints require auth
|
# Test 3: API endpoints require auth
|
||||||
echo "3. Testing API endpoints require auth..."
|
echo "3. Testing API endpoints require auth..."
|
||||||
$DOCKER exec nas-dashboard-dev python3 -c "
|
printf 'import urllib.request, json\ntry:\n resp = urllib.request.urlopen(\"http://localhost:4000/api/conversations/dates\", timeout=5)\n data = resp.read().decode()\n assert \"Not authenticated\" in data or \"detail\" in data\nexcept urllib.error.HTTPError as e:\n assert e.code in (401, 403)\n' | $DOCKER exec -i nas-dashboard-dev python3 && echo "✅ API requires auth" || { echo "❌ Auth check failed"; exit 1; }
|
||||||
import urllib.request, json
|
|
||||||
try:
|
|
||||||
resp = urllib.request.urlopen('http://localhost:4000/api/conversations/dates', timeout=5)
|
|
||||||
data = resp.read().decode()
|
|
||||||
assert 'Not authenticated' in data or 'detail' in data, f'unexpected: {data[:200]}'
|
|
||||||
except urllib.error.HTTPError as e:
|
|
||||||
assert e.code in (401, 403), f'expected 401/403, got {e.code}'
|
|
||||||
" && echo "✅ API requires auth" || { echo "❌ Auth check failed"; exit 1; }
|
|
||||||
|
|
||||||
# Test 4: Double /api/ prefix bug (non-failing)
|
# Test 4: Double /api/ prefix bug (non-failing)
|
||||||
echo "4. Testing for double /api/ prefix bug..."
|
echo "4. Testing for double /api/ prefix bug..."
|
||||||
$DOCKER exec nas-dashboard-dev python3 -c "
|
printf 'import urllib.request\ntry:\n urllib.request.urlopen(\"http://localhost:4000/api/api/conversations/dates\", timeout=5)\n print(\"WARNING: /api/api/ returned 200\")\nexcept urllib.error.HTTPError as e:\n assert e.code == 404\n print(\"OK: /api/api/ returned 404\")\n' | $DOCKER exec -i nas-dashboard-dev python3 && echo "No double /api/ prefix bug" || echo "Warning: Double API prefix"
|
||||||
import urllib.request
|
|
||||||
try:
|
|
||||||
urllib.request.urlopen('http://localhost:4000/api/api/conversations/dates', timeout=5)
|
|
||||||
print('WARNING: /api/api/ returned 200')
|
|
||||||
except urllib.error.HTTPError as e:
|
|
||||||
assert e.code == 404, f'expected 404, got {e.code}'
|
|
||||||
print('OK: /api/api/ returned 404')
|
|
||||||
" && echo "✅ No double /api/ prefix bug" || echo "⚠️ Double API prefix warning"
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== All smoke tests passed! ==="
|
echo "=== All smoke tests passed! ==="
|
||||||
|
echo "=== All smoke tests passed! ==="
|
||||||
|
|||||||
Reference in New Issue
Block a user