Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch postgres tests to run in a matrix of versions #2195

Merged
merged 4 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can put the if on the whole job?

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
Loading