This document outlines a comprehensive strategy for extending lightstack's test coverage beyond contract tests to include end-to-end (E2E) testing and continuous integration (CI) pipeline automation. Current status: 82% contract test coverage (157/191 passing), ready for E2E scenarios and CI integration.
| Test Type | Coverage | Tool/Framework | Status |
|---|---|---|---|
| Contract Tests | 157/191 (82%) | gophercloud SDK | ✅ Operational |
| Integration Tests | 20+ scripts | Bash + OpenStack CLI | ✅ Operational |
| Unit Tests | Per-file | Go testing stdlib | ✅ Operational |
| E2E Tests | 0 | None | ⏳ Needs Implementation |
| CI Pipeline | 0 | None | ⏳ Needs Implementation |
Contract Tests validate API contracts but don't cover:
- Multi-service workflows (e.g., VM with volume + network)
- Real-world user scenarios (Terraform apply, Horizon workflows)
- Performance under load
- Upgrade/migration paths
- Multi-node deployments
Integration Tests exist but are:
- Manual execution only (no automation)
- No CI/CD integration
- No failure reporting/tracking
- Limited to basic workflows
- Validate real-world workflows - Test scenarios users actually perform
- Multi-service integration - Verify cross-service interactions
- Client compatibility - Validate Terraform, Horizon, CLI simultaneously
- Performance baselines - Establish acceptable response times
- Regression detection - Catch breaking changes before release
| Scenario | Services | Validation |
|---|---|---|
| VM Full Lifecycle | Nova + Neutron + Cinder + Glance | Create VM with volume + network → verify connectivity → snapshot → delete |
| Terraform Stack Deploy | All services | Apply Terraform with openstack_* resources → verify state → destroy |
| Horizon Dashboard Workflow | Keystone + Nova | Login → create server → attach volume → assign floating IP → delete |
| Volume Attach/Detach | Nova + Cinder | Create VM → attach volume → write data → detach → attach to new VM → verify data |
| Network Isolation | Neutron + Nova | Create 2 networks → launch VMs on each → verify isolation → add router → verify connectivity |
| Scenario | Services | Validation |
|---|---|---|
| Multi-Tenant Isolation | Keystone + all | Create 2 projects → deploy resources → verify isolation |
| Security Groups | Neutron + Nova | Create VM → apply security group → verify blocked/allowed traffic |
| Floating IP Assignment | Neutron + Nova | Create VM on private network → assign floating IP → verify external access |
| Snapshot and Restore | Nova + Glance + Cinder | Create VM → take snapshot → restore to new VM → verify identical |
| Image Upload via Horizon | Glance + Horizon | Upload image through UI → verify metadata → launch VM from image |
| Scenario | Services | Validation |
|---|---|---|
| High Availability | All | Kill Lightstack process → restart → verify state consistency |
| Database Migration | Database + all | Apply new migration → verify no data loss → rollback → verify |
| Multi-Node VXLAN | Neutron + Nova + Compute nodes | Deploy VMs on 2 nodes → verify cross-node connectivity |
| Performance Under Load | All | 100 concurrent API requests → measure response times → verify no degradation |
Approach: Enhance existing test/ scripts with E2E scenarios.
Pros:
- Builds on existing infrastructure
- Uses OpenStack CLI (real client validation)
- Easy to read and maintain
- Fast iteration
Cons:
- Limited parallelization
- No structured reporting
- Bash limitations for complex logic
Implementation:
test/
├── e2e/
│ ├── vm_full_lifecycle.sh # VM + volume + network
│ ├── terraform_stack_deploy.sh # Terraform apply/destroy
│ ├── horizon_workflow.sh # Selenium-based UI test
│ ├── volume_attach_detach.sh # Volume operations
│ └── network_isolation.sh # Multi-network test
└── lib/
├── common.sh # Shared functions
├── wait.sh # Wait-for-condition helpers
└── report.sh # JSON test reportingApproach: Create test/e2e/ with Go test framework using gophercloud.
Pros:
- Type-safe, structured tests
- Better error handling
- Parallel execution
- Integrated with Go tooling
Cons:
- More setup overhead
- Duplicates bash test patterns
- Requires gophercloud knowledge
Implementation:
test/e2e/
├── framework/
│ ├── setup.go # Test environment setup
│ ├── clients.go # gophercloud client init
│ └── wait.go # Wait conditions
├── scenarios/
│ ├── vm_lifecycle_test.go
│ ├── terraform_test.go
│ └── network_isolation_test.go
└── suite_test.go # Test suite runner
Approach: Bash for simple workflows, Go for complex scenarios.
Pros:
- Flexibility to choose right tool
- Gradual migration path
- Reuse existing bash scripts
Cons:
- Two test systems to maintain
- Need coordination between both
Development:
# Run all E2E tests
make test-e2e
# Run specific scenario
./test/e2e/vm_full_lifecycle.sh
# Run with verbose output
E2E_VERBOSE=1 make test-e2eCI Pipeline:
# Fast E2E suite (< 5 minutes)
make test-e2e-fast
# Full E2E suite (< 15 minutes)
make test-e2e-fullPros:
- Native GitHub integration
- Free for open source
- Extensive action marketplace
- Matrix builds for multi-version testing
- Good Docker support
Cons:
- Limited to 6-hour jobs
- Public repos only for free tier
Configuration: .github/workflows/
Pros:
- Powerful pipeline features
- Better Docker support
- Unlimited pipeline minutes (self-hosted)
- Built-in container registry
Cons:
- Requires GitLab hosting or self-hosted runner
- More complex configuration
Configuration: .gitlab-ci.yml
graph LR
A[Commit] --> B[Build]
B --> C[Unit Tests]
B --> D[Contract Tests]
B --> E[Integration Tests]
C --> F[E2E Tests - Fast]
D --> F
E --> F
F --> G[E2E Tests - Full]
G --> H[Deploy Staging]
H --> I[Release]
Stage 1: Build (< 2 minutes)
- Go build
- Docker image build
- Binary size check
- Linting (golangci-lint)
Stage 2: Unit Tests (< 1 minute)
go test ./...- Coverage report
- Race detector
Stage 3: Contract Tests (< 5 minutes)
- Spin up Lightstack + PostgreSQL
- Run 191 contract tests
- Report pass/fail by service
Stage 4: Integration Tests (< 3 minutes)
- Run
test/quick_test.sh - Basic workflow validation
- OpenStack CLI compatibility
Stage 5: E2E Tests - Fast (< 5 minutes)
- Priority 1 scenarios only
- VM lifecycle
- Volume attach/detach
- Network isolation
Stage 6: E2E Tests - Full (< 15 minutes)
- All Priority 1 + Priority 2 scenarios
- Terraform stack deploy
- Horizon workflow (headless browser)
- Multi-tenant isolation
Stage 7: Deploy Staging (manual trigger)
- Deploy to staging environment
- Run smoke tests
- Performance benchmarks
Stage 8: Release (manual trigger)
- Tag release
- Build release artifacts
- Publish Docker images
- Update documentation
.github/
└── workflows/
├── ci.yml # Main CI pipeline (all PRs)
├── nightly.yml # Nightly full test suite
├── release.yml # Release automation
└── dependency-update.yml # Dependabot integration
name: CI Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.26'
- name: Build
run: make build
- name: Lint
run: make lint
- name: Check binary size
run: |
SIZE=$(stat -f%z bin/lightstack)
if [ $SIZE -gt 40000000 ]; then
echo "Binary too large: ${SIZE} bytes (max 40MB)"
exit 1
fi
unit-tests:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.26'
- name: Run unit tests
run: go test -race -coverprofile=coverage.txt ./...
- name: Upload coverage
uses: codecov/codecov-action@v3
contract-tests:
runs-on: ubuntu-latest
needs: build
services:
postgres:
image: postgres:18-alpine
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.26'
- name: Start lightstack
run: |
docker compose up -d
sleep 10
- name: Run contract tests
run: |
docker compose -f deployments/docker-compose.test.yml run --rm test-runner
- name: Report results
run: |
echo "Contract Tests: $(grep -c PASS test-results.txt)/191"
integration-tests:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Start lightstack
run: docker compose up -d
- name: Run integration tests
run: ./test/quick_test.sh
- name: Check logs
if: failure()
run: docker compose logs
e2e-fast:
runs-on: ubuntu-latest
needs: [unit-tests, contract-tests, integration-tests]
steps:
- uses: actions/checkout@v4
- name: Start lightstack
run: docker compose up -d
- name: Run fast E2E tests
run: make test-e2e-fast
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: e2e-results
path: test-results/
e2e-full:
runs-on: ubuntu-latest
needs: e2e-fast
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Start lightstack
run: docker compose up -d
- name: Run full E2E tests
run: make test-e2e-full
- name: Performance benchmarks
run: ./test/benchmark.shname: Nightly Full Test Suite
on:
schedule:
- cron: '0 2 * * *' # 2 AM UTC daily
workflow_dispatch: # Manual trigger
jobs:
full-suite:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run all tests
run: |
make test-all
make test-e2e-full
make benchmark
- name: Generate report
run: ./scripts/generate-test-report.sh
- name: Upload report
uses: actions/upload-artifact@v3
with:
name: nightly-report
path: reports/Convert bash test results to JUnit XML for GitHub Actions visualization:
#!/bin/bash
# test/lib/report.sh
function test_start() {
TEST_NAME="$1"
TEST_START_TIME=$(date +%s)
}
function test_pass() {
TEST_END_TIME=$(date +%s)
TEST_DURATION=$((TEST_END_TIME - TEST_START_TIME))
echo "<testcase name=\"$TEST_NAME\" time=\"$TEST_DURATION\"/>" >> results.xml
}
function test_fail() {
TEST_END_TIME=$(date +%s)
TEST_DURATION=$((TEST_END_TIME - TEST_START_TIME))
ERROR_MSG="$1"
cat >> results.xml <<EOF
<testcase name="$TEST_NAME" time="$TEST_DURATION">
<failure message="$ERROR_MSG"/>
</testcase>
EOF
}Use GitHub Actions annotations to show test results in PR comments:
- name: Comment PR with results
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
const results = fs.readFileSync('test-results.json');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## Test Results\n\n${results}`
});Goal: Get basic CI working on GitHub Actions.
Tasks:
- Create
.github/workflows/ci.yml - Add build + lint jobs
- Add unit test job with coverage
- Add contract test job (reuse Docker setup)
- Add integration test job (
quick_test.sh) - Configure status checks for PRs
Deliverables:
- ✅ CI badge in README.md
- ✅ Test results in PR checks
- ✅ Coverage reporting
Goal: Implement Priority 1 E2E scenarios.
Tasks:
- Create
test/e2e/directory structure - Implement
vm_full_lifecycle.sh - Implement
volume_attach_detach.sh - Implement
network_isolation.sh - Add
make test-e2e-fasttarget - Integrate into CI pipeline
Deliverables:
- ✅ 3 Priority 1 scenarios working
- ✅ E2E job in CI pipeline
- ✅ Test results reporting
Goal: Add Terraform and Horizon validation.
Tasks:
- Create Terraform test suite (
terraform_stack_deploy.sh) - Set up Selenium for Horizon testing
- Implement
horizon_workflow.sh - Add multi-tenant isolation test
- Add security group test
- Create
make test-e2e-fulltarget
Deliverables:
- ✅ 5 Priority 2 scenarios working
- ✅ Terraform compatibility validated
- ✅ Horizon UI validated
Goal: Comprehensive nightly validation.
Tasks:
- Create
.github/workflows/nightly.yml - Implement performance benchmarks
- Add load testing (
100 concurrent requests) - Create test result dashboard
- Set up notifications for failures
- Document testing strategy
Deliverables:
- ✅ Nightly pipeline running
- ✅ Performance baselines established
- ✅ Testing documentation complete
| Test Type | Current | Target (3 months) | Target (6 months) |
|---|---|---|---|
| Contract Tests | 82% (157/191) | 90% (172/191) | 95% (181/191) |
| E2E Scenarios | 0 | 8 scenarios | 15 scenarios |
| CI Integration | 0% | 100% | 100% |
| Automation Rate | 0% | 80% | 95% |
- ✅ All PRs require passing tests
- ✅ No merges with failing tests
- ✅ < 5 minute fast E2E suite
- ✅ < 15 minute full E2E suite
- ✅ Nightly runs catch regressions within 24 hours
- ✅ Performance benchmarks tracked over time
- ✅ CI pipeline success rate > 95%
- ✅ Flaky test rate < 2%
- ✅ Test execution time stable (±10%)
- ✅ Zero false positives in release gates
GitHub Actions (free tier sufficient):
- Concurrent job limit: 20
- Storage: 500MB artifacts
- Minutes: Unlimited for public repos
Self-Hosted Runners (optional, for performance tests):
- 1 VM: 4 CPU, 8GB RAM, 50GB disk
- Cost: ~$40/month (DigitalOcean/Hetzner)
Required:
- GitHub Actions (free)
- Docker Compose (already used)
- PostgreSQL (already used)
Optional:
- Selenium Grid (for Horizon testing)
- Terraform (for stack validation)
- Load testing tool (k6, vegeta, or wrk)
| Risk | Impact | Mitigation |
|---|---|---|
| CI costs exceed budget | High | Use free tier, optimize test runtime |
| Flaky tests block releases | High | Implement retry logic, quarantine flaky tests |
| E2E tests too slow | Medium | Parallel execution, fast/full split |
| Terraform tests unstable | Medium | Use fixed Terraform version, lock provider |
| Selenium tests brittle | Medium | Use stable selectors, add wait conditions |
Plan A (Recommended): GitHub Actions + bash E2E tests
- Fast setup
- Low maintenance
- Reuses existing patterns
Plan B (Fallback): Self-hosted GitLab CI
- If GitHub Actions limits hit
- Better control over resources
- Can run longer jobs
Plan C (Minimal): Manual E2E + contract tests only in CI
- If E2E automation proves too complex
- Still validates core functionality
- Reduces CI complexity
- ✅ Create GitHub Actions CI pipeline (
.github/workflows/ci.yml) - ✅ Add contract tests to CI
- ✅ Add integration tests to CI
- ✅ Configure PR status checks
- ✅ Implement 3 Priority 1 E2E scenarios
- ✅ Add E2E job to CI pipeline
- ✅ Create test result reporting
- ✅ Add Terraform validation
- ✅ Add Horizon UI testing
- ✅ Set up nightly full test suite
- ✅ Establish performance baselines
Document Created: March 25, 2026 Author: Lightstack Development Team Status: Proposal - Ready for Implementation Review Date: After Phase 1 completion