fix: apply Docker 24 network workaround and smoke tests to production deploy #64

Merged
jimmy merged 18 commits from dev into main 2026-05-17 23:34:02 +08:00
2 changed files with 39 additions and 8 deletions
Showing only changes of commit deb049c889 - Show all commits
+38 -7
View File
@@ -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! ==="
+1 -1
View File
@@ -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