Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Integration Tests

on:
pull_request:
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- 'tests/integration/**'
- '.github/workflows/integration-tests.yml'
workflow_dispatch:
inputs:
test_type:
description: 'Test type to run'
required: false
default: 'quick'
type: choice
options:
- 'quick'
- 'all'
- 'long'

permissions:
contents: read

jobs:
quick-tests:
name: Quick Integration Tests
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' || inputs.test_type == 'quick' || inputs.test_type == 'all'
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Build binaries
run: |
go build -o bin/litestream ./cmd/litestream
go build -o bin/litestream-test ./cmd/litestream-test

- name: Run quick integration tests
run: |
go test -v -tags=integration -timeout=30m ./tests/integration/... \
-run="TestFreshStart|TestDatabaseIntegrity|TestRapidCheckpoints"
env:
CGO_ENABLED: 1

- name: Upload test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: quick-test-logs
path: |
/tmp/litestream-*/*.log
/tmp/*-test.log

scenario-tests:
name: Scenario Integration Tests
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && (inputs.test_type == 'all' || inputs.test_type == 'long')
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Build binaries
run: |
go build -o bin/litestream ./cmd/litestream
go build -o bin/litestream-test ./cmd/litestream-test

- name: Run all scenario tests
run: |
go test -v -tags=integration -timeout=1h ./tests/integration/... \
-run="Test(FreshStart|DatabaseIntegrity|DatabaseDeletion|RapidCheckpoints|WALGrowth|ConcurrentOperations|BusyTimeout)"
env:
CGO_ENABLED: 1

- name: Upload test logs
if: always()
uses: actions/upload-artifact@v4
with:
name: scenario-test-logs
path: |
/tmp/litestream-*/*.log
/tmp/*-test.log

long-running-tests:
name: Long-Running Integration Tests
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' && inputs.test_type == 'long'
timeout-minutes: 600
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Build binaries
run: |
go build -o bin/litestream ./cmd/litestream
go build -o bin/litestream-test ./cmd/litestream-test

- name: Run long tests
run: |
go test -v -tags="integration,long" -timeout=10h ./tests/integration/... \
-run="TestOvernight|Test1GBBoundary"
env:
CGO_ENABLED: 1

- name: Upload test logs
if: always()
uses: actions/upload-artifact@v4
with:
name: long-test-logs
path: |
/tmp/litestream-*/*.log
/tmp/*-test.log

summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [quick-tests]
if: always() && (github.event_name == 'pull_request' || inputs.test_type == 'quick' || inputs.test_type == 'all')
steps:
- name: Generate summary
run: |
echo "## Integration Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

if [ "${{ needs.quick-tests.result }}" == "success" ]; then
echo "✅ **Quick Tests:** Passed" >> $GITHUB_STEP_SUMMARY
elif [ "${{ needs.quick-tests.result }}" == "failure" ]; then
echo "❌ **Quick Tests:** Failed" >> $GITHUB_STEP_SUMMARY
elif [ "${{ needs.quick-tests.result }}" == "skipped" ]; then
echo "⏭️ **Quick Tests:** Skipped" >> $GITHUB_STEP_SUMMARY
fi

echo "" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
echo "**Triggered by:** @${{ github.actor }}" >> $GITHUB_STEP_SUMMARY

# Note: Scenario and long-running tests run independently on workflow_dispatch.
# Check individual job results for those test suites.
153 changes: 2 additions & 151 deletions cmd/litestream-test/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,11 @@ go build -o bin/litestream-test ./cmd/litestream-test

## Quick Reference

> **Note:** Some tests have been migrated to Go integration tests in `tests/integration/`. See [tests/integration/README.md](../../tests/integration/README.md) for the Go-based test suite.

| Script | Purpose | Duration | Status |
|--------|---------|----------|--------|
| verify-test-setup.sh | Environment validation | ~5s | ✅ Stable |
| test-fresh-start.sh | Fresh database creation | ~30s | ✅ Stable |
| test-rapid-checkpoints.sh | Checkpoint stress test | ~2min | ✅ Stable |
| test-wal-growth.sh | Large WAL handling (100MB+) | ~5min | ✅ Stable |
| test-concurrent-operations.sh | Multi-database concurrent replication | ~5min | ✅ Stable |
| test-database-integrity.sh | Complex data integrity validation | ~3min | ✅ Stable |
| test-database-deletion.sh | Database deletion scenarios | ~2min | ✅ Stable |
| test-replica-failover.sh | Replica failover testing | ~3min | ✅ Stable |
| test-busy-timeout.sh | Database busy timeout handling | ~2min | ✅ Stable |
| test-1gb-boundary.sh | SQLite 1GB lock page boundary | ~10min | ⚠️ Blocked by #754 |
| reproduce-critical-bug.sh | Checkpoint during downtime bug | ~2min | 🐛 Reproduces #752 |
| test-754-s3-scenarios.sh | Issue #754 S3 vs file replication | ~10min | 🐛 Tests #754 |
| test-754-restore-focus.sh | Issue #754 restore focus | ~5min | 🐛 Tests #754 |
Expand Down Expand Up @@ -58,148 +51,6 @@ Verifies that the test environment is properly configured with required binaries
- SQLite3 available
- Python dependencies for S3 mock

### Core Functionality Tests

#### test-fresh-start.sh
Tests replication with a fresh database that doesn't exist when Litestream starts.

```bash
./cmd/litestream-test/scripts/test-fresh-start.sh
```

**Tests:**
- Starting Litestream before database exists
- Database creation while Litestream is running
- Automatic detection of new database
- Replication and restore integrity

#### test-database-integrity.sh
Creates complex data patterns and verifies integrity after restore.

```bash
./cmd/litestream-test/scripts/test-database-integrity.sh
```

**Tests:**
- Complex data patterns (multiple tables, indexes)
- SQLite PRAGMA integrity_check
- Full database restoration
- Data consistency verification

#### test-database-deletion.sh
Tests scenarios where the source database is deleted during replication.

```bash
./cmd/litestream-test/scripts/test-database-deletion.sh
```

**Tests:**
- Database deletion during active replication
- Recovery behavior
- Replica consistency

#### test-replica-failover.sh
Tests replica failover scenarios with multiple replicas.

```bash
./cmd/litestream-test/scripts/test-replica-failover.sh
```

**Tests:**
- Multiple replica configuration
- Failover when primary replica fails
- Data consistency across replicas

### Stress & Performance Tests

#### test-rapid-checkpoints.sh
Tests Litestream under rapid checkpoint pressure with continuous writes.

```bash
./cmd/litestream-test/scripts/test-rapid-checkpoints.sh
```

**Tests:**
- 100+ writes/second
- Forced rapid checkpoints
- Replication under checkpoint pressure
- Data integrity under stress

**Key Metrics:**
- Checkpoint frequency
- WAL file growth
- Replication lag
- Error rates

#### test-wal-growth.sh
Tests handling of large WAL files (100MB+) under sustained write load.

```bash
./cmd/litestream-test/scripts/test-wal-growth.sh
```

**Tests:**
- Sustained high write rates (400+ writes/sec)
- Large WAL file creation and handling
- Checkpoint behavior with large WALs
- Replication performance with large data

**Key Findings:**
- Successfully handles 100MB+ WAL files
- Maintains data integrity
- Handles 400+ writes/second

#### test-concurrent-operations.sh
Tests multiple databases replicating simultaneously with competing operations.

```bash
./cmd/litestream-test/scripts/test-concurrent-operations.sh
```

**Tests:**
- Multiple databases (3-5) replicating concurrently
- Mixed read/write operations
- Competing checkpoints
- Resource contention handling

#### test-busy-timeout.sh
Tests database busy timeout handling with concurrent access.

```bash
./cmd/litestream-test/scripts/test-busy-timeout.sh
```

**Tests:**
- Concurrent database access
- Busy timeout configuration
- Lock contention handling
- Recovery from busy states

### Boundary & Edge Case Tests

#### test-1gb-boundary.sh
Tests SQLite's 1GB lock page boundary handling.

```bash
./cmd/litestream-test/scripts/test-1gb-boundary.sh
```

**Tests:**
- Database growth beyond 1GB (with 4KB pages)
- Lock page at #262145 properly skipped
- Replication across lock page boundary
- Restoration integrity after crossing boundary

**Status:** ⚠️ Currently blocked by ltx v0.5.0 flag compatibility issue (#754)

**Lock Page Numbers by Page Size:**
| Page Size | Lock Page # |
|-----------|-------------|
| 4KB | 262145 |
| 8KB | 131073 |
| 16KB | 65537 |
| 32KB | 32769 |

### Bug Reproduction Scripts

#### reproduce-critical-bug.sh
Expand Down
Loading