Skip to content

Commit

Permalink
Switch postgres tests to run in a matrix of versions
Browse files Browse the repository at this point in the history
  • Loading branch information
josephschorr committed Jan 8, 2025
1 parent c18b165 commit 2d9d84a
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 296 deletions.
33 changes: 32 additions & 1 deletion .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
strategy:
fail-fast: false
matrix:
datastore: ["crdb", "mysql", "postgres", "spanner", "pgbouncer"]
datastore: ["crdb", "mysql", "spanner"]
steps:
- uses: "actions/checkout@v4"
if: |
Expand All @@ -130,6 +130,37 @@ jobs:
needs.paths-filter.outputs.codechange == 'true'
run: "go run mage.go testcons:${{ matrix.datastore }}"

pgdatastore:
name: "Datastore 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 }}"
- name: "Consistency tests"
if: |
needs.paths-filter.outputs.codechange == 'true'
run: "go run mage.go testcons:${{ matrix.datastore }}ver ${{ 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 2d9d84a

Please sign in to comment.