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

Update integration test suite #713

Merged
merged 21 commits into from
Mar 14, 2024
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Goose end-end tests
name: Goose integration tests

on:
push:
Expand All @@ -8,13 +8,9 @@ on:

jobs:
test:
name: Run e2e tests
name: Run integration tests
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
max-parallel: 2
matrix:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was a bit of a bottleneck, and I think we should be able to run more tests in parallel.

dialect: ["postgres", "mysql", "vertica", "clickhouse", "ydb", "turso"]

steps:
- name: Checkout code
Expand All @@ -23,6 +19,6 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: "stable"
- name: Run e2e ${{ matrix.dialect }} tests
- name: Run full integration tests
run: |
make test-e2e-${{ matrix.dialect }}
make integration
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@

dist/
release_notes.txt

go.work
go.work.sum
50 changes: 34 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GO_TEST_FLAGS ?= -race -count=1 -v -timeout=10m
GO_TEST_FLAGS ?= -race -count=1 -v -timeout=5m

# These are the default values for the test database. They can be overridden
DB_USER ?= dbuser
Expand Down Expand Up @@ -42,28 +42,46 @@ test-packages:
test-packages-short:
go test -test.short $(GO_TEST_FLAGS) $$(go list ./... | grep -v -e /tests -e /bin -e /cmd -e /examples)

test-e2e: test-e2e-postgres test-e2e-mysql test-e2e-clickhouse test-e2e-vertica test-e2e-ydb test-e2e-turso test-e2e-duckdb
#
# Integration-related targets
#
add-gowork:
@[ -f go.work ] || go work init
@[ -f go.work.sum ] || go work use -r .

test-e2e-postgres:
go test $(GO_TEST_FLAGS) ./tests/e2e -dialect=postgres
remove-gowork:
rm -rf go.work go.work.sum

test-e2e-mysql:
go test $(GO_TEST_FLAGS) ./tests/e2e -dialect=mysql
test-postgres-long: add-gowork test-postgres
go test $(GO_TEST_FLAGS) ./internal/testing/integration -run='(TestPostgresProviderLocking|TestPostgresSessionLocker)'

test-e2e-clickhouse:
go test $(GO_TEST_FLAGS) ./tests/clickhouse -test.short
test-postgres: add-gowork
go test $(GO_TEST_FLAGS) ./internal/testing/integration -run='TestPostgres'

test-e2e-vertica:
go test $(GO_TEST_FLAGS) ./tests/vertica
test-clickhouse: add-gowork
go test $(GO_TEST_FLAGS) ./internal/testing/integration -run='(TestClickhouse|TestClickhouseRemote)'

test-e2e-ydb:
go test $(GO_TEST_FLAGS) -parallel=1 ./tests/e2e -dialect=ydb
test-mysql: add-gowork
go test $(GO_TEST_FLAGS) ./internal/testing/integration -run='TestMySQL'

test-e2e-turso:
go test $(GO_TEST_FLAGS) -parallel=1 ./tests/e2e -dialect=turso
test-turso: add-gowork
go test $(GO_TEST_FLAGS) ./internal/testing/integration -run='TestTurso'

test-e2e-duckdb:
go test $(GO_TEST_FLAGS) -parallel=1 ./tests/e2e -dialect=duckdb
test-duckdb: add-gowork
go test $(GO_TEST_FLAGS) ./internal/testing/integration -run='TestDuckDB'

test-vertica: add-gowork
go test $(GO_TEST_FLAGS) ./internal/testing/integration -run='TestVertica'

test-ydb: add-gowork
go test $(GO_TEST_FLAGS) ./internal/testing/integration -run='TestYDB'

test-integration: add-gowork
go test $(GO_TEST_FLAGS) ./internal/testing/integration/...

#
# Docker-related targets
#

docker-cleanup:
docker stop -t=0 $$(docker ps --filter="label=goose_test" -aq)
Expand Down
17 changes: 0 additions & 17 deletions database/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import (
"path/filepath"
"testing"

"github.com/jackc/pgx/v5/pgconn"
"github.com/pressly/goose/v3/database"
"github.com/pressly/goose/v3/internal/check"
"github.com/pressly/goose/v3/internal/testdb"
"go.uber.org/multierr"
"modernc.org/sqlite"
)
Expand All @@ -32,21 +30,6 @@ func TestDialectStore(t *testing.T) {
_, err = database.NewStore("", "foo")
check.HasError(t, err)
})
t.Run("postgres", func(t *testing.T) {
if testing.Short() {
t.Skip("skip long-running test")
}
// Test postgres specific behavior.
db, cleanup, err := testdb.NewPostgres()
check.NoError(t, err)
t.Cleanup(cleanup)
testStore(context.Background(), t, database.DialectPostgres, db, func(t *testing.T, err error) {
var pgErr *pgconn.PgError
ok := errors.As(err, &pgErr)
check.Bool(t, ok, true)
check.Equal(t, pgErr.Code, "42P07") // duplicate_table
Copy link
Collaborator Author

@mfridman mfridman Mar 14, 2024

Choose a reason for hiding this comment

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

The entire dialect store can be tested with SQLite. The only reason we had postgres in here was to test for this duplicate table error, confirming the error can be correctly asserted from caller -> driver -> goose -> caller.

})
})
// Test generic behavior.
t.Run("sqlite3", func(t *testing.T) {
db, err := sql.Open("sqlite", ":memory:")
Expand Down
111 changes: 49 additions & 62 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,102 +1,89 @@
module github.com/pressly/goose/v3

go 1.20
go 1.21

toolchain go1.22.1

require (
github.com/ClickHouse/clickhouse-go/v2 v2.17.1
github.com/go-sql-driver/mysql v1.7.1
github.com/jackc/pgx/v5 v5.5.2
github.com/marcboeker/go-duckdb v1.5.6
github.com/ClickHouse/clickhouse-go/v2 v2.20.0
github.com/go-sql-driver/mysql v1.8.0
github.com/jackc/pgx/v5 v5.5.5
github.com/marcboeker/go-duckdb v1.6.1
github.com/mfridman/interpolate v0.0.2
github.com/microsoft/go-mssqldb v1.6.0
github.com/ory/dockertest/v3 v3.10.0
Copy link
Collaborator Author

@mfridman mfridman Mar 10, 2024

Choose a reason for hiding this comment

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

I want the main goose module to have no dependency on this and any of the indirect deps. I think removing it and having an independent "integration test" module is cleaner.

github.com/microsoft/go-mssqldb v1.7.0
github.com/sethvargo/go-retry v0.2.4
github.com/tursodatabase/libsql-client-go v0.0.0-20231216154754-8383a53d618f
github.com/tursodatabase/libsql-client-go v0.0.0-20240220085343-4ae0eb9d0898
github.com/vertica/vertica-sql-go v1.3.3
github.com/ydb-platform/ydb-go-sdk/v3 v3.55.1
github.com/ydb-platform/ydb-go-sdk/v3 v3.57.0
github.com/ziutek/mymysql v1.5.4
go.uber.org/multierr v1.11.0
golang.org/x/sync v0.6.0
modernc.org/sqlite v1.28.0
modernc.org/sqlite v1.29.3
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/ClickHouse/ch-go v0.58.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/andybalholm/brotli v1.0.6 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/ClickHouse/ch-go v0.61.5 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/containerd/continuity v0.4.3 // indirect
github.com/docker/cli v24.0.7+incompatible // indirect
github.com/docker/docker v24.0.7+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/apache/arrow/go/v14 v14.0.2 // indirect
github.com/docker/docker v25.0.4+incompatible // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/elastic/go-sysinfo v1.11.2 // indirect
github.com/elastic/go-sysinfo v1.13.1 // indirect
github.com/elastic/go-windows v1.0.1 // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.6.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/go-faster/errors v0.7.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/google/uuid v1.5.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/flatbuffers v24.3.7+incompatible // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 // indirect
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/libsql/sqlite-antlr4-parser v0.0.0-20230802215326-5cb5bb604475 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/paulmach/orb v0.10.0 // indirect
github.com/pierrec/lz4/v4 v4.1.18 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/paulmach/orb v0.11.1 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240126124512-dbb0e1720dbf // indirect
go.opentelemetry.io/otel v1.20.0 // indirect
go.opentelemetry.io/otel/trace v1.20.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.15.0 // indirect
github.com/ydb-platform/ydb-go-genproto v0.0.0-20240219184408-1de5f3f077de // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
golang.org/x/tools v0.19.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240308144416-29370a3891b7 // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
howett.net/plist v1.0.0 // indirect
lukechampine.com/uint128 v1.3.0 // indirect
modernc.org/cc/v3 v3.41.0 // indirect
modernc.org/ccgo/v3 v3.16.15 // indirect
modernc.org/libc v1.32.0 // indirect
howett.net/plist v1.0.1 // indirect
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect
modernc.org/libc v1.43.1 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.7.2 // indirect
modernc.org/opt v0.1.3 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
nhooyr.io/websocket v1.8.7 // indirect
nhooyr.io/websocket v1.8.10 // indirect
)

retract (
Expand Down
Loading
Loading