diff --git a/helper/test-cover.sh b/helper/test-cover.sh index ca14aa6..13bd654 100644 --- a/helper/test-cover.sh +++ b/helper/test-cover.sh @@ -2,7 +2,7 @@ set -x echo "" > coverage.txt for store in redis mysql boltdb; do for d in $(go list ./... | grep -v vendor); do - TEST_STORE=$store go test -covermode count -coverprofile=profile.out -coverpkg=github.com/dtm-labs/dtm/dtmcli,github.com/dtm-labs/dtm/dtmcli/dtmimp,github.com/dtm-labs/dtm/dtmcli/logger,github.com/dtm-labs/dtm/dtmgrpc,github.com/dtm-labs/dtm/dtmgrpc/dtmgimp,github.com/dtm-labs/dtm/dtmsvr,github.com/dtm-labs/dtm/dtmsvr/config,github.com/dtm-labs/dtm/dtmsvr/storage,github.com/dtm-labs/dtm/dtmsvr/storage/boltdb,github.com/dtm-labs/dtm/dtmsvr/storage/redis,github.com/dtm-labs/dtm/dtmsvr/storage/registry,github.com/dtm-labs/dtm/dtmsvr/storage/sql,github.com/dtm-labs/dtm/dtmutil -gcflags=-l $d + TEST_STORE=$store go test -covermode count -coverprofile=profile.out -coverpkg=github.com/dtm-labs/dtm/dtmcli,github.com/dtm-labs/dtm/dtmcli/dtmimp,github.com/dtm-labs/dtm/dtmcli/logger,github.com/dtm-labs/dtm/dtmgrpc,github.com/dtm-labs/dtm/dtmgrpc/dtmgimp,github.com/dtm-labs/dtm/dtmsvr,github.com/dtm-labs/dtm/dtmsvr/config,github.com/dtm-labs/dtm/dtmsvr/storage,github.com/dtm-labs/dtm/dtmsvr/storage/boltdb,github.com/dtm-labs/dtm/dtmsvr/storage/redis,github.com/dtm-labs/dtm/dtmsvr/storage/registry,github.com/dtm-labs/dtm/dtmsvr/storage/sql,github.com/dtm-labs/dtm/dtmutil -gcflags=-l $d || exit 1 if [ -f profile.out ]; then cat profile.out >> coverage.txt echo > profile.out diff --git a/test/main_test.go b/test/main_test.go index 9d0036c..0f4add2 100644 --- a/test/main_test.go +++ b/test/main_test.go @@ -63,6 +63,9 @@ func TestMain(m *testing.M) { busi.PopulateDB(false) _ = busi.Startup() - exitIf(m.Run()) - + r := m.Run() + exitIf(r) + close(dtmsvr.TransProcessedTestChan) + gid, more := <-dtmsvr.TransProcessedTestChan + logger.FatalfIf(more, "extra gid: %s in test chan", gid) } diff --git a/test/msg_barrier_test.go b/test/msg_barrier_test.go index 29970dd..fe586e0 100644 --- a/test/msg_barrier_test.go +++ b/test/msg_barrier_test.go @@ -57,6 +57,9 @@ func TestMsgPrepareAndSubmitPrepareFailed(t *testing.T) { } func TestMsgPrepareAndSubmitCommitFailed(t *testing.T) { + if conf.Store.IsDB() { // cannot patch tx.Commit, because Prepare also do Commit + return + } before := getBeforeBalances() gid := dtmimp.GetFuncName() req := busi.GenTransReq(30, false, false) @@ -78,6 +81,9 @@ func TestMsgPrepareAndSubmitCommitFailed(t *testing.T) { } func TestMsgPrepareAndSubmitCommitAfterFailed(t *testing.T) { + if conf.Store.IsDB() { // cannot patch tx.Commit, because Prepare also do Commit + return + } before := getBeforeBalances() gid := dtmimp.GetFuncName() req := busi.GenTransReq(30, false, false)