Skip to content

Commit

Permalink
Merge pull request #2195 from josephschorr/pg-test-matrix
Browse files Browse the repository at this point in the history
Switch postgres tests to run in a matrix of versions
  • Loading branch information
josephschorr authored Jan 10, 2025
2 parents 6b2e961 + 9401072 commit fabeff1
Show file tree
Hide file tree
Showing 10 changed files with 445 additions and 309 deletions.
82 changes: 79 additions & 3 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ jobs:
- name: "Integration tests"
run: "go run mage.go test:integration"

datastore:
name: "Datastore Tests"
datastoreinttest:
name: "Datastore Integration Tests"
runs-on: "buildjet-8vcpu-ubuntu-2204"
needs: "paths-filter"
strategy:
fail-fast: false
matrix:
datastore: ["crdb", "mysql", "postgres", "spanner", "pgbouncer"]
datastore: ["crdb", "mysql", "spanner"]
steps:
- uses: "actions/checkout@v4"
if: |
Expand All @@ -125,11 +125,87 @@ jobs:
if: |
needs.paths-filter.outputs.codechange == 'true'
run: "go run mage.go testds:${{ matrix.datastore }}"

datastoreconstest:
name: "Datastore Consistency Tests"
runs-on: "buildjet-4vcpu-ubuntu-2204"
needs: "paths-filter"
strategy:
fail-fast: false
matrix:
datastore: ["crdb", "mysql", "spanner"]
steps:
- uses: "actions/checkout@v4"
if: |
needs.paths-filter.outputs.codechange == 'true'
- uses: "authzed/actions/setup-go@main"
if: |
needs.paths-filter.outputs.codechange == 'true'
- uses: "docker/login-action@v3"
if: |
needs.paths-filter.outputs.codechange == 'true'
with:
username: "${{ env.DOCKERHUB_PUBLIC_USER }}"
password: "${{ env.DOCKERHUB_PUBLIC_ACCESS_TOKEN }}"
- name: "Consistency tests"
if: |
needs.paths-filter.outputs.codechange == 'true'
run: "go run mage.go testcons:${{ matrix.datastore }}"

pgdatastoreinttest:
name: "Datastore Integration Tests"
runs-on: "buildjet-4vcpu-ubuntu-2204"
needs: "paths-filter"
strategy:
fail-fast: false
matrix:
datastore: ["postgres", "pgbouncer"]
pgversion: ["13.8", "14", "15", "16", "17"]
steps:
- uses: "actions/checkout@v4"
if: |
needs.paths-filter.outputs.codechange == 'true'
- uses: "authzed/actions/setup-go@main"
if: |
needs.paths-filter.outputs.codechange == 'true'
- uses: "docker/login-action@v3"
if: |
needs.paths-filter.outputs.codechange == 'true'
with:
username: "${{ env.DOCKERHUB_PUBLIC_USER }}"
password: "${{ env.DOCKERHUB_PUBLIC_ACCESS_TOKEN }}"
- name: "Integration tests"
if: |
needs.paths-filter.outputs.codechange == 'true'
run: "go run mage.go testds:${{ matrix.datastore }}ver ${{ matrix.pgversion }}"

pgdatastoreconstest:
name: "Datastore Consistency Tests"
runs-on: "buildjet-4vcpu-ubuntu-2204"
needs: "paths-filter"
strategy:
fail-fast: false
matrix:
datastore: ["postgres"]
pgversion: ["13.8", "14", "15", "16", "17"]
steps:
- uses: "actions/checkout@v4"
if: |
needs.paths-filter.outputs.codechange == 'true'
- uses: "authzed/actions/setup-go@main"
if: |
needs.paths-filter.outputs.codechange == 'true'
- uses: "docker/login-action@v3"
if: |
needs.paths-filter.outputs.codechange == 'true'
with:
username: "${{ env.DOCKERHUB_PUBLIC_USER }}"
password: "${{ env.DOCKERHUB_PUBLIC_ACCESS_TOKEN }}"
- name: "Consistency tests"
if: |
needs.paths-filter.outputs.codechange == 'true'
run: "go run mage.go testcons:postgresver ${{ matrix.pgversion }}"

e2e:
name: "E2E"
runs-on: "buildjet-8vcpu-ubuntu-2204"
Expand Down
25 changes: 14 additions & 11 deletions internal/datastore/postgres/pgbouncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@
package postgres

import (
"os"
"testing"

pgversion "github.com/authzed/spicedb/internal/datastore/postgres/version"

"github.com/samber/lo"
"github.com/authzed/spicedb/internal/datastore/postgres/version"
)

var pgbouncerConfigs = lo.Map(
[]string{pgversion.MinimumSupportedPostgresVersion, "14", "15", "16"},
func(postgresVersion string, _ int) postgresConfig {
return postgresConfig{"head", "", postgresVersion, true}
},
)
func pgbouncerTestVersion() string {
ver := os.Getenv("POSTGRES_TEST_VERSION")
if ver != "" {
return ver
}

return version.LatestTestedPostgresVersion
}

var pgbouncerConfig = postgresTestConfig{"head", "", pgbouncerTestVersion(), true}

func TestPostgresWithPgBouncerDatastore(t *testing.T) {
testPostgresDatastore(t, pgbouncerConfigs)
testPostgresDatastore(t, pgbouncerConfig)
}

func TestPostgresDatastoreWithPgBouncerWithoutCommitTimestamps(t *testing.T) {
testPostgresDatastoreWithoutCommitTimestamps(t, pgbouncerConfigs)
testPostgresDatastoreWithoutCommitTimestamps(t, pgbouncerConfig)
}
Loading

0 comments on commit fabeff1

Please sign in to comment.