Skip to content

Comprehensive Tests #228

Comprehensive Tests

Comprehensive Tests #228

name: Comprehensive Tests
on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch:
env:
GO_VERSION: '1.23.2'
jobs:
unit-tests:
name: Unit Tests (${{ matrix.component }})
runs-on: ubuntu-latest
strategy:
matrix:
component: [cache, cluster, config, filter, network, storage]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go mod download
- name: Test ${{ matrix.component }}
run: |
mkdir -p test-results
go test -v -race -coverprofile=test-results/${{ matrix.component }}.out \
-covermode=atomic -timeout=10m ./tests/unit/${{ matrix.component }}/...
- name: Coverage
run: go tool cover -func=test-results/${{ matrix.component }}.out | tail -1
- uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ matrix.component }}-coverage
path: test-results/
in-package-tests:
name: In-Package Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go mod download
- name: Run all internal tests
run: go test -race -timeout=5m ./internal/... ./pkg/...
integration-full:
name: Full Integration (Newman)
runs-on: ubuntu-latest
needs: [unit-tests, in-package-tests]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install -g newman
- name: Build and start cluster
run: |
mkdir -p bin logs
go build -o bin/hypercache ./cmd/hypercache
rm -rf /tmp/hypercache && mkdir -p /tmp/hypercache/node-{1,2,3}
./bin/hypercache -protocol resp -config configs/node1-config.yaml > logs/node-1.log 2>&1 &
sleep 3
./bin/hypercache -protocol resp -config configs/node2-config.yaml > logs/node-2.log 2>&1 &
sleep 3
./bin/hypercache -protocol resp -config configs/node3-config.yaml > logs/node-3.log 2>&1 &
sleep 5
for port in 9080 9081 9082; do
curl -sf http://localhost:$port/health > /dev/null || { cat logs/node-*.log; exit 1; }
done
- name: Run full Postman collection
run: |
newman run HyperCache.postman_collection.json \
--delay-request 2000 --timeout-request 10000 \
--reporters cli,json \
--reporter-json-export test-results/newman.json
- name: Cleanup
if: always()
run: pkill -f bin/hypercache 2>/dev/null || true
- uses: actions/upload-artifact@v4
if: always()
with:
name: integration-results
path: test-results/
benchmarks:
name: Benchmarks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go mod download
- name: Run benchmarks
run: |
mkdir -p benchmark-results
go test -bench=. -benchmem -run='^$' -timeout=10m \
./internal/... > benchmark-results/all.txt 2>&1 || true
cat benchmark-results/all.txt
- uses: actions/upload-artifact@v4
if: always()
with:
name: benchmark-results
path: benchmark-results/
scenario-tests:
name: Scenario Tests (Real-World Patterns)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
- run: go mod download
- name: Run deterministic scenarios
run: |
go test -v -race -timeout=5m -run 'Test(SessionStoreOverflow|ConcurrentReadWrite|TTLExpiry|PersistenceRecovery|StoreLifecycle|HotKeyThunderingHerd)' \
./tests/scenarios/...
- name: Run randomized scenarios
run: |
go test -v -race -timeout=5m -run 'TestRandomized' \
./tests/scenarios/...