diff --git a/go.mod b/go.mod index 1698740d5..b6980a171 100644 --- a/go.mod +++ b/go.mod @@ -5,11 +5,11 @@ go 1.18 require ( dubbo.apache.org/dubbo-go/v3 v3.0.3-rc2 github.com/DATA-DOG/go-sqlmock v1.5.0 - github.com/apache/dubbo-getty v1.4.9-0.20220825024508-3da63c3257fa + github.com/apache/dubbo-getty v1.4.10-0.20230731065302-7c0f0039e59c github.com/arana-db/parser v0.2.5 github.com/bluele/gcache v0.0.2 github.com/dsnet/compress v0.0.1 - github.com/dubbogo/gost v1.12.6-0.20220824084206-300e27e9e524 + github.com/dubbogo/gost v1.13.1 github.com/gin-gonic/gin v1.8.0 github.com/go-sql-driver/mysql v1.6.0 github.com/goccy/go-json v0.9.7 diff --git a/go.sum b/go.sum index 6a0441924..47106fb16 100644 --- a/go.sum +++ b/go.sum @@ -66,9 +66,11 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alibaba/sentinel-golang v1.0.4/go.mod h1:Lag5rIYyJiPOylK8Kku2P+a23gdKMMqzQS7wTnjWEpk= github.com/aliyun/alibaba-cloud-sdk-go v1.61.18/go.mod h1:v8ESoHo4SyHmuB4b1tJqDHxfTGEciD+yhvOU/5s1Rfk= +github.com/aliyun/alibaba-cloud-sdk-go v1.61.1704/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/dubbo-getty v1.4.9-0.20220825024508-3da63c3257fa h1:siT9WaTLlbR8McWqiCAyo5DtH3NNPWS4D6oJXjbX0tc= github.com/apache/dubbo-getty v1.4.9-0.20220825024508-3da63c3257fa/go.mod h1:6qmrqBSPGs3B35zwEuGhEYNVsx1nfGT/xzV2yOt2amM= +github.com/apache/dubbo-getty v1.4.10-0.20230731065302-7c0f0039e59c h1:e1pJKY0lFvO6rik7m3qmpMRA98cc9Zkg6AJeB1/7QFQ= +github.com/apache/dubbo-getty v1.4.10-0.20230731065302-7c0f0039e59c/go.mod h1:TqHfi87Ufv7wpwI7nER5Kx8FCb/jjwlyazxiYwEmTs8= github.com/apache/dubbo-go-hessian2 v1.9.1/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/dubbo-go-hessian2 v1.9.3/go.mod h1:xQUjE7F8PX49nm80kChFvepA/AvqAZ0oh/UaB6+6pBE= github.com/apache/dubbo-go-hessian2 v1.11.1 h1:03xs4QCAZHY/gHCOWgOmIUW6Yc842FCLz4R0hxCzPr8= @@ -170,8 +172,9 @@ github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4D github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c= github.com/dubbogo/gost v1.9.0/go.mod h1:pPTjVyoJan3aPxBPNUX0ADkXjPibLo+/Ib0/fADXSG8= github.com/dubbogo/gost v1.11.18/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI= -github.com/dubbogo/gost v1.12.6-0.20220824084206-300e27e9e524 h1:QgDFv0rwH6RTVSpYc9oEZsAGM4DGg0YN5XHk69vZshU= github.com/dubbogo/gost v1.12.6-0.20220824084206-300e27e9e524/go.mod h1:0YHTGJtjHiYlWtVEkZnyrvhr7rR+23GczNaJrgc2v38= +github.com/dubbogo/gost v1.13.1 h1:71EJIwV6ev0CxWqWPwcDcHhzEq1Q5pUmCkLcLCBaqvM= +github.com/dubbogo/gost v1.13.1/go.mod h1:9HMXBv+WBMRWhF3SklpqDjkS/01AKWm2SrVdz/A0xJI= github.com/dubbogo/grpc-go v1.42.9/go.mod h1:F1T9hnUvYGW4JLK1QNriavpOkhusU677ovPzLkk6zHM= github.com/dubbogo/grpc-go v1.42.10/go.mod h1:JMkPt1mIHL96GAFeYsMoMjew6f1ROKycikGzZQH1s5U= github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU= @@ -558,6 +561,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nacos-group/nacos-sdk-go v1.0.8/go.mod h1:hlAPn3UdzlxIlSILAyOXKxjFSvDJ9oLzTJ9hLAK1KzA= github.com/nacos-group/nacos-sdk-go v1.1.2/go.mod h1:I8Vj4M8ZLpBk7EY2A8RXQE1SbfCA7b56TJBPIFTrUYE= +github.com/nacos-group/nacos-sdk-go/v2 v2.1.2/go.mod h1:ys/1adWeKXXzbNWfRNbaFlX/t6HVLWdpsNDvmoWTw0g= github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= @@ -940,6 +944,7 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1035,6 +1040,7 @@ golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1194,6 +1200,7 @@ google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9K google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -1226,6 +1233,7 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= diff --git a/pkg/remoting/loadbalance/random_loadbalance_test.go b/pkg/remoting/loadbalance/random_loadbalance_test.go new file mode 100644 index 000000000..2a3791365 --- /dev/null +++ b/pkg/remoting/loadbalance/random_loadbalance_test.go @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package loadbalance + +import ( + "fmt" + "sync" + "testing" + + "github.com/golang/mock/gomock" + "github.com/seata/seata-go/pkg/remoting/mock" + "github.com/stretchr/testify/assert" +) + +func TestRandomLoadBalance_Nomal(t *testing.T) { + ctrl := gomock.NewController(t) + sessions := &sync.Map{} + + for i := 0; i < 3; i++ { + session := mock.NewMockTestSession(ctrl) + session.EXPECT().IsClosed().Return(i == 2).AnyTimes() + sessions.Store(session, fmt.Sprintf("session-%d", (i+1))) + } + result := RandomLoadBalance(sessions, "some_xid") + + assert.NotNil(t, result) + //assert random load balance return session not closed + assert.False(t, result.IsClosed()) +} + +func TestRandomLoadBalance_All_Closed(t *testing.T) { + + ctrl := gomock.NewController(t) + sessions := &sync.Map{} + + //mock closed sessions + for i := 0; i < 10; i++ { + session := mock.NewMockTestSession(ctrl) + session.EXPECT().IsClosed().Return(true).AnyTimes() + sessions.Store(session, fmt.Sprintf("session-%d", (i+1))) + } + result := RandomLoadBalance(sessions, "some_xid") + + assert.NotNil(t, result) + assert.True(t, result.IsClosed(), "found one un-closed session instance in ALL_CLOSED_SESSION_MAP") +} + +func TestRandomLoadBalance_All_Opening(t *testing.T) { + + ctrl := gomock.NewController(t) + sessions := &sync.Map{} + for i := 0; i < 10; i++ { + session := mock.NewMockTestSession(ctrl) + session.EXPECT().IsClosed().Return(false).AnyTimes() + sessions.Store(session, fmt.Sprintf("session-%d", (i+1))) + } + result := RandomLoadBalance(sessions, "some_xid") + //assert return session is not closed + assert.False(t, result.IsClosed()) +} diff --git a/pkg/remoting/mock/mock_getty_session.go b/pkg/remoting/mock/mock_getty_session.go new file mode 100644 index 000000000..a2abc681f --- /dev/null +++ b/pkg/remoting/mock/mock_getty_session.go @@ -0,0 +1,513 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Code generated by MockGen. DO NOT EDIT. +// Source: ./pkg/remoting/mock/test_getty_session.go + +// Package mock is a generated GoMock package. +package mock + +import ( + net "net" + reflect "reflect" + time "time" + + getty "github.com/apache/dubbo-getty" + gomock "github.com/golang/mock/gomock" +) + +// MockTestSession is a mock of TestSession interface. +type MockTestSession struct { + ctrl *gomock.Controller + recorder *MockTestSessionMockRecorder +} + +// MockTestSessionMockRecorder is the mock recorder for MockTestSession. +type MockTestSessionMockRecorder struct { + mock *MockTestSession +} + +// NewMockTestSession creates a new mock instance. +func NewMockTestSession(ctrl *gomock.Controller) *MockTestSession { + mock := &MockTestSession{ctrl: ctrl} + mock.recorder = &MockTestSessionMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTestSession) EXPECT() *MockTestSessionMockRecorder { + return m.recorder +} + +// Close mocks base method. +func (m *MockTestSession) Close() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Close") +} + +// Close indicates an expected call of Close. +func (mr *MockTestSessionMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockTestSession)(nil).Close)) +} + +// CloseConn mocks base method. +func (m *MockTestSession) CloseConn(arg0 int) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "CloseConn", arg0) +} + +// CloseConn indicates an expected call of CloseConn. +func (mr *MockTestSessionMockRecorder) CloseConn(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CloseConn", reflect.TypeOf((*MockTestSession)(nil).CloseConn), arg0) +} + +// Conn mocks base method. +func (m *MockTestSession) Conn() net.Conn { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Conn") + ret0, _ := ret[0].(net.Conn) + return ret0 +} + +// Conn indicates an expected call of Conn. +func (mr *MockTestSessionMockRecorder) Conn() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Conn", reflect.TypeOf((*MockTestSession)(nil).Conn)) +} + +// EndPoint mocks base method. +func (m *MockTestSession) EndPoint() getty.EndPoint { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EndPoint") + ret0, _ := ret[0].(getty.EndPoint) + return ret0 +} + +// EndPoint indicates an expected call of EndPoint. +func (mr *MockTestSessionMockRecorder) EndPoint() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndPoint", reflect.TypeOf((*MockTestSession)(nil).EndPoint)) +} + +// GetActive mocks base method. +func (m *MockTestSession) GetActive() time.Time { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetActive") + ret0, _ := ret[0].(time.Time) + return ret0 +} + +// GetActive indicates an expected call of GetActive. +func (mr *MockTestSessionMockRecorder) GetActive() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetActive", reflect.TypeOf((*MockTestSession)(nil).GetActive)) +} + +// GetAttribute mocks base method. +func (m *MockTestSession) GetAttribute(arg0 interface{}) interface{} { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAttribute", arg0) + ret0, _ := ret[0].(interface{}) + return ret0 +} + +// GetAttribute indicates an expected call of GetAttribute. +func (mr *MockTestSessionMockRecorder) GetAttribute(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAttribute", reflect.TypeOf((*MockTestSession)(nil).GetAttribute), arg0) +} + +// ID mocks base method. +func (m *MockTestSession) ID() uint32 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ID") + ret0, _ := ret[0].(uint32) + return ret0 +} + +// ID indicates an expected call of ID. +func (mr *MockTestSessionMockRecorder) ID() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ID", reflect.TypeOf((*MockTestSession)(nil).ID)) +} + +// IncReadPkgNum mocks base method. +func (m *MockTestSession) IncReadPkgNum() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "IncReadPkgNum") +} + +// IncReadPkgNum indicates an expected call of IncReadPkgNum. +func (mr *MockTestSessionMockRecorder) IncReadPkgNum() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IncReadPkgNum", reflect.TypeOf((*MockTestSession)(nil).IncReadPkgNum)) +} + +// IncWritePkgNum mocks base method. +func (m *MockTestSession) IncWritePkgNum() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "IncWritePkgNum") +} + +// IncWritePkgNum indicates an expected call of IncWritePkgNum. +func (mr *MockTestSessionMockRecorder) IncWritePkgNum() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IncWritePkgNum", reflect.TypeOf((*MockTestSession)(nil).IncWritePkgNum)) +} + +// IsClosed mocks base method. +func (m *MockTestSession) IsClosed() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "IsClosed") + ret0, _ := ret[0].(bool) + return ret0 +} + +// IsClosed indicates an expected call of IsClosed. +func (mr *MockTestSessionMockRecorder) IsClosed() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsClosed", reflect.TypeOf((*MockTestSession)(nil).IsClosed)) +} + +// LocalAddr mocks base method. +func (m *MockTestSession) LocalAddr() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "LocalAddr") + ret0, _ := ret[0].(string) + return ret0 +} + +// LocalAddr indicates an expected call of LocalAddr. +func (mr *MockTestSessionMockRecorder) LocalAddr() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LocalAddr", reflect.TypeOf((*MockTestSession)(nil).LocalAddr)) +} + +// ReadTimeout mocks base method. +func (m *MockTestSession) ReadTimeout() time.Duration { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReadTimeout") + ret0, _ := ret[0].(time.Duration) + return ret0 +} + +// ReadTimeout indicates an expected call of ReadTimeout. +func (mr *MockTestSessionMockRecorder) ReadTimeout() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReadTimeout", reflect.TypeOf((*MockTestSession)(nil).ReadTimeout)) +} + +// RemoteAddr mocks base method. +func (m *MockTestSession) RemoteAddr() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "RemoteAddr") + ret0, _ := ret[0].(string) + return ret0 +} + +// RemoteAddr indicates an expected call of RemoteAddr. +func (mr *MockTestSessionMockRecorder) RemoteAddr() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoteAddr", reflect.TypeOf((*MockTestSession)(nil).RemoteAddr)) +} + +// RemoveAttribute mocks base method. +func (m *MockTestSession) RemoveAttribute(arg0 interface{}) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "RemoveAttribute", arg0) +} + +// RemoveAttribute indicates an expected call of RemoveAttribute. +func (mr *MockTestSessionMockRecorder) RemoveAttribute(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveAttribute", reflect.TypeOf((*MockTestSession)(nil).RemoveAttribute), arg0) +} + +// Reset mocks base method. +func (m *MockTestSession) Reset() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Reset") +} + +// Reset indicates an expected call of Reset. +func (mr *MockTestSessionMockRecorder) Reset() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reset", reflect.TypeOf((*MockTestSession)(nil).Reset)) +} + +// Send mocks base method. +func (m *MockTestSession) Send(arg0 interface{}) (int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Send", arg0) + ret0, _ := ret[0].(int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Send indicates an expected call of Send. +func (mr *MockTestSessionMockRecorder) Send(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockTestSession)(nil).Send), arg0) +} + +// SetAttribute mocks base method. +func (m *MockTestSession) SetAttribute(arg0, arg1 interface{}) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetAttribute", arg0, arg1) +} + +// SetAttribute indicates an expected call of SetAttribute. +func (mr *MockTestSessionMockRecorder) SetAttribute(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAttribute", reflect.TypeOf((*MockTestSession)(nil).SetAttribute), arg0, arg1) +} + +// SetCompressType mocks base method. +func (m *MockTestSession) SetCompressType(arg0 getty.CompressType) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetCompressType", arg0) +} + +// SetCompressType indicates an expected call of SetCompressType. +func (mr *MockTestSessionMockRecorder) SetCompressType(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCompressType", reflect.TypeOf((*MockTestSession)(nil).SetCompressType), arg0) +} + +// SetCronPeriod mocks base method. +func (m *MockTestSession) SetCronPeriod(arg0 int) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetCronPeriod", arg0) +} + +// SetCronPeriod indicates an expected call of SetCronPeriod. +func (mr *MockTestSessionMockRecorder) SetCronPeriod(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetCronPeriod", reflect.TypeOf((*MockTestSession)(nil).SetCronPeriod), arg0) +} + +// SetEventListener mocks base method. +func (m *MockTestSession) SetEventListener(arg0 getty.EventListener) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetEventListener", arg0) +} + +// SetEventListener indicates an expected call of SetEventListener. +func (mr *MockTestSessionMockRecorder) SetEventListener(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetEventListener", reflect.TypeOf((*MockTestSession)(nil).SetEventListener), arg0) +} + +// SetMaxMsgLen mocks base method. +func (m *MockTestSession) SetMaxMsgLen(arg0 int) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetMaxMsgLen", arg0) +} + +// SetMaxMsgLen indicates an expected call of SetMaxMsgLen. +func (mr *MockTestSessionMockRecorder) SetMaxMsgLen(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetMaxMsgLen", reflect.TypeOf((*MockTestSession)(nil).SetMaxMsgLen), arg0) +} + +// SetName mocks base method. +func (m *MockTestSession) SetName(arg0 string) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetName", arg0) +} + +// SetName indicates an expected call of SetName. +func (mr *MockTestSessionMockRecorder) SetName(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetName", reflect.TypeOf((*MockTestSession)(nil).SetName), arg0) +} + +// SetPkgHandler mocks base method. +func (m *MockTestSession) SetPkgHandler(arg0 getty.ReadWriter) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetPkgHandler", arg0) +} + +// SetPkgHandler indicates an expected call of SetPkgHandler. +func (mr *MockTestSessionMockRecorder) SetPkgHandler(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetPkgHandler", reflect.TypeOf((*MockTestSession)(nil).SetPkgHandler), arg0) +} + +// SetReadTimeout mocks base method. +func (m *MockTestSession) SetReadTimeout(arg0 time.Duration) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetReadTimeout", arg0) +} + +// SetReadTimeout indicates an expected call of SetReadTimeout. +func (mr *MockTestSessionMockRecorder) SetReadTimeout(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetReadTimeout", reflect.TypeOf((*MockTestSession)(nil).SetReadTimeout), arg0) +} + +// SetReader mocks base method. +func (m *MockTestSession) SetReader(arg0 getty.Reader) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetReader", arg0) +} + +// SetReader indicates an expected call of SetReader. +func (mr *MockTestSessionMockRecorder) SetReader(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetReader", reflect.TypeOf((*MockTestSession)(nil).SetReader), arg0) +} + +// SetSession mocks base method. +func (m *MockTestSession) SetSession(arg0 getty.Session) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetSession", arg0) +} + +// SetSession indicates an expected call of SetSession. +func (mr *MockTestSessionMockRecorder) SetSession(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSession", reflect.TypeOf((*MockTestSession)(nil).SetSession), arg0) +} + +// SetWaitTime mocks base method. +func (m *MockTestSession) SetWaitTime(arg0 time.Duration) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetWaitTime", arg0) +} + +// SetWaitTime indicates an expected call of SetWaitTime. +func (mr *MockTestSessionMockRecorder) SetWaitTime(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetWaitTime", reflect.TypeOf((*MockTestSession)(nil).SetWaitTime), arg0) +} + +// SetWriteTimeout mocks base method. +func (m *MockTestSession) SetWriteTimeout(arg0 time.Duration) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetWriteTimeout", arg0) +} + +// SetWriteTimeout indicates an expected call of SetWriteTimeout. +func (mr *MockTestSessionMockRecorder) SetWriteTimeout(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetWriteTimeout", reflect.TypeOf((*MockTestSession)(nil).SetWriteTimeout), arg0) +} + +// SetWriter mocks base method. +func (m *MockTestSession) SetWriter(arg0 getty.Writer) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetWriter", arg0) +} + +// SetWriter indicates an expected call of SetWriter. +func (mr *MockTestSessionMockRecorder) SetWriter(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetWriter", reflect.TypeOf((*MockTestSession)(nil).SetWriter), arg0) +} + +// Stat mocks base method. +func (m *MockTestSession) Stat() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Stat") + ret0, _ := ret[0].(string) + return ret0 +} + +// Stat indicates an expected call of Stat. +func (mr *MockTestSessionMockRecorder) Stat() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stat", reflect.TypeOf((*MockTestSession)(nil).Stat)) +} + +// UpdateActive mocks base method. +func (m *MockTestSession) UpdateActive() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "UpdateActive") +} + +// UpdateActive indicates an expected call of UpdateActive. +func (mr *MockTestSessionMockRecorder) UpdateActive() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateActive", reflect.TypeOf((*MockTestSession)(nil).UpdateActive)) +} + +// WriteBytes mocks base method. +func (m *MockTestSession) WriteBytes(arg0 []byte) (int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WriteBytes", arg0) + ret0, _ := ret[0].(int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WriteBytes indicates an expected call of WriteBytes. +func (mr *MockTestSessionMockRecorder) WriteBytes(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteBytes", reflect.TypeOf((*MockTestSession)(nil).WriteBytes), arg0) +} + +// WriteBytesArray mocks base method. +func (m *MockTestSession) WriteBytesArray(arg0 ...[]byte) (int, error) { + m.ctrl.T.Helper() + varargs := []interface{}{} + for _, a := range arg0 { + varargs = append(varargs, a) + } + ret := m.ctrl.Call(m, "WriteBytesArray", varargs...) + ret0, _ := ret[0].(int) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// WriteBytesArray indicates an expected call of WriteBytesArray. +func (mr *MockTestSessionMockRecorder) WriteBytesArray(arg0 ...interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteBytesArray", reflect.TypeOf((*MockTestSession)(nil).WriteBytesArray), arg0...) +} + +// WritePkg mocks base method. +func (m *MockTestSession) WritePkg(pkg interface{}, timeout time.Duration) (int, int, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WritePkg", pkg, timeout) + ret0, _ := ret[0].(int) + ret1, _ := ret[1].(int) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// WritePkg indicates an expected call of WritePkg. +func (mr *MockTestSessionMockRecorder) WritePkg(pkg, timeout interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WritePkg", reflect.TypeOf((*MockTestSession)(nil).WritePkg), pkg, timeout) +} + +// WriteTimeout mocks base method. +func (m *MockTestSession) WriteTimeout() time.Duration { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WriteTimeout") + ret0, _ := ret[0].(time.Duration) + return ret0 +} + +// WriteTimeout indicates an expected call of WriteTimeout. +func (mr *MockTestSessionMockRecorder) WriteTimeout() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteTimeout", reflect.TypeOf((*MockTestSession)(nil).WriteTimeout)) +} diff --git a/pkg/remoting/mock/test_getty_session.go b/pkg/remoting/mock/test_getty_session.go new file mode 100644 index 000000000..510d7f002 --- /dev/null +++ b/pkg/remoting/mock/test_getty_session.go @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package mock + +import getty "github.com/apache/dubbo-getty" + +type TestSession interface { + getty.Session +}