Skip to content
Snippets Groups Projects
Commit c6c0535c authored by AlexStocks's avatar AlexStocks
Browse files

Fix: ut fail

parent 095d3f5e
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......@@ -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()
......
......@@ -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())
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment