Skip to content

Integration Testing Guide

This guide explains how to run local integration tests against staging AWS resources.

  1. AWS Credentials: Ensure you have AWS credentials configured with access to staging resources

    Terminal window
    aws sts get-caller-identity
  2. 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
  3. Environment File: .env.stage with staging configuration (secrets retrieved from AWS Secrets Manager)

Terminal window
# Check if table exists
aws dynamodb describe-table --table-name stage-consumer-agent-history --region us-east-1
# Create if needed (already done)
# aws dynamodb create-table ...

The .env.stage file should contain:

  • DYNAMODB_TABLE_NAME=stage-consumer-agent-history
  • AWS_REGION=us-east-1
  • OPENAI_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.

Terminal 1 - Start the service:

Terminal window
./scripts/run_staging.sh

Terminal 2 - Run integration tests:

Terminal window
./scripts/test_staging_integration.py
Terminal window
# Start service in background
./scripts/run_staging.sh &
# Wait for startup
sleep 5
# Test health endpoint
curl http://localhost:8080/health
# Test streaming endpoint
curl -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":[]}'

The test_staging_integration.py script tests:

  1. Health Endpoint - Verifies service is running
  2. Streaming Agent - Tests /agent/stream endpoint with a real OpenAI request
  3. DynamoDB Storage - Verifies messages are stored in staging DynamoDB table

Check messages in DynamoDB:

Terminal window
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

Stop the service:

Terminal window
# Find the process
lsof -ti:8080
# Kill it
lsof -ti:8080 | xargs kill -9

Or simply press Ctrl+C in the terminal running the service.

Terminal window
lsof -ti:8080 | xargs kill -9

Ensure .env.stage has:

DYNAMODB_TABLE_NAME=stage-consumer-agent-history
Terminal window
# Check current identity
aws sts get-caller-identity
# Set profile if needed
export AWS_PROFILE=stage-services-admin

Retrieve from AWS Secrets Manager:

Terminal window
# OpenAI API Key
aws secretsmanager get-secret-value \
--secret-id rover-agent-stage/openai-api-key \
--region us-east-1 \
--query SecretString \
--output text
# MCP Authorization
aws secretsmanager get-secret-value \
--secret-id rover-mcp/auth-tokens \
--region us-east-1 \
--query SecretString \
--output text

After successful integration tests:

  1. Commit your feature branch
  2. Create a pull request
  3. Deploy to staging via GitHub Actions workflow
  4. Test the deployed service in staging environment