Passe Testumgebung für externes Backend auf 192.168.0.105 an
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
7f0991e517
commit
a082a81c87
@ -1,25 +1,7 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Backend for testing
|
# Frontend for testing - using external backend
|
||||||
backend:
|
|
||||||
build:
|
|
||||||
context: ../../backend
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: myp-backend-test
|
|
||||||
ports:
|
|
||||||
- "5000:5000"
|
|
||||||
environment:
|
|
||||||
- SECRET_KEY=testsecretkey123456789
|
|
||||||
- DATABASE_URL=sqlite:///myp.db
|
|
||||||
- FLASK_ENV=development
|
|
||||||
- TESTING=true
|
|
||||||
volumes:
|
|
||||||
- backend-test-data:/app/instance
|
|
||||||
networks:
|
|
||||||
- test-network
|
|
||||||
|
|
||||||
# Frontend for testing - bound to loopback address
|
|
||||||
frontend-test:
|
frontend-test:
|
||||||
build:
|
build:
|
||||||
context: ..
|
context: ..
|
||||||
@ -29,17 +11,7 @@ services:
|
|||||||
- NODE_ENV=development
|
- NODE_ENV=development
|
||||||
- AUTH_TRUST_HOST=true
|
- AUTH_TRUST_HOST=true
|
||||||
- AUTH_SECRET=test-secret-key-for-testing-only-do-not-use-in-production
|
- AUTH_SECRET=test-secret-key-for-testing-only-do-not-use-in-production
|
||||||
- NEXT_PUBLIC_BACKEND_URL=http://backend:5000
|
- NEXT_PUBLIC_BACKEND_URL=http://192.168.0.105:5000
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:3000:3000"
|
- "127.0.0.1:3000:3000"
|
||||||
depends_on:
|
network_mode: "host"
|
||||||
- backend
|
|
||||||
networks:
|
|
||||||
- test-network
|
|
||||||
|
|
||||||
networks:
|
|
||||||
test-network:
|
|
||||||
driver: bridge
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
backend-test-data:
|
|
@ -48,29 +48,28 @@ if [ $? -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Wait for backend to be ready
|
# Check if external backend is available
|
||||||
echo -e "${YELLOW}Waiting for backend to be ready...${NC}" | tee -a "$TEST_LOG"
|
echo -e "${YELLOW}Checking if external backend is available...${NC}" | tee -a "$TEST_LOG"
|
||||||
max_attempts=30
|
max_attempts=10
|
||||||
attempt=1
|
attempt=1
|
||||||
backend_ready=false
|
backend_ready=false
|
||||||
|
|
||||||
while [ $attempt -le $max_attempts ] && [ "$backend_ready" = "false" ]; do
|
while [ $attempt -le $max_attempts ] && [ "$backend_ready" = "false" ]; do
|
||||||
echo "Checking backend readiness (attempt $attempt/$max_attempts)..." | tee -a "$TEST_LOG"
|
echo "Checking backend readiness (attempt $attempt/$max_attempts)..." | tee -a "$TEST_LOG"
|
||||||
|
|
||||||
if curl -s http://localhost:5000/api/health &> /dev/null; then
|
if curl -s http://192.168.0.105:5000/api/health &> /dev/null; then
|
||||||
backend_ready=true
|
backend_ready=true
|
||||||
echo -e "${GREEN}Backend is ready!${NC}" | tee -a "$TEST_LOG"
|
echo -e "${GREEN}External backend is available!${NC}" | tee -a "$TEST_LOG"
|
||||||
else
|
else
|
||||||
echo "Backend not ready yet, waiting..." | tee -a "$TEST_LOG"
|
echo "External backend not available yet, waiting..." | tee -a "$TEST_LOG"
|
||||||
sleep 2
|
sleep 2
|
||||||
attempt=$((attempt+1))
|
attempt=$((attempt+1))
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$backend_ready" = "false" ]; then
|
if [ "$backend_ready" = "false" ]; then
|
||||||
echo -e "${RED}Backend failed to start properly after $max_attempts attempts${NC}" | tee -a "$TEST_LOG"
|
echo -e "${RED}External backend at 192.168.0.105:5000 is not available after $max_attempts attempts${NC}" | tee -a "$TEST_LOG"
|
||||||
echo "Logs from backend container:" | tee -a "$TEST_LOG"
|
echo -e "${RED}Please make sure the backend is running on the separate Raspberry Pi${NC}" | tee -a "$TEST_LOG"
|
||||||
run_docker_compose -f "$SCRIPT_DIR/test-env.yml" logs backend >> "$TEST_LOG" 2>&1
|
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
run_docker_compose -f "$SCRIPT_DIR/test-env.yml" down >> "$TEST_LOG" 2>&1
|
run_docker_compose -f "$SCRIPT_DIR/test-env.yml" down >> "$TEST_LOG" 2>&1
|
||||||
@ -120,7 +119,7 @@ if [ -z "$frontend_container_id" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Run a simple test inside the frontend container to check API connectivity
|
# Run a simple test inside the frontend container to check API connectivity
|
||||||
api_test_result=$(docker exec $frontend_container_id curl -s http://backend:5000/api/health)
|
api_test_result=$(docker exec $frontend_container_id curl -s http://192.168.0.105:5000/api/health)
|
||||||
if [[ "$api_test_result" == *"healthy"* ]]; then
|
if [[ "$api_test_result" == *"healthy"* ]]; then
|
||||||
echo -e "${GREEN}Test 1 PASSED: Frontend can connect to backend API${NC}" | tee -a "$TEST_LOG"
|
echo -e "${GREEN}Test 1 PASSED: Frontend can connect to backend API${NC}" | tee -a "$TEST_LOG"
|
||||||
else
|
else
|
||||||
@ -145,7 +144,7 @@ echo -e "${GREEN}Integration tests completed${NC}" | tee -a "$TEST_LOG"
|
|||||||
# Ask if the environment should be kept running or shutdown
|
# Ask if the environment should be kept running or shutdown
|
||||||
echo -e "${YELLOW}Test environment is running at:${NC}" | tee -a "$TEST_LOG"
|
echo -e "${YELLOW}Test environment is running at:${NC}" | tee -a "$TEST_LOG"
|
||||||
echo "Frontend: http://127.0.0.1:3000" | tee -a "$TEST_LOG"
|
echo "Frontend: http://127.0.0.1:3000" | tee -a "$TEST_LOG"
|
||||||
echo "Backend: http://localhost:5000" | tee -a "$TEST_LOG"
|
echo "Backend: http://192.168.0.105:5000 (external Raspberry Pi)" | tee -a "$TEST_LOG"
|
||||||
echo "" | tee -a "$TEST_LOG"
|
echo "" | tee -a "$TEST_LOG"
|
||||||
|
|
||||||
read -p "Do you want to keep the test environment running? (y/n): " keep_running
|
read -p "Do you want to keep the test environment running? (y/n): " keep_running
|
||||||
|
Loading…
x
Reference in New Issue
Block a user