diff --git a/common/types.go b/common/types.go index 4f7f74a..4be83a3 100644 --- a/common/types.go +++ b/common/types.go @@ -197,6 +197,9 @@ func checkConfig() string { func WaitDBUp() { sdb, err := dtmimp.StandaloneDB(DtmConfig.DB) dtmimp.FatalIfError(err) + defer func() { + sdb.Close() + }() for _, err := dtmimp.DBExec(sdb, "select 1"); err != nil; { // wait for mysql to start time.Sleep(3 * time.Second) _, err = dtmimp.DBExec(sdb, "select 1") diff --git a/common/types_test.go b/common/types_test.go index 84d4c32..ed3c30f 100644 --- a/common/types_test.go +++ b/common/types_test.go @@ -19,6 +19,10 @@ func TestDb(t *testing.T) { assert.NotEqual(t, nil, err) } +func TestWaitDBUp(t *testing.T) { + WaitDBUp() +} + func TestDbAlone(t *testing.T) { db, err := dtmimp.StandaloneDB(DtmConfig.DB) assert.Nil(t, err)