@@ -39,33 +39,74 @@ print_info "Advanced Backend Integration Test Runner"
3939print_info " ========================================"
4040
4141# Load environment variables (CI or local)
42- if [ -f " .env" ] && [ -z " $DEEPGRAM_API_KEY " ]; then
42+ # Priority: CI environment > .env.test > .env
43+ if [ -n " $DEEPGRAM_API_KEY " ]; then
44+ print_info " Using environment variables from CI/environment..."
45+ elif [ -f " .env.test" ]; then
46+ print_info " Loading environment variables from .env.test..."
47+ set -a
48+ source .env.test
49+ set +a
50+ elif [ -f " .env" ]; then
4351 print_info " Loading environment variables from .env..."
4452 set -a
4553 source .env
4654 set +a
47- elif [ -n " $DEEPGRAM_API_KEY " ]; then
48- print_info " Using environment variables from CI..."
4955else
50- print_error " Neither .env file nor CI environment variables found !"
51- print_info " For local development: cp .env.template .env and configure API keys"
52- print_info " For CI: ensure DEEPGRAM_API_KEY and OPENAI_API_KEY secrets are set"
56+ print_error " Neither .env.test nor .env file found, and no environment variables set !"
57+ print_info " For local development: cp .env.template .env and configure required API keys"
58+ print_info " For CI: ensure required API keys are set based on configured providers "
5359 exit 1
5460fi
5561
56- # Verify required environment variables
57- if [ -z " $DEEPGRAM_API_KEY " ]; then
58- print_error " DEEPGRAM_API_KEY not set"
59- exit 1
60- fi
61-
62- if [ -z " $OPENAI_API_KEY " ]; then
63- print_error " OPENAI_API_KEY not set"
64- exit 1
65- fi
66-
67- print_info " DEEPGRAM_API_KEY length: ${# DEEPGRAM_API_KEY} "
68- print_info " OPENAI_API_KEY length: ${# OPENAI_API_KEY} "
62+ # Verify required environment variables based on configured providers
63+ TRANSCRIPTION_PROVIDER=${TRANSCRIPTION_PROVIDER:- deepgram}
64+ LLM_PROVIDER=${LLM_PROVIDER:- openai}
65+
66+ print_info " Configured providers:"
67+ print_info " TRANSCRIPTION_PROVIDER: $TRANSCRIPTION_PROVIDER "
68+ print_info " LLM_PROVIDER: $LLM_PROVIDER "
69+
70+ # Check transcription provider API key
71+ case " $TRANSCRIPTION_PROVIDER " in
72+ deepgram)
73+ if [ -z " $DEEPGRAM_API_KEY " ]; then
74+ print_error " DEEPGRAM_API_KEY not set (required for TRANSCRIPTION_PROVIDER=deepgram)"
75+ exit 1
76+ fi
77+ print_info " DEEPGRAM_API_KEY length: ${# DEEPGRAM_API_KEY} "
78+ ;;
79+ mistral)
80+ if [ -z " $MISTRAL_API_KEY " ]; then
81+ print_error " MISTRAL_API_KEY not set (required for TRANSCRIPTION_PROVIDER=mistral)"
82+ exit 1
83+ fi
84+ print_info " MISTRAL_API_KEY length: ${# MISTRAL_API_KEY} "
85+ ;;
86+ offline|parakeet)
87+ print_info " Using offline/local transcription - no API key required"
88+ ;;
89+ * )
90+ print_warning " Unknown TRANSCRIPTION_PROVIDER: $TRANSCRIPTION_PROVIDER "
91+ ;;
92+ esac
93+
94+ # Check LLM provider API key (for memory extraction)
95+ case " $LLM_PROVIDER " in
96+ openai)
97+ if [ -z " $OPENAI_API_KEY " ]; then
98+ print_error " OPENAI_API_KEY not set (required for LLM_PROVIDER=openai)"
99+ exit 1
100+ fi
101+ print_info " OPENAI_API_KEY length: ${# OPENAI_API_KEY} "
102+ ;;
103+ ollama)
104+ print_info " Using Ollama for LLM - no API key required"
105+ ;;
106+ * )
107+ print_warning " Unknown LLM_PROVIDER: $LLM_PROVIDER "
108+ ;;
109+ esac
69110
70111# Ensure memory_config.yaml exists
71112if [ ! -f " memory_config.yaml" ] && [ -f " memory_config.yaml.template" ]; then
@@ -119,9 +160,19 @@ export DOCKER_BUILDKIT=0
119160
120161# Run the integration test with extended timeout (mem0 needs time for comprehensive extraction)
121162print_info " Starting integration test (timeout: 15 minutes)..."
122- timeout 900 uv run pytest tests/test_integration.py::test_full_pipeline_integration -v -s --tb=short --log-cli-level=INFO
163+ if timeout 900 uv run pytest tests/test_integration.py::test_full_pipeline_integration -v -s --tb=short --log-cli-level=INFO; then
164+ print_success " Integration tests completed successfully!"
165+ else
166+ TEST_EXIT_CODE=$?
167+ print_error " Integration tests FAILED with exit code: $TEST_EXIT_CODE "
123168
124- print_success " Integration tests completed successfully!"
169+ # Clean up test containers before exiting
170+ print_info " Cleaning up test containers after failure..."
171+ docker compose -f docker-compose-test.yml down -v || true
172+ docker system prune -f || true
173+
174+ exit $TEST_EXIT_CODE
175+ fi
125176
126177# Clean up test containers
127178print_info " Cleaning up test containers..."
0 commit comments