Made the smoke test resilient to the restart timing issues and confir… #66
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: [push, pull_request] | |
| permissions: | |
| contents: read | |
| packages: write | |
| jobs: | |
| build-test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| go-version: ['1.23'] | |
| platform: [amd64, arm64] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ matrix.go-version }} | |
| - uses: docker/setup-buildx-action@v3 | |
| id: buildx | |
| - run: make build-ebpf | |
| - run: make build | |
| - run: go test -tags integration -v -timeout 30m ./... | |
| - name: Demo smoke test | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| cd demo/postgres-survive-kill9 | |
| docker compose up -d | |
| echo "Waiting for Postgres to be ready..." | |
| for i in {1..30}; do | |
| if docker compose exec -T postgres pg_isready -U postgres >/dev/null 2>&1; then | |
| ready=1 | |
| break | |
| fi | |
| sleep 2 | |
| done | |
| if [ "${ready:-0}" != "1" ]; then | |
| echo "Postgres did not become ready in time" >&2 | |
| exit 1 | |
| fi | |
| baseline=$(docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null || echo "0") | |
| echo "Baseline transactions: ${baseline}" | |
| docker kill -s KILL "$(docker compose ps -q postgres)" | |
| echo "Waiting for Postgres to restart..." | |
| unset ready | |
| for i in {1..30}; do | |
| sleep 2 | |
| if docker compose exec -T postgres pg_isready -U postgres >/dev/null 2>&1; then | |
| ready=1 | |
| break | |
| fi | |
| done | |
| if [ "${ready:-0}" != "1" ]; then | |
| echo "Postgres did not restart" >&2 | |
| exit 1 | |
| fi | |
| after=$(docker compose exec -T postgres psql -U postgres -d bench -t -A -c "SELECT count(*) FROM pgbench_history;" 2>/dev/null || echo "0") | |
| echo "Post-restart transactions: ${after}" | |
| if [ "${after}" -lt "${baseline}" ]; then | |
| echo "Transaction count decreased after kill -9" >&2 | |
| exit 1 | |
| fi | |
| curl -sf http://localhost:9911/metrics | grep diffkeeper_recovery_total | |
| docker compose down -v |