#!/bin/bash # Integration test script for pension-quant-platform set -e echo "=========================================" echo "Pension Quant Platform Integration Tests" echo "=========================================" cd "$(dirname "$0")/.." # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Function to print colored output print_status() { if [ $1 -eq 0 ]; then echo -e "${GREEN}✓ $2${NC}" else echo -e "${RED}✗ $2${NC}" exit 1 fi } # 1. Check Docker services echo "" echo "Step 1: Checking Docker services..." docker-compose ps print_status $? "Docker services checked" # 2. Wait for PostgreSQL echo "" echo "Step 2: Waiting for PostgreSQL..." sleep 5 docker-compose exec -T postgres pg_isready -U postgres print_status $? "PostgreSQL is ready" # 3. Run database migrations echo "" echo "Step 3: Running database migrations..." docker-compose exec -T backend alembic upgrade head print_status $? "Database migrations completed" # 4. Run unit tests echo "" echo "Step 4: Running unit tests..." docker-compose exec -T backend pytest tests/ -m "unit" -v print_status $? "Unit tests passed" # 5. Run integration tests echo "" echo "Step 5: Running integration tests..." docker-compose exec -T backend pytest tests/ -m "integration and not slow" -v print_status $? "Integration tests passed" # 6. Check API health echo "" echo "Step 6: Checking API health..." curl -f http://localhost:8000/health || exit 1 print_status $? "API health check passed" # 7. Test strategy list endpoint echo "" echo "Step 7: Testing strategy list endpoint..." curl -f http://localhost:8000/api/v1/backtest/strategies/list || exit 1 print_status $? "Strategy list endpoint working" # 8. Check Celery worker echo "" echo "Step 8: Checking Celery worker..." docker-compose exec -T celery_worker celery -A app.celery_app inspect ping print_status $? "Celery worker is running" # 9. Check Flower monitoring echo "" echo "Step 9: Checking Flower monitoring..." curl -f http://localhost:5555/ > /dev/null 2>&1 print_status $? "Flower monitoring is accessible" # 10. Check frontend build echo "" echo "Step 10: Checking frontend..." curl -f http://localhost:3000/ > /dev/null 2>&1 print_status $? "Frontend is accessible" echo "" echo "=========================================" echo -e "${GREEN}All tests passed successfully!${NC}" echo "=========================================" echo "" echo "Next steps:" echo "1. Run full backtest: curl -X POST http://localhost:8000/api/v1/backtest/run -H 'Content-Type: application/json' -d @samples/backtest_config.json" echo "2. Trigger data collection: curl -X POST http://localhost:8000/api/v1/data/collect/all" echo "3. View Flower: http://localhost:5555" echo "4. View frontend: http://localhost:3000" echo ""