Skip to content

Commit

Permalink
Fix: ut fail
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexStocks committed Oct 8, 2020
1 parent ab06520 commit 0571516
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
7 changes: 3 additions & 4 deletions protocol/dubbo/dubbo_invoker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ func TestDubboInvokerInvoke(t *testing.T) {

// destroy
lock.Lock()
defer lock.Unlock()
proto.Destroy()
lock.Unlock()
}

func InitTest(t *testing.T) (protocol.Protocol, common.URL) {

hessian.RegisterPOJO(&User{})

methods, err := common.ServiceMap.Register("", "dubbo", &UserProvider{})
methods, err := common.ServiceMap.Register("com.ikurento.user.UserProvider", "dubbo", &UserProvider{})
assert.NoError(t, err)
assert.Equal(t, "GetBigPkg,GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4,GetUser5,GetUser6", methods)

Expand Down Expand Up @@ -176,10 +176,9 @@ type (
// size:4801228
func (u *UserProvider) GetBigPkg(ctx context.Context, req []interface{}, rsp *User) error {
argBuf := new(bytes.Buffer)
for i := 0; i < 400; i++ {
for i := 0; i < 800; i++ {
// use chinese for test
argBuf.WriteString("击鼓其镗,踊跃用兵。土国城漕,我独南行。从孙子仲,平陈与宋。不我以归,忧心有忡。爰居爰处?爰丧其马?于以求之?于林之下。死生契阔,与子成说。执子之手,与子偕老。于嗟阔兮,不我活兮。于嗟洵兮,不我信兮。")
argBuf.WriteString("击鼓其镗,踊跃用兵。土国城漕,我独南行。从孙子仲,平陈与宋。不我以归,忧心有忡。爰居爰处?爰丧其马?于以求之?于林之下。死生契阔,与子成说。执子之手,与子偕老。于嗟阔兮,不我活兮。于嗟洵兮,不我信兮。")
}
rsp.Id = argBuf.String()
rsp.Name = argBuf.String()
Expand Down
15 changes: 11 additions & 4 deletions remoting/getty/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,26 @@ func newGettyRPCClientConn(pool *gettyRPCClientPool, addr string) (*gettyRPCClie
gettyClient: gettyClient,
}
go c.gettyClient.RunEventLoop(c.newSession)

idx := 1
times := int(pool.rpcClient.opts.ConnectTimeout / 1e6)
start := time.Now()
connectTimeout := pool.rpcClient.opts.ConnectTimeout
for {
idx++
if c.isAvailable() {
break
}

if idx > times {
if time.Now().Sub(start) > connectTimeout {
c.gettyClient.Close()
return nil, perrors.New(fmt.Sprintf("failed to create client connection to %s in %f seconds", addr, float32(times)/1000))
return nil, perrors.New(fmt.Sprintf("failed to create client connection to %s in %s", addr, connectTimeout))
}

interval := time.Millisecond * time.Duration(idx)
if interval > time.Duration(100e6) {
interval = 100e6 // 100 ms
}
time.Sleep(time.Millisecond * time.Duration(times))
time.Sleep(interval)
}
logger.Debug("client init ok")
c.updateActive(time.Now().Unix())
Expand Down

0 comments on commit 0571516

Please sign in to comment.