Browse Source

add dtmserver panic test

pull/330/head
yedf2 4 years ago
parent
commit
d51716ff45
  1. 1
      dtmsvr/svr.go
  2. 12
      test/dtmsvr_test.go

1
dtmsvr/svr.go

@ -143,6 +143,7 @@ func grpcRecover(ctx context.Context, req interface{}, info *grpc.UnaryServerInf
defer func() {
if x := recover(); x != nil {
rerr = status.Errorf(codes.Internal, "%v", x)
logger.Errorf("dtm server panic: %v", x)
}
}()
res, rerr = handler(ctx, req)

12
test/dtmsvr_test.go

@ -7,10 +7,13 @@
package test
import (
"context"
"testing"
"time"
"github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
"github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp"
"github.com/dtm-labs/dtm/client/dtmgrpc/dtmgpb"
"github.com/dtm-labs/dtm/client/workflow"
"github.com/dtm-labs/dtm/dtmsvr"
"github.com/dtm-labs/dtm/dtmsvr/config"
@ -80,3 +83,12 @@ func TestUpdateBranchAsync(t *testing.T) {
conf.UpdateBranchSync = 1
}
func TestGrpcPanic(t *testing.T) {
gid := dtmimp.GetFuncName()
req := dtmgpb.DtmRequest{
Gid: gid,
}
err := dtmgimp.MustGetGrpcConn(DtmGrpcServer, false).Invoke(context.Background(), "/dtmgimp.Dtm/"+"Submit", &req, nil)
assert.Error(t, err)
}

Loading…
Cancel
Save