Integration Testing Guide
Integration Testing Guide
Section titled “Integration Testing Guide”This guide explains how to run local integration tests against staging AWS resources.
Prerequisites
Section titled “Prerequisites”-
AWS Credentials: Ensure you have AWS credentials configured with access to staging resources
Terminal window aws sts get-caller-identity -
DynamoDB Table: The staging table should exist
- Table name:
stage-consumer-agent-history - Created via CLI or will be created by FSD on first deployment
- Table name:
-
Environment File:
.env.stagewith staging configuration (secrets retrieved from AWS Secrets Manager)
1. Create DynamoDB Table (if not exists)
Section titled “1. Create DynamoDB Table (if not exists)”# Check if table existsaws dynamodb describe-table --table-name stage-consumer-agent-history --region us-east-1
# Create if needed (already done)# aws dynamodb create-table ...2. Verify .env.stage Configuration
Section titled “2. Verify .env.stage Configuration”The .env.stage file should contain:
DYNAMODB_TABLE_NAME=stage-consumer-agent-historyAWS_REGION=us-east-1OPENAI_API_KEY(from AWS Secrets Manager)ROVER_MCP_AUTHORIZATION(from AWS Secrets Manager)- Other staging configuration
Note: .env.stage is in .gitignore and should NOT be committed.
Running Integration Tests
Section titled “Running Integration Tests”Option 1: Manual Testing
Section titled “Option 1: Manual Testing”Terminal 1 - Start the service:
./scripts/run_staging.shTerminal 2 - Run integration tests:
./scripts/test_staging_integration.pyOption 2: Health Check Only
Section titled “Option 2: Health Check Only”# Start service in background./scripts/run_staging.sh &
# Wait for startupsleep 5
# Test health endpointcurl http://localhost:8080/health
# Test streaming endpointcurl -X POST http://localhost:8080/agent/stream \ -H "Content-Type: application/json" \ -H "userId: test-user-001" \ -d '{"messages":[{"role":"user","content":"Hello!"}],"enabled_components":[]}'Integration Test Coverage
Section titled “Integration Test Coverage”The test_staging_integration.py script tests:
- Health Endpoint - Verifies service is running
- Streaming Agent - Tests
/agent/streamendpoint with a real OpenAI request - DynamoDB Storage - Verifies messages are stored in staging DynamoDB table
Verifying DynamoDB Storage
Section titled “Verifying DynamoDB Storage”Check messages in DynamoDB:
aws dynamodb query \ --table-name stage-consumer-agent-history \ --region us-east-1 \ --key-condition-expression "UserId = :user_id" \ --expression-attribute-values '{":user_id":{"S":"test-user-integration-001"}}'Or use the AWS Console:
- Service: DynamoDB
- Region: us-east-1
- Table:
stage-consumer-agent-history - Query by UserId
Cleanup
Section titled “Cleanup”Stop the service:
# Find the processlsof -ti:8080
# Kill itlsof -ti:8080 | xargs kill -9Or simply press Ctrl+C in the terminal running the service.
Troubleshooting
Section titled “Troubleshooting”Port Already in Use
Section titled “Port Already in Use”lsof -ti:8080 | xargs kill -9History Storage Not Configured
Section titled “History Storage Not Configured”Ensure .env.stage has:
DYNAMODB_TABLE_NAME=stage-consumer-agent-historyAWS Credentials Issues
Section titled “AWS Credentials Issues”# Check current identityaws sts get-caller-identity
# Set profile if neededexport AWS_PROFILE=stage-services-adminSecrets Not Found
Section titled “Secrets Not Found”Retrieve from AWS Secrets Manager:
# OpenAI API Keyaws secretsmanager get-secret-value \ --secret-id rover-agent-stage/openai-api-key \ --region us-east-1 \ --query SecretString \ --output text
# MCP Authorizationaws secretsmanager get-secret-value \ --secret-id rover-mcp/auth-tokens \ --region us-east-1 \ --query SecretString \ --output textNext Steps
Section titled “Next Steps”After successful integration tests:
- Commit your feature branch
- Create a pull request
- Deploy to staging via GitHub Actions workflow
- Test the deployed service in staging environment