Comprehensive integration tests for Forge AI SDK integrations using testcontainers-go.
These tests verify that all integrations work correctly with real services running in Docker containers. Tests use testcontainers-go to automatically start, configure, and tear down service containers.
- Docker installed and running
- Go 1.21+
- Sufficient disk space for Docker images
go test -tags=integration ./...# Vector stores only
go test -tags=integration -run TestPgVector ./...
go test -tags=integration -run TestQdrant ./...
go test -tags=integration -run TestChroma ./...
# State stores only
go test -tags=integration -run TestPostgresStateStore ./...
go test -tags=integration -run TestRedisStateStore ./...
# Caches only
go test -tags=integration -run TestRedisCache ./...go test -tags=integration -v ./...go test -tags=integration -cover -coverprofile=coverage.out ./...
go tool cover -html=coverage.outTests verify:
- Upsert: Adding/updating vectors
- Query: Similarity search
- Query with Filter: Metadata filtering
- Delete: Removing vectors
Containers Used:
- PostgreSQL + pgvector (
ankane/pgvector:latest) - Qdrant (
qdrant/qdrant:latest) - ChromaDB (
chromadb/chroma:latest)
Tests verify:
- Save: Storing agent state
- Load: Retrieving agent state
- List: Listing sessions for an agent
- Delete: Removing agent state
Containers Used:
- PostgreSQL (
postgres:16-alpine) - Redis (
redis:7-alpine)
Tests verify:
- Set: Storing cache entries
- Get: Retrieving cache entries
- Delete: Removing cache entries
- Clear: Clearing all entries
- TTL: Time-to-live expiration
Containers Used:
- Redis (
redis:7-alpine)
The tests will automatically pull these images if not present:
docker pull ankane/pgvector:latest
docker pull qdrant/qdrant:latest
docker pull chromadb/chroma:latest
docker pull postgres:16-alpine
docker pull redis:7-alpine# Check Docker status
docker info
# Start Docker (macOS)
open -a Docker# Add user to docker group (Linux)
sudo usermod -aG docker $USER
newgrp dockerSome containers may take longer to start on slower machines:
// Increase timeout in tests
WaitingFor: wait.ForLog("...").WithStartupTimeout(120 * time.Second)Testcontainers automatically assigns random ports, but if you see port conflicts:
# Check for processes using ports
lsof -i :5432
lsof -i :6379
lsof -i :6334
lsof -i :8000
# Stop conflicting containers
docker ps
docker stop <container_id># List all containers
docker ps -a
# Remove stopped containers
docker container prune
# Remove unused images
docker image prunename: Integration Tests
on: [push, pull_request]
jobs:
integration:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Run Integration Tests
run: go test -tags=integration -v ./integrations/tests/integration/...integration_tests:
image: golang:1.21
services:
- docker:dind
variables:
DOCKER_HOST: tcp://docker:2375
script:
- go test -tags=integration -v ./integrations/tests/integration/...Typical Test Duration:
- Vector store tests: ~30-60 seconds each
- State store tests: ~20-40 seconds each
- Cache tests: ~15-30 seconds each
- Total suite: ~5-10 minutes
Resource Usage:
- Memory: ~2-4 GB
- Disk: ~500 MB - 1 GB (Docker images)
- CPU: 2-4 cores recommended
- Run Locally First: Verify tests pass locally before CI
- Clean Up: Containers are automatically cleaned up via
defer - Parallel Execution: Tests can run in parallel with
-parallelflag - Isolation: Each test uses unique table/collection names
- Timeouts: Generous timeouts prevent flaky tests
// +build integration
package integration
func TestMyIntegration(t *testing.T) {
ctx := context.Background()
// 1. Start container
req := testcontainers.ContainerRequest{
Image: "my-service:latest",
ExposedPorts: []string{"port/tcp"},
WaitingFor: wait.ForLog("ready"),
}
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: req,
Started: true,
})
if err != nil {
t.Fatal(err)
}
defer container.Terminate(ctx)
// 2. Get connection details
host, _ := container.Host(ctx)
port, _ := container.MappedPort(ctx, "port")
// 3. Create integration
// ... your integration setup ...
// 4. Run tests
TestMyOperations(t, myIntegration)
}When adding new integrations:
- Add integration test following the template
- Add helper functions to
helpers.goif needed - Update this README with new test details
- Verify tests pass in CI
MIT License - see LICENSE