fix: open dev port to all interfaces and run smoke tests via docker exec
- Change port binding from 127.0.0.1:4001:4000 to 4001:4000 so CI containers can reach the dashboard from any network namespace - Run smoke tests via docker exec against localhost:4000 instead of curling the external hostname, which resolves to the Caddy VPS and times out Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -294,10 +294,41 @@ jobs:
|
|||||||
|
|
||||||
- name: Run smoke tests
|
- name: Run smoke tests
|
||||||
run: |
|
run: |
|
||||||
bash scripts/smoke-test-dashboard.sh dev
|
echo "=== Running smoke tests via docker exec ==="
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "❌ Smoke tests failed! Check logs above."
|
# Test 1: Health check
|
||||||
docker logs nas-dashboard-dev --tail 100
|
echo "1. Testing health endpoint..."
|
||||||
exit 1
|
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; }
|
||||||
fi
|
|
||||||
echo "✅ Smoke tests passed"
|
# Test 2: 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; }
|
||||||
|
|
||||||
|
# Test 3: API endpoints require auth
|
||||||
|
echo "3. Testing API endpoints require auth..."
|
||||||
|
docker exec nas-dashboard-dev python3 -c "
|
||||||
|
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)
|
||||||
|
echo "4. Testing for double /api/ prefix bug..."
|
||||||
|
docker exec nas-dashboard-dev python3 -c "
|
||||||
|
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"
|
||||||
|
|
||||||
|
# Test 5: Container health already verified in previous step
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== All smoke tests passed! ==="
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ services:
|
|||||||
container_name: nas-dashboard-dev
|
container_name: nas-dashboard-dev
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:4001:4000"
|
- "4001:4000"
|
||||||
environment:
|
environment:
|
||||||
- DOCKER_HOST=tcp://docker-socket-proxy:2375
|
- DOCKER_HOST=tcp://docker-socket-proxy:2375
|
||||||
- GITEA_URL=http://gitea:3000
|
- GITEA_URL=http://gitea:3000
|
||||||
|
|||||||
Reference in New Issue
Block a user