Skip to content

Commit

Permalink
Update integration test suite (formally e2e) (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfridman authored Mar 14, 2024
1 parent 73e2f88 commit b2c483a
Show file tree
Hide file tree
Showing 91 changed files with 1,519 additions and 2,204 deletions.
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 @@ -12,13 +12,9 @@ concurrency:

jobs:
test:
name: Run e2e tests
name: Run integration tests
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
max-parallel: 2
matrix:
dialect: ["postgres", "mysql", "vertica", "clickhouse", "ydb", "turso"]

steps:
- name: Checkout code
Expand All @@ -27,6 +23,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 test-integration
3 changes: 2 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: golangci

on:
push:
branches:
- master
- main
pull_request:

concurrency:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

Expand Down
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
53 changes: 39 additions & 14 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,25 +42,50 @@ 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
#
# 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
gomod:
go mod tidy
cd ./internal/testing/integration && go mod tidy

test-e2e-clickhouse:
go test $(GO_TEST_FLAGS) ./tests/clickhouse -test.short
upgrade-integration-deps:
cd ./internal/testing/integration && go get -u ./... && go mod tidy

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

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

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

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

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

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
})
})
// Test generic behavior.
t.Run("sqlite3", func(t *testing.T) {
db, err := sql.Open("sqlite", ":memory:")
Expand Down
25 changes: 0 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ require (
github.com/jackc/pgx/v5 v5.5.5
github.com/mfridman/interpolate v0.0.2
github.com/microsoft/go-mssqldb v1.7.0
github.com/ory/dockertest/v3 v3.10.0
github.com/sethvargo/go-retry v0.2.4
github.com/tursodatabase/libsql-client-go v0.0.0-20240220085343-4ae0eb9d0898
github.com/vertica/vertica-sql-go v1.3.3
Expand All @@ -21,32 +20,20 @@ require (

require (
filippo.io/edwards25519 v1.1.0 // indirect
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
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/dustin/go-humanize v1.0.1 // indirect
github.com/elastic/go-sysinfo v1.11.2 // 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/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.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
Expand All @@ -55,37 +42,25 @@ require (
github.com/klauspost/compress v1.17.2 // 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/ncruces/go-strftime v0.1.9 // 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/pkg/errors v0.9.1 // indirect
github.com/prometheus/procfs v0.12.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.18.0 // indirect
golang.org/x/exp v0.0.0-20231108232855-2478ac86f678 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.17.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.33.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
howett.net/plist v1.0.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
Expand Down
Loading

0 comments on commit b2c483a

Please sign in to comment.