Merge pull request #72 from ProxySQL/issue69-postgresql-docs #44
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: Functional Tests | |
| on: | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| jobs: | |
| functional: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.25.7' | |
| cache: true | |
| - name: Build orchestrator (for CLI tests on host) | |
| run: go build -o bin/orchestrator ./go/cmd/orchestrator | |
| - name: Start test infrastructure (MySQL + ProxySQL + Orchestrator) | |
| working-directory: tests/functional | |
| run: | | |
| docker compose up -d mysql1 mysql2 mysql3 proxysql | |
| echo "Waiting for MySQL and ProxySQL to be healthy..." | |
| timeout 120 bash -c ' | |
| while true; do | |
| HEALTHY=$(docker compose ps --format json 2>/dev/null | python3 -c " | |
| import json, sys | |
| healthy = 0 | |
| for line in sys.stdin: | |
| svc = json.loads(line) | |
| if \"healthy\" in svc.get(\"Status\",\"\").lower(): | |
| healthy += 1 | |
| print(healthy) | |
| " 2>/dev/null || echo "0") | |
| if [ "$HEALTHY" -ge 4 ]; then | |
| echo "All 4 services healthy" | |
| exit 0 | |
| fi | |
| sleep 2 | |
| done | |
| ' || { echo "Timeout"; docker compose ps; docker compose logs --tail=30; exit 1; } | |
| - name: Setup replication | |
| run: bash tests/functional/setup-replication.sh | |
| - name: Start orchestrator in Docker network | |
| working-directory: tests/functional | |
| run: | | |
| docker compose up -d orchestrator | |
| echo "Waiting for orchestrator to be ready..." | |
| timeout 120 bash -c ' | |
| while true; do | |
| if curl -sf http://localhost:3099/api/clusters > /dev/null 2>&1; then | |
| echo "Orchestrator ready" | |
| exit 0 | |
| fi | |
| sleep 2 | |
| done | |
| ' || { echo "Orchestrator not ready"; docker compose logs orchestrator --tail=50; exit 1; } | |
| - name: Run smoke tests | |
| run: bash tests/functional/test-smoke.sh | |
| - name: Run regression tests | |
| run: bash tests/functional/test-regression.sh | |
| - name: Run failover tests | |
| run: bash tests/functional/test-failover.sh | |
| # ---- PostgreSQL functional tests ---- | |
| - name: Start PostgreSQL containers | |
| working-directory: tests/functional | |
| run: | | |
| docker compose up -d pgprimary | |
| echo "Waiting for pgprimary to be healthy..." | |
| timeout 120 bash -c ' | |
| while true; do | |
| STATUS=$(docker compose ps pgprimary --format json 2>/dev/null | python3 -c " | |
| import json, sys | |
| for line in sys.stdin: | |
| svc = json.loads(line) | |
| if \"healthy\" in svc.get(\"Status\",\"\").lower(): | |
| print(\"healthy\") | |
| sys.exit(0) | |
| print(\"waiting\") | |
| " 2>/dev/null || echo "waiting") | |
| if [ "$STATUS" = "healthy" ]; then | |
| echo "pgprimary healthy" | |
| exit 0 | |
| fi | |
| sleep 2 | |
| done | |
| ' || { echo "Timeout waiting for pgprimary"; docker compose logs pgprimary --tail=30; exit 1; } | |
| docker compose up -d pgstandby1 | |
| echo "Waiting for pgstandby1 to be healthy..." | |
| timeout 120 bash -c ' | |
| while true; do | |
| STATUS=$(docker compose ps pgstandby1 --format json 2>/dev/null | python3 -c " | |
| import json, sys | |
| for line in sys.stdin: | |
| svc = json.loads(line) | |
| if \"healthy\" in svc.get(\"Status\",\"\").lower(): | |
| print(\"healthy\") | |
| sys.exit(0) | |
| print(\"waiting\") | |
| " 2>/dev/null || echo "waiting") | |
| if [ "$STATUS" = "healthy" ]; then | |
| echo "pgstandby1 healthy" | |
| exit 0 | |
| fi | |
| sleep 2 | |
| done | |
| ' || { echo "Timeout waiting for pgstandby1"; docker compose logs pgstandby1 --tail=30; exit 1; } | |
| - name: Start PostgreSQL orchestrator | |
| working-directory: tests/functional | |
| run: | | |
| docker compose up -d orchestrator-pg | |
| echo "Waiting for PostgreSQL orchestrator to be ready..." | |
| timeout 120 bash -c ' | |
| while true; do | |
| if curl -sf http://localhost:3098/api/clusters > /dev/null 2>&1; then | |
| echo "PostgreSQL orchestrator ready" | |
| exit 0 | |
| fi | |
| sleep 2 | |
| done | |
| ' || { echo "PostgreSQL orchestrator not ready"; docker compose logs orchestrator-pg --tail=50; exit 1; } | |
| - name: Run PostgreSQL tests | |
| run: bash tests/functional/test-postgresql.sh | |
| - name: Collect orchestrator logs | |
| if: always() | |
| working-directory: tests/functional | |
| run: | | |
| docker compose logs orchestrator > /tmp/orchestrator-test.log 2>&1 || true | |
| docker compose logs orchestrator-pg > /tmp/orchestrator-pg-test.log 2>&1 || true | |
| - name: Upload orchestrator logs | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: orchestrator-test-logs | |
| path: | | |
| /tmp/orchestrator-test.log | |
| /tmp/orchestrator-pg-test.log | |
| - name: Collect all docker logs on failure | |
| if: failure() | |
| working-directory: tests/functional | |
| run: docker compose logs > /tmp/docker-compose-logs.txt 2>&1 || true | |
| - name: Upload docker logs on failure | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: docker-compose-logs | |
| path: /tmp/docker-compose-logs.txt | |
| - name: Cleanup | |
| if: always() | |
| working-directory: tests/functional | |
| run: docker compose down -v --remove-orphans 2>/dev/null || true |