Browse Source

fix msg delay unit test

pull/223/head
xyctruth 4 years ago
parent
commit
8dc04d8ab3
  1. 5
      dtmsvr/trans_class.go
  2. 8
      test/msg_delay_test.go

5
dtmsvr/trans_class.go

@ -19,11 +19,12 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
// triggerType trigger transaction type
type triggerType int type triggerType int
const ( const (
triggerManual triggerType = iota //manual trigger triggerManual triggerType = iota //triggerManual manual trigger
triggerCron //cron trigger triggerCron //triggerCron cron trigger
) )
// TransGlobal global transaction // TransGlobal global transaction

8
test/msg_delay_test.go

@ -2,11 +2,9 @@ package test
import ( import (
"testing" "testing"
"time"
"github.com/dtm-labs/dtm/dtmcli" "github.com/dtm-labs/dtm/dtmcli"
"github.com/dtm-labs/dtm/dtmcli/dtmimp" "github.com/dtm-labs/dtm/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/dtmsvr"
"github.com/dtm-labs/dtm/dtmutil" "github.com/dtm-labs/dtm/dtmutil"
"github.com/dtm-labs/dtm/test/busi" "github.com/dtm-labs/dtm/test/busi"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -25,14 +23,10 @@ func TestMsgDelayNormal(t *testing.T) {
gid := dtmimp.GetFuncName() gid := dtmimp.GetFuncName()
msg := genMsgDelay(gid) msg := genMsgDelay(gid)
msg.Submit() msg.Submit()
assert.Equal(t, StatusSubmitted, getTransStatus(msg.Gid))
waitTransProcessed(msg.Gid) waitTransProcessed(msg.Gid)
assert.Equal(t, []string{StatusPrepared, StatusPrepared}, getBranchesStatus(msg.Gid)) assert.Equal(t, []string{StatusPrepared, StatusPrepared}, getBranchesStatus(msg.Gid))
assert.Equal(t, StatusSubmitted, getTransStatus(msg.Gid)) assert.Equal(t, StatusSubmitted, getTransStatus(msg.Gid))
time.Sleep(2 * time.Second) cronTransOnceForwardNow(t, gid, 2)
dtmsvr.CronForwardDuration = 0
cronTransOnce(t, gid)
assert.Equal(t, []string{StatusSucceed, StatusSucceed}, getBranchesStatus(msg.Gid)) assert.Equal(t, []string{StatusSucceed, StatusSucceed}, getBranchesStatus(msg.Gid))
assert.Equal(t, StatusSucceed, getTransStatus(msg.Gid)) assert.Equal(t, StatusSucceed, getTransStatus(msg.Gid))
dtmsvr.CronForwardDuration = 180 * time.Second
} }

Loading…
Cancel
Save