Browse Source
Merge pull request #79 from yedf/alpha
fix grpc WaitResult
pull/80/head
yedf2
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
19 additions and
1 deletions
-
dtmsvr/trans_class.go
-
test/saga_grpc_test.go
-
test/saga_options_test.go
|
|
|
@ -114,12 +114,21 @@ func TransFromContext(c *gin.Context) *TransGlobal { |
|
|
|
|
|
|
|
// TransFromDtmRequest TransFromContext
|
|
|
|
func TransFromDtmRequest(c *dtmgimp.DtmRequest) *TransGlobal { |
|
|
|
o := &dtmgimp.DtmTransOptions{} |
|
|
|
if c.TransOptions != nil { |
|
|
|
o = c.TransOptions |
|
|
|
} |
|
|
|
r := TransGlobal{ |
|
|
|
Gid: c.Gid, |
|
|
|
TransType: c.TransType, |
|
|
|
QueryPrepared: c.QueryPrepared, |
|
|
|
Protocol: "grpc", |
|
|
|
BinPayloads: c.BinPayloads, |
|
|
|
TransOptions: dtmcli.TransOptions{ |
|
|
|
WaitResult: o.WaitResult, |
|
|
|
TimeoutToFail: o.TimeoutToFail, |
|
|
|
RetryInterval: o.RetryInterval, |
|
|
|
}, |
|
|
|
} |
|
|
|
if c.Steps != "" { |
|
|
|
dtmimp.MustUnmarshalString(c.Steps, &r.Steps) |
|
|
|
|
|
|
|
@ -66,6 +66,15 @@ func TestSagaGrpcCommittedOngoing(t *testing.T) { |
|
|
|
assert.Equal(t, []string{StatusPrepared, StatusSucceed, StatusPrepared, StatusSucceed}, getBranchesStatus(saga.Gid)) |
|
|
|
} |
|
|
|
|
|
|
|
func TestSagaGrpcNormalWait(t *testing.T) { |
|
|
|
saga := genSagaGrpc(dtmimp.GetFuncName(), false, false) |
|
|
|
saga.SetOptions(&dtmcli.TransOptions{WaitResult: true}) |
|
|
|
saga.Submit() |
|
|
|
assert.Equal(t, []string{StatusPrepared, StatusSucceed, StatusPrepared, StatusSucceed}, getBranchesStatus(saga.Gid)) |
|
|
|
assert.Equal(t, StatusSucceed, getTransStatus(saga.Gid)) |
|
|
|
waitTransProcessed(saga.Gid) |
|
|
|
} |
|
|
|
|
|
|
|
func genSagaGrpc(gid string, outFailed bool, inFailed bool) *dtmgrpc.SagaGrpc { |
|
|
|
saga := dtmgrpc.NewSagaGrpc(examples.DtmGrpcServer, gid) |
|
|
|
req := examples.GenBusiReq(30, outFailed, inFailed) |
|
|
|
|
|
|
|
@ -58,9 +58,9 @@ func TestSagaOptionsNormalWait(t *testing.T) { |
|
|
|
saga.SetOptions(&dtmcli.TransOptions{WaitResult: true}) |
|
|
|
err := saga.Submit() |
|
|
|
assert.Nil(t, err) |
|
|
|
waitTransProcessed(saga.Gid) |
|
|
|
assert.Equal(t, []string{StatusPrepared, StatusSucceed, StatusPrepared, StatusSucceed}, getBranchesStatus(saga.Gid)) |
|
|
|
assert.Equal(t, StatusSucceed, getTransStatus(saga.Gid)) |
|
|
|
waitTransProcessed(saga.Gid) |
|
|
|
} |
|
|
|
|
|
|
|
func TestSagaOptionsCommittedOngoingWait(t *testing.T) { |
|
|
|
|