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

test: use isolated databases to parallelize all tests #879

Merged
merged 4 commits into from
May 30, 2022

Conversation

zepatrik
Copy link
Member

@zepatrik zepatrik commented May 27, 2022

Separating a few changes from #840

You can now also use go test -tags sqlite,nomysql to run tests against all DBs, except mysql. You can also omit the sqlite tags, which will just use all others. FYI @aeneasr

I got some errors when using the DBs started by docker, that might be related to cleanup I think. We'll have to fix those still.

--- FAIL: TestMigrate (34.72s)
    --- FAIL: TestMigrate/dsn=mysql (3.86s)
        --- FAIL: TestMigrate/dsn=mysql/case=applies_on_yes_flag (1.54s)
            helper.go:181: 
                        Error Trace:    helper.go:181
                                                                helper.go:221
                                                                migrate_test.go:130
                                                                testing.go:1034
                                                                testing.go:1203
                                                                testing.go:1433
                        Error:          Received unexpected error:
                                        this error should never be printed
                                        github.com/ory/x/cmdx.init
                                                /home/patrik/git/go/pkg/mod/github.com/ory/x@v0.0.389/cmdx/helper.go:28
                                        runtime.doInit
                                                /usr/lib/go/src/runtime/proc.go:6222
                                        runtime.doInit
                                                /usr/lib/go/src/runtime/proc.go:6199
                                        runtime.doInit
                                                /usr/lib/go/src/runtime/proc.go:6199
                                        runtime.main
                                                /usr/lib/go/src/runtime/proc.go:233
                                        runtime.goexit
                                                /usr/lib/go/src/runtime/asm_amd64.s:1571
                                        github.com/ory/x/cmdx.FailSilently
                                                /home/patrik/git/go/pkg/mod/github.com/ory/x@v0.0.389/cmdx/helper.go:36
                                        github.com/ory/keto/cmd/migrate.BoxDown
                                                /home/patrik/git/keto/cmd/migrate/down.go:65
                                        github.com/ory/keto/cmd/migrate.newDownCmd.func1
                                                /home/patrik/git/keto/cmd/migrate/down.go:40
                                        github.com/spf13/cobra.(*Command).execute
                                                /home/patrik/git/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:856
                                        github.com/spf13/cobra.(*Command).ExecuteC
                                                /home/patrik/git/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974
                                        github.com/spf13/cobra.(*Command).Execute
                                                /home/patrik/git/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902
                                        github.com/spf13/cobra.(*Command).ExecuteContext
                                                /home/patrik/git/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:895
                                        github.com/ory/x/cmdx.ExecBackgroundCtx.func1
                                                /home/patrik/git/go/pkg/mod/github.com/ory/x@v0.0.389/cmdx/helper.go:143
                                        golang.org/x/sync/errgroup.(*Group).Go.func1
                                                /home/patrik/git/go/pkg/mod/golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57
                                        runtime.goexit
                                                /usr/lib/go/src/runtime/asm_amd64.s:1571
                        Test:           TestMigrate/dsn=mysql/case=applies_on_yes_flag
                        Messages:       std_out: Version                        Name            Status  
                                        20150100000001000000    networks        Applied 
                                        20201110175414000000    relationtuple   Applied 
                                        20201110175414000001    relationtuple   Applied 
                                        20210623162417000000    relationtuple   Applied 
                                        20210623162417000001    relationtuple   Applied 
                                        20210914134624000000    legacy-cleanup  Applied 
                                        20220217152313000000    nid_fk          Applied 
                                        20220512151000000000    indices         Applied 
                                        
                                        std_err: Could apply down migrations: invalid connection
                                        error committing or rolling back transaction: error executing migrations/sql/20201110175414000001_relationtuple.mysql.down.sql, sql: DROP TABLE keto_namespace;: invalid connection
                                        github.com/ory/x/popx.(*Migrator).isolatedTransaction
                                                /home/patrik/git/go/pkg/mod/github.com/ory/x@v0.0.389/popx/migrator.go:324
                                        github.com/ory/x/popx.(*Migrator).Down.func1
                                                /home/patrik/git/go/pkg/mod/github.com/ory/x@v0.0.389/popx/migrator.go:212
                                        github.com/ory/x/popx.(*Migrator).exec
                                                /home/patrik/git/go/pkg/mod/github.com/ory/x@v0.0.389/popx/migrator.go:559
                                        github.com/ory/x/popx.(*Migrator).Down
                                                /home/patrik/git/go/pkg/mod/github.com/ory/x@v0.0.389/popx/migrator.go:177
                                        github.com/ory/keto/cmd/migrate.BoxDown
                                                /home/patrik/git/keto/cmd/migrate/down.go:63
                                        github.com/ory/keto/cmd/migrate.newDownCmd.func1
                                                /home/patrik/git/keto/cmd/migrate/down.go:40
                                        github.com/spf13/cobra.(*Command).execute
                                                /home/patrik/git/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:856
                                        github.com/spf13/cobra.(*Command).ExecuteC
                                                /home/patrik/git/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:974
                                        github.com/spf13/cobra.(*Command).Execute
                                                /home/patrik/git/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:902
                                        github.com/spf13/cobra.(*Command).ExecuteContext
                                                /home/patrik/git/go/pkg/mod/github.com/spf13/cobra@v1.4.0/command.go:895
                                        github.com/ory/x/cmdx.ExecBackgroundCtx.func1
                                                /home/patrik/git/go/pkg/mod/github.com/ory/x@v0.0.389/cmdx/helper.go:143
                                        golang.org/x/sync/errgroup.(*Group).Go.func1
                                                /home/patrik/git/go/pkg/mod/golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c/errgroup/errgroup.go:57
                                        runtime.goexit
                                                /usr/lib/go/src/runtime/asm_amd64.s:1571
    dsn_testutils.go:94: could not drop database "testdb_e5015d8a6ad5870a1e932f45b0d670769c3eaef9" in "mysql://root:secret@(localhost:49236)/mysql?parseTime=true&multiStatements=true": dial tcp [::1]:49236: connect: connection refused
    dsn_testutils.go:94: could not drop database "testdb_e5015d8a6ad5870a1e932f45b0d670769c3eaef9" in "postgres://postgres:secret@127.0.0.1:49237/postgres?sslmode=disable": unexpected EOF
[mysql] 2022/05/27 13:23:32 packets.go:123: closing bad idle connection: EOF
FAIL
FAIL    github.com/ory/keto/cmd/migrate 38.709s
FAIL

@zepatrik zepatrik requested a review from hperl May 27, 2022 11:36
@zepatrik zepatrik marked this pull request as ready for review May 30, 2022 12:27
@zepatrik zepatrik merged commit 0bfb10e into master May 30, 2022
@zepatrik zepatrik deleted the test/parallel-db branch May 30, 2022 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant