[#85] pool: make client interface methods private

Signed-off-by: Denis Kirillov <denis@nspcc.ru>
This commit is contained in:
Denis Kirillov 2022-03-28 12:17:56 +03:00 committed by LeL
parent aa6a4950d5
commit 9e8e12f6ae
4 changed files with 221 additions and 222 deletions

View file

@ -1,5 +1,5 @@
// Code generated by MockGen. DO NOT EDIT.
// Source: github.com/nspcc-dev/neofs-sdk-go/pool (interfaces: Client)
// Source: pool.go
// Package pool is a generated GoMock package.
package pool
@ -18,7 +18,7 @@ import (
id0 "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
// MockClient is a mock of Client interface.
// MockClient is a mock of client interface.
type MockClient struct {
ctrl *gomock.Controller
recorder *MockClientMockRecorder
@ -41,239 +41,239 @@ func (m *MockClient) EXPECT() *MockClientMockRecorder {
return m.recorder
}
// BalanceGet mocks base method.
func (m *MockClient) BalanceGet(arg0 context.Context, arg1 PrmBalanceGet) (*accounting.Decimal, error) {
// balanceGet mocks base method.
func (m *MockClient) balanceGet(arg0 context.Context, arg1 PrmBalanceGet) (*accounting.Decimal, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "BalanceGet", arg0, arg1)
ret := m.ctrl.Call(m, "balanceGet", arg0, arg1)
ret0, _ := ret[0].(*accounting.Decimal)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// BalanceGet indicates an expected call of BalanceGet.
func (mr *MockClientMockRecorder) BalanceGet(arg0, arg1 interface{}) *gomock.Call {
// balanceGet indicates an expected call of balanceGet.
func (mr *MockClientMockRecorder) balanceGet(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "BalanceGet", reflect.TypeOf((*MockClient)(nil).BalanceGet), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "balanceGet", reflect.TypeOf((*MockClient)(nil).balanceGet), arg0, arg1)
}
// ContainerDelete mocks base method.
func (m *MockClient) ContainerDelete(arg0 context.Context, arg1 PrmContainerDelete) error {
// containerDelete mocks base method.
func (m *MockClient) containerDelete(arg0 context.Context, arg1 PrmContainerDelete) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ContainerDelete", arg0, arg1)
ret := m.ctrl.Call(m, "containerDelete", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// ContainerDelete indicates an expected call of ContainerDelete.
func (mr *MockClientMockRecorder) ContainerDelete(arg0, arg1 interface{}) *gomock.Call {
// containerDelete indicates an expected call of containerDelete.
func (mr *MockClientMockRecorder) containerDelete(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerDelete", reflect.TypeOf((*MockClient)(nil).ContainerDelete), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "containerDelete", reflect.TypeOf((*MockClient)(nil).containerDelete), arg0, arg1)
}
// ContainerEACL mocks base method.
func (m *MockClient) ContainerEACL(arg0 context.Context, arg1 PrmContainerEACL) (*eacl.Table, error) {
// containerEACL mocks base method.
func (m *MockClient) containerEACL(arg0 context.Context, arg1 PrmContainerEACL) (*eacl.Table, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ContainerEACL", arg0, arg1)
ret := m.ctrl.Call(m, "containerEACL", arg0, arg1)
ret0, _ := ret[0].(*eacl.Table)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ContainerEACL indicates an expected call of ContainerEACL.
func (mr *MockClientMockRecorder) ContainerEACL(arg0, arg1 interface{}) *gomock.Call {
// containerEACL indicates an expected call of containerEACL.
func (mr *MockClientMockRecorder) containerEACL(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerEACL", reflect.TypeOf((*MockClient)(nil).ContainerEACL), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "containerEACL", reflect.TypeOf((*MockClient)(nil).containerEACL), arg0, arg1)
}
// ContainerGet mocks base method.
func (m *MockClient) ContainerGet(arg0 context.Context, arg1 PrmContainerGet) (*container.Container, error) {
// containerGet mocks base method.
func (m *MockClient) containerGet(arg0 context.Context, arg1 PrmContainerGet) (*container.Container, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ContainerGet", arg0, arg1)
ret := m.ctrl.Call(m, "containerGet", arg0, arg1)
ret0, _ := ret[0].(*container.Container)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ContainerGet indicates an expected call of ContainerGet.
func (mr *MockClientMockRecorder) ContainerGet(arg0, arg1 interface{}) *gomock.Call {
// containerGet indicates an expected call of containerGet.
func (mr *MockClientMockRecorder) containerGet(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerGet", reflect.TypeOf((*MockClient)(nil).ContainerGet), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "containerGet", reflect.TypeOf((*MockClient)(nil).containerGet), arg0, arg1)
}
// ContainerList mocks base method.
func (m *MockClient) ContainerList(arg0 context.Context, arg1 PrmContainerList) ([]id.ID, error) {
// containerList mocks base method.
func (m *MockClient) containerList(arg0 context.Context, arg1 PrmContainerList) ([]id.ID, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ContainerList", arg0, arg1)
ret := m.ctrl.Call(m, "containerList", arg0, arg1)
ret0, _ := ret[0].([]id.ID)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ContainerList indicates an expected call of ContainerList.
func (mr *MockClientMockRecorder) ContainerList(arg0, arg1 interface{}) *gomock.Call {
// containerList indicates an expected call of containerList.
func (mr *MockClientMockRecorder) containerList(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerList", reflect.TypeOf((*MockClient)(nil).ContainerList), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "containerList", reflect.TypeOf((*MockClient)(nil).containerList), arg0, arg1)
}
// ContainerPut mocks base method.
func (m *MockClient) ContainerPut(arg0 context.Context, arg1 PrmContainerPut) (*id.ID, error) {
// containerPut mocks base method.
func (m *MockClient) containerPut(arg0 context.Context, arg1 PrmContainerPut) (*id.ID, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ContainerPut", arg0, arg1)
ret := m.ctrl.Call(m, "containerPut", arg0, arg1)
ret0, _ := ret[0].(*id.ID)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ContainerPut indicates an expected call of ContainerPut.
func (mr *MockClientMockRecorder) ContainerPut(arg0, arg1 interface{}) *gomock.Call {
// containerPut indicates an expected call of containerPut.
func (mr *MockClientMockRecorder) containerPut(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerPut", reflect.TypeOf((*MockClient)(nil).ContainerPut), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "containerPut", reflect.TypeOf((*MockClient)(nil).containerPut), arg0, arg1)
}
// ContainerSetEACL mocks base method.
func (m *MockClient) ContainerSetEACL(arg0 context.Context, arg1 PrmContainerSetEACL) error {
// containerSetEACL mocks base method.
func (m *MockClient) containerSetEACL(arg0 context.Context, arg1 PrmContainerSetEACL) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ContainerSetEACL", arg0, arg1)
ret := m.ctrl.Call(m, "containerSetEACL", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// ContainerSetEACL indicates an expected call of ContainerSetEACL.
func (mr *MockClientMockRecorder) ContainerSetEACL(arg0, arg1 interface{}) *gomock.Call {
// containerSetEACL indicates an expected call of containerSetEACL.
func (mr *MockClientMockRecorder) containerSetEACL(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ContainerSetEACL", reflect.TypeOf((*MockClient)(nil).ContainerSetEACL), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "containerSetEACL", reflect.TypeOf((*MockClient)(nil).containerSetEACL), arg0, arg1)
}
// EndpointInfo mocks base method.
func (m *MockClient) EndpointInfo(arg0 context.Context, arg1 PrmEndpointInfo) (*netmap.NodeInfo, error) {
// endpointInfo mocks base method.
func (m *MockClient) endpointInfo(arg0 context.Context, arg1 prmEndpointInfo) (*netmap.NodeInfo, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EndpointInfo", arg0, arg1)
ret := m.ctrl.Call(m, "endpointInfo", arg0, arg1)
ret0, _ := ret[0].(*netmap.NodeInfo)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// EndpointInfo indicates an expected call of EndpointInfo.
func (mr *MockClientMockRecorder) EndpointInfo(arg0, arg1 interface{}) *gomock.Call {
// endpointInfo indicates an expected call of endpointInfo.
func (mr *MockClientMockRecorder) endpointInfo(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EndpointInfo", reflect.TypeOf((*MockClient)(nil).EndpointInfo), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "endpointInfo", reflect.TypeOf((*MockClient)(nil).endpointInfo), arg0, arg1)
}
// NetworkInfo mocks base method.
func (m *MockClient) NetworkInfo(arg0 context.Context, arg1 PrmNetworkInfo) (*netmap.NetworkInfo, error) {
// networkInfo mocks base method.
func (m *MockClient) networkInfo(arg0 context.Context, arg1 prmNetworkInfo) (*netmap.NetworkInfo, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "NetworkInfo", arg0, arg1)
ret := m.ctrl.Call(m, "networkInfo", arg0, arg1)
ret0, _ := ret[0].(*netmap.NetworkInfo)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// NetworkInfo indicates an expected call of NetworkInfo.
func (mr *MockClientMockRecorder) NetworkInfo(arg0, arg1 interface{}) *gomock.Call {
// networkInfo indicates an expected call of networkInfo.
func (mr *MockClientMockRecorder) networkInfo(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NetworkInfo", reflect.TypeOf((*MockClient)(nil).NetworkInfo), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "networkInfo", reflect.TypeOf((*MockClient)(nil).networkInfo), arg0, arg1)
}
// ObjectDelete mocks base method.
func (m *MockClient) ObjectDelete(arg0 context.Context, arg1 PrmObjectDelete) error {
// objectDelete mocks base method.
func (m *MockClient) objectDelete(arg0 context.Context, arg1 PrmObjectDelete) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ObjectDelete", arg0, arg1)
ret := m.ctrl.Call(m, "objectDelete", arg0, arg1)
ret0, _ := ret[0].(error)
return ret0
}
// ObjectDelete indicates an expected call of ObjectDelete.
func (mr *MockClientMockRecorder) ObjectDelete(arg0, arg1 interface{}) *gomock.Call {
// objectDelete indicates an expected call of objectDelete.
func (mr *MockClientMockRecorder) objectDelete(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectDelete", reflect.TypeOf((*MockClient)(nil).ObjectDelete), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "objectDelete", reflect.TypeOf((*MockClient)(nil).objectDelete), arg0, arg1)
}
// ObjectGet mocks base method.
func (m *MockClient) ObjectGet(arg0 context.Context, arg1 PrmObjectGet) (*ResGetObject, error) {
// objectGet mocks base method.
func (m *MockClient) objectGet(arg0 context.Context, arg1 PrmObjectGet) (*ResGetObject, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ObjectGet", arg0, arg1)
ret := m.ctrl.Call(m, "objectGet", arg0, arg1)
ret0, _ := ret[0].(*ResGetObject)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ObjectGet indicates an expected call of ObjectGet.
func (mr *MockClientMockRecorder) ObjectGet(arg0, arg1 interface{}) *gomock.Call {
// objectGet indicates an expected call of objectGet.
func (mr *MockClientMockRecorder) objectGet(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectGet", reflect.TypeOf((*MockClient)(nil).ObjectGet), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "objectGet", reflect.TypeOf((*MockClient)(nil).objectGet), arg0, arg1)
}
// ObjectHead mocks base method.
func (m *MockClient) ObjectHead(arg0 context.Context, arg1 PrmObjectHead) (*object.Object, error) {
// objectHead mocks base method.
func (m *MockClient) objectHead(arg0 context.Context, arg1 PrmObjectHead) (*object.Object, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ObjectHead", arg0, arg1)
ret := m.ctrl.Call(m, "objectHead", arg0, arg1)
ret0, _ := ret[0].(*object.Object)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ObjectHead indicates an expected call of ObjectHead.
func (mr *MockClientMockRecorder) ObjectHead(arg0, arg1 interface{}) *gomock.Call {
// objectHead indicates an expected call of objectHead.
func (mr *MockClientMockRecorder) objectHead(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectHead", reflect.TypeOf((*MockClient)(nil).ObjectHead), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "objectHead", reflect.TypeOf((*MockClient)(nil).objectHead), arg0, arg1)
}
// ObjectPut mocks base method.
func (m *MockClient) ObjectPut(arg0 context.Context, arg1 PrmObjectPut) (*id0.ID, error) {
// objectPut mocks base method.
func (m *MockClient) objectPut(arg0 context.Context, arg1 PrmObjectPut) (*id0.ID, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ObjectPut", arg0, arg1)
ret := m.ctrl.Call(m, "objectPut", arg0, arg1)
ret0, _ := ret[0].(*id0.ID)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ObjectPut indicates an expected call of ObjectPut.
func (mr *MockClientMockRecorder) ObjectPut(arg0, arg1 interface{}) *gomock.Call {
// objectPut indicates an expected call of objectPut.
func (mr *MockClientMockRecorder) objectPut(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectPut", reflect.TypeOf((*MockClient)(nil).ObjectPut), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "objectPut", reflect.TypeOf((*MockClient)(nil).objectPut), arg0, arg1)
}
// ObjectRange mocks base method.
func (m *MockClient) ObjectRange(arg0 context.Context, arg1 PrmObjectRange) (*ResObjectRange, error) {
// objectRange mocks base method.
func (m *MockClient) objectRange(arg0 context.Context, arg1 PrmObjectRange) (*ResObjectRange, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ObjectRange", arg0, arg1)
ret := m.ctrl.Call(m, "objectRange", arg0, arg1)
ret0, _ := ret[0].(*ResObjectRange)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ObjectRange indicates an expected call of ObjectRange.
func (mr *MockClientMockRecorder) ObjectRange(arg0, arg1 interface{}) *gomock.Call {
// objectRange indicates an expected call of objectRange.
func (mr *MockClientMockRecorder) objectRange(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectRange", reflect.TypeOf((*MockClient)(nil).ObjectRange), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "objectRange", reflect.TypeOf((*MockClient)(nil).objectRange), arg0, arg1)
}
// ObjectSearch mocks base method.
func (m *MockClient) ObjectSearch(arg0 context.Context, arg1 PrmObjectSearch) (*ResObjectSearch, error) {
// objectSearch mocks base method.
func (m *MockClient) objectSearch(arg0 context.Context, arg1 PrmObjectSearch) (*ResObjectSearch, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ObjectSearch", arg0, arg1)
ret := m.ctrl.Call(m, "objectSearch", arg0, arg1)
ret0, _ := ret[0].(*ResObjectSearch)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// ObjectSearch indicates an expected call of ObjectSearch.
func (mr *MockClientMockRecorder) ObjectSearch(arg0, arg1 interface{}) *gomock.Call {
// objectSearch indicates an expected call of objectSearch.
func (mr *MockClientMockRecorder) objectSearch(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ObjectSearch", reflect.TypeOf((*MockClient)(nil).ObjectSearch), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "objectSearch", reflect.TypeOf((*MockClient)(nil).objectSearch), arg0, arg1)
}
// SessionCreate mocks base method.
func (m *MockClient) SessionCreate(arg0 context.Context, arg1 PrmCreateSession) (*ResCreateSession, error) {
// sessionCreate mocks base method.
func (m *MockClient) sessionCreate(arg0 context.Context, arg1 prmCreateSession) (*resCreateSession, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SessionCreate", arg0, arg1)
ret0, _ := ret[0].(*ResCreateSession)
ret := m.ctrl.Call(m, "sessionCreate", arg0, arg1)
ret0, _ := ret[0].(*resCreateSession)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// SessionCreate indicates an expected call of SessionCreate.
func (mr *MockClientMockRecorder) SessionCreate(arg0, arg1 interface{}) *gomock.Call {
// sessionCreate indicates an expected call of sessionCreate.
func (mr *MockClientMockRecorder) sessionCreate(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SessionCreate", reflect.TypeOf((*MockClient)(nil).SessionCreate), arg0, arg1)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "sessionCreate", reflect.TypeOf((*MockClient)(nil).sessionCreate), arg0, arg1)
}

View file

@ -33,22 +33,22 @@ import (
// client represents virtual connection to the single NeoFS network endpoint from which Pool is formed.
type client interface {
BalanceGet(context.Context, PrmBalanceGet) (*accounting.Decimal, error)
ContainerPut(context.Context, PrmContainerPut) (*cid.ID, error)
ContainerGet(context.Context, PrmContainerGet) (*container.Container, error)
ContainerList(context.Context, PrmContainerList) ([]cid.ID, error)
ContainerDelete(context.Context, PrmContainerDelete) error
ContainerEACL(context.Context, PrmContainerEACL) (*eacl.Table, error)
ContainerSetEACL(context.Context, PrmContainerSetEACL) error
EndpointInfo(context.Context, PrmEndpointInfo) (*netmap.NodeInfo, error)
NetworkInfo(context.Context, PrmNetworkInfo) (*netmap.NetworkInfo, error)
ObjectPut(context.Context, PrmObjectPut) (*oid.ID, error)
ObjectDelete(context.Context, PrmObjectDelete) error
ObjectGet(context.Context, PrmObjectGet) (*ResGetObject, error)
ObjectHead(context.Context, PrmObjectHead) (*object.Object, error)
ObjectRange(context.Context, PrmObjectRange) (*ResObjectRange, error)
ObjectSearch(context.Context, PrmObjectSearch) (*ResObjectSearch, error)
SessionCreate(context.Context, PrmCreateSession) (*ResCreateSession, error)
balanceGet(context.Context, PrmBalanceGet) (*accounting.Decimal, error)
containerPut(context.Context, PrmContainerPut) (*cid.ID, error)
containerGet(context.Context, PrmContainerGet) (*container.Container, error)
containerList(context.Context, PrmContainerList) ([]cid.ID, error)
containerDelete(context.Context, PrmContainerDelete) error
containerEACL(context.Context, PrmContainerEACL) (*eacl.Table, error)
containerSetEACL(context.Context, PrmContainerSetEACL) error
endpointInfo(context.Context, prmEndpointInfo) (*netmap.NodeInfo, error)
networkInfo(context.Context, prmNetworkInfo) (*netmap.NetworkInfo, error)
objectPut(context.Context, PrmObjectPut) (*oid.ID, error)
objectDelete(context.Context, PrmObjectDelete) error
objectGet(context.Context, PrmObjectGet) (*ResGetObject, error)
objectHead(context.Context, PrmObjectHead) (*object.Object, error)
objectRange(context.Context, PrmObjectRange) (*ResObjectRange, error)
objectSearch(context.Context, PrmObjectSearch) (*ResObjectSearch, error)
sessionCreate(context.Context, prmCreateSession) (*resCreateSession, error)
}
// clientWrapper is used by default, alternative implementations are intended for testing purposes only.
@ -96,7 +96,7 @@ func newWrapper(prm wrapperPrm) (*clientWrapper, error) {
return &clientWrapper{client: &c, key: prm.key}, c.Dial(prmDial)
}
func (c *clientWrapper) BalanceGet(ctx context.Context, prm PrmBalanceGet) (*accounting.Decimal, error) {
func (c *clientWrapper) balanceGet(ctx context.Context, prm PrmBalanceGet) (*accounting.Decimal, error) {
var cliPrm sdkClient.PrmBalanceGet
cliPrm.SetAccount(prm.ownerID)
@ -107,7 +107,7 @@ func (c *clientWrapper) BalanceGet(ctx context.Context, prm PrmBalanceGet) (*acc
return res.Amount(), nil
}
func (c *clientWrapper) ContainerPut(ctx context.Context, prm PrmContainerPut) (*cid.ID, error) {
func (c *clientWrapper) containerPut(ctx context.Context, prm PrmContainerPut) (*cid.ID, error) {
var cliPrm sdkClient.PrmContainerPut
cliPrm.SetContainer(prm.cnr)
@ -123,7 +123,7 @@ func (c *clientWrapper) ContainerPut(ctx context.Context, prm PrmContainerPut) (
return res.ID(), waitForContainerPresence(ctx, c, res.ID(), &prm.waitParams)
}
func (c *clientWrapper) ContainerGet(ctx context.Context, prm PrmContainerGet) (*container.Container, error) {
func (c *clientWrapper) containerGet(ctx context.Context, prm PrmContainerGet) (*container.Container, error) {
var cliPrm sdkClient.PrmContainerGet
cliPrm.SetContainer(prm.cnrID)
@ -134,7 +134,7 @@ func (c *clientWrapper) ContainerGet(ctx context.Context, prm PrmContainerGet) (
return res.Container(), nil
}
func (c *clientWrapper) ContainerList(ctx context.Context, prm PrmContainerList) ([]cid.ID, error) {
func (c *clientWrapper) containerList(ctx context.Context, prm PrmContainerList) ([]cid.ID, error) {
var cliPrm sdkClient.PrmContainerList
cliPrm.SetAccount(prm.ownerID)
@ -145,7 +145,7 @@ func (c *clientWrapper) ContainerList(ctx context.Context, prm PrmContainerList)
return res.Containers(), nil
}
func (c *clientWrapper) ContainerDelete(ctx context.Context, prm PrmContainerDelete) error {
func (c *clientWrapper) containerDelete(ctx context.Context, prm PrmContainerDelete) error {
var cliPrm sdkClient.PrmContainerDelete
cliPrm.SetContainer(prm.cnrID)
cliPrm.SetSessionToken(prm.stoken)
@ -161,7 +161,7 @@ func (c *clientWrapper) ContainerDelete(ctx context.Context, prm PrmContainerDel
return waitForContainerRemoved(ctx, c, &prm.cnrID, &prm.waitParams)
}
func (c *clientWrapper) ContainerEACL(ctx context.Context, prm PrmContainerEACL) (*eacl.Table, error) {
func (c *clientWrapper) containerEACL(ctx context.Context, prm PrmContainerEACL) (*eacl.Table, error) {
var cliPrm sdkClient.PrmContainerEACL
cliPrm.SetContainer(prm.cnrID)
@ -172,7 +172,7 @@ func (c *clientWrapper) ContainerEACL(ctx context.Context, prm PrmContainerEACL)
return res.Table(), nil
}
func (c *clientWrapper) ContainerSetEACL(ctx context.Context, prm PrmContainerSetEACL) error {
func (c *clientWrapper) containerSetEACL(ctx context.Context, prm PrmContainerSetEACL) error {
var cliPrm sdkClient.PrmContainerSetEACL
cliPrm.SetTable(prm.table)
@ -187,7 +187,7 @@ func (c *clientWrapper) ContainerSetEACL(ctx context.Context, prm PrmContainerSe
return waitForEACLPresence(ctx, c, prm.table.CID(), &prm.table, &prm.waitParams)
}
func (c *clientWrapper) EndpointInfo(ctx context.Context, _ PrmEndpointInfo) (*netmap.NodeInfo, error) {
func (c *clientWrapper) endpointInfo(ctx context.Context, _ prmEndpointInfo) (*netmap.NodeInfo, error) {
res, err := c.client.EndpointInfo(ctx, sdkClient.PrmEndpointInfo{})
if err != nil {
return nil, err
@ -195,7 +195,7 @@ func (c *clientWrapper) EndpointInfo(ctx context.Context, _ PrmEndpointInfo) (*n
return res.NodeInfo(), nil
}
func (c *clientWrapper) NetworkInfo(ctx context.Context, _ PrmNetworkInfo) (*netmap.NetworkInfo, error) {
func (c *clientWrapper) networkInfo(ctx context.Context, _ prmNetworkInfo) (*netmap.NetworkInfo, error) {
res, err := c.client.NetworkInfo(ctx, sdkClient.PrmNetworkInfo{})
if err != nil {
return nil, err
@ -203,7 +203,7 @@ func (c *clientWrapper) NetworkInfo(ctx context.Context, _ PrmNetworkInfo) (*net
return res.Info(), nil
}
func (c *clientWrapper) ObjectPut(ctx context.Context, prm PrmObjectPut) (*oid.ID, error) {
func (c *clientWrapper) objectPut(ctx context.Context, prm PrmObjectPut) (*oid.ID, error) {
var cliPrm sdkClient.PrmObjectPutInit
wObj, err := c.client.ObjectPutInit(ctx, cliPrm)
if err != nil {
@ -275,7 +275,7 @@ func (c *clientWrapper) ObjectPut(ctx context.Context, prm PrmObjectPut) (*oid.I
return &id, nil
}
func (c *clientWrapper) ObjectDelete(ctx context.Context, prm PrmObjectDelete) error {
func (c *clientWrapper) objectDelete(ctx context.Context, prm PrmObjectDelete) error {
var cliPrm sdkClient.PrmObjectDelete
if cnr := prm.addr.ContainerID(); cnr != nil {
@ -299,7 +299,7 @@ func (c *clientWrapper) ObjectDelete(ctx context.Context, prm PrmObjectDelete) e
return err
}
func (c *clientWrapper) ObjectGet(ctx context.Context, prm PrmObjectGet) (*ResGetObject, error) {
func (c *clientWrapper) objectGet(ctx context.Context, prm PrmObjectGet) (*ResGetObject, error) {
var cliPrm sdkClient.PrmObjectGet
if cnr := prm.addr.ContainerID(); cnr != nil {
@ -345,7 +345,7 @@ func (c *clientWrapper) ObjectGet(ctx context.Context, prm PrmObjectGet) (*ResGe
return &res, nil
}
func (c *clientWrapper) ObjectHead(ctx context.Context, prm PrmObjectHead) (*object.Object, error) {
func (c *clientWrapper) objectHead(ctx context.Context, prm PrmObjectHead) (*object.Object, error) {
var cliPrm sdkClient.PrmObjectHead
if cnr := prm.addr.ContainerID(); cnr != nil {
@ -379,7 +379,7 @@ func (c *clientWrapper) ObjectHead(ctx context.Context, prm PrmObjectHead) (*obj
return &obj, nil
}
func (c *clientWrapper) ObjectRange(ctx context.Context, prm PrmObjectRange) (*ResObjectRange, error) {
func (c *clientWrapper) objectRange(ctx context.Context, prm PrmObjectRange) (*ResObjectRange, error) {
var cliPrm sdkClient.PrmObjectRange
cliPrm.SetOffset(prm.off)
@ -410,7 +410,7 @@ func (c *clientWrapper) ObjectRange(ctx context.Context, prm PrmObjectRange) (*R
return &ResObjectRange{payload: res}, nil
}
func (c *clientWrapper) ObjectSearch(ctx context.Context, prm PrmObjectSearch) (*ResObjectSearch, error) {
func (c *clientWrapper) objectSearch(ctx context.Context, prm PrmObjectSearch) (*ResObjectSearch, error) {
var cliPrm sdkClient.PrmObjectSearch
cliPrm.InContainer(prm.cnrID)
@ -433,7 +433,7 @@ func (c *clientWrapper) ObjectSearch(ctx context.Context, prm PrmObjectSearch) (
return &ResObjectSearch{r: res}, nil
}
func (c *clientWrapper) SessionCreate(ctx context.Context, prm PrmCreateSession) (*ResCreateSession, error) {
func (c *clientWrapper) sessionCreate(ctx context.Context, prm prmCreateSession) (*resCreateSession, error) {
var cliPrm sdkClient.PrmSessionCreate
cliPrm.SetExp(prm.exp)
@ -442,7 +442,7 @@ func (c *clientWrapper) SessionCreate(ctx context.Context, prm PrmCreateSession)
return nil, fmt.Errorf("session creation on client: %w", err)
}
return &ResCreateSession{
return &resCreateSession{
id: res.ID(),
sessionKey: res.PublicKey(),
}, nil
@ -828,23 +828,24 @@ func (x *PrmBalanceGet) SetOwnerID(ownerID owner.ID) {
x.ownerID = ownerID
}
type PrmCreateSession struct {
// prmEndpointInfo groups parameters of sessionCreate operation.
type prmCreateSession struct {
exp uint64
}
// SetExp sets number of the last NeoFS epoch in the lifetime of the session after which it will be expired.
func (x *PrmCreateSession) SetExp(exp uint64) {
func (x *prmCreateSession) SetExp(exp uint64) {
x.exp = exp
}
// PrmEndpointInfo groups parameters of EndpointInfo operation.
type PrmEndpointInfo struct{}
// prmEndpointInfo groups parameters of endpointInfo operation.
type prmEndpointInfo struct{}
// PrmNetworkInfo groups parameters of NetworkInfo operation.
type PrmNetworkInfo struct{}
// prmNetworkInfo groups parameters of networkInfo operation.
type prmNetworkInfo struct{}
// ResCreateSession groups resulting values of SessionCreate operation.
type ResCreateSession struct {
// resCreateSession groups resulting values of sessionCreate operation.
type resCreateSession struct {
id []byte
sessionKey []byte
@ -1086,7 +1087,7 @@ func (p *Pool) updateInnerNodesHealth(ctx context.Context, i int, bufferWeights
healthyChanged := false
wg := sync.WaitGroup{}
var prmEndpoint PrmEndpointInfo
var prmEndpoint prmEndpointInfo
for j, cPack := range pool.clientPacks {
wg.Add(1)
@ -1096,7 +1097,7 @@ func (p *Pool) updateInnerNodesHealth(ctx context.Context, i int, bufferWeights
tctx, c := context.WithTimeout(ctx, options.nodeRequestTimeout)
defer c()
if _, err := cli.EndpointInfo(tctx, prmEndpoint); err != nil {
if _, err := cli.endpointInfo(tctx, prmEndpoint); err != nil {
ok = false
bufferWeights[j] = 0
}
@ -1200,7 +1201,7 @@ func (p *Pool) checkSessionTokenErr(err error, address string) bool {
}
func createSessionTokenForDuration(ctx context.Context, c client, ownerID *owner.ID, dur uint64) (*session.Token, error) {
ni, err := c.NetworkInfo(ctx, PrmNetworkInfo{})
ni, err := c.networkInfo(ctx, prmNetworkInfo{})
if err != nil {
return nil, err
}
@ -1213,10 +1214,10 @@ func createSessionTokenForDuration(ctx context.Context, c client, ownerID *owner
} else {
exp = epoch + dur
}
var prm PrmCreateSession
var prm prmCreateSession
prm.SetExp(exp)
res, err := c.SessionCreate(ctx, prm)
res, err := c.sessionCreate(ctx, prm)
if err != nil {
return nil, err
}
@ -1338,14 +1339,13 @@ func (p *Pool) PutObject(ctx context.Context, prm PrmObjectPut) (*oid.ID, error)
if ctxCall.sessionDefault {
ctxCall.sessionTarget = prm.UseSession
err = p.openDefaultSession(&ctxCall)
if err != nil {
if err := p.openDefaultSession(&ctxCall); err != nil {
return nil, fmt.Errorf("open default session: %w", err)
}
}
prm.key = ctxCall.key
id, err := ctxCall.client.ObjectPut(ctx, prm)
id, err := ctxCall.client.objectPut(ctx, prm)
if err != nil {
// removes session token from cache in case of token error
p.checkSessionTokenErr(err, ctxCall.endpoint)
@ -1376,7 +1376,7 @@ func (p *Pool) DeleteObject(ctx context.Context, prm PrmObjectDelete) error {
}
return p.call(&cc, func() error {
if err = cc.client.ObjectDelete(ctx, prm); err != nil {
if err = cc.client.objectDelete(ctx, prm); err != nil {
return fmt.Errorf("remove object via client: %w", err)
}
@ -1422,7 +1422,7 @@ func (p *Pool) GetObject(ctx context.Context, prm PrmObjectGet) (*ResGetObject,
var res *ResGetObject
return res, p.call(&cc, func() error {
res, err = cc.client.ObjectGet(ctx, prm)
res, err = cc.client.objectGet(ctx, prm)
return err
})
}
@ -1446,7 +1446,7 @@ func (p *Pool) HeadObject(ctx context.Context, prm PrmObjectHead) (*object.Objec
var obj *object.Object
return obj, p.call(&cc, func() error {
obj, err = cc.client.ObjectHead(ctx, prm)
obj, err = cc.client.objectHead(ctx, prm)
return err
})
}
@ -1492,7 +1492,7 @@ func (p *Pool) ObjectRange(ctx context.Context, prm PrmObjectRange) (*ResObjectR
var res *ResObjectRange
return res, p.call(&cc, func() error {
res, err = cc.client.ObjectRange(ctx, prm)
res, err = cc.client.objectRange(ctx, prm)
return err
})
}
@ -1557,7 +1557,7 @@ func (p *Pool) SearchObjects(ctx context.Context, prm PrmObjectSearch) (*ResObje
var res *ResObjectSearch
return res, p.call(&cc, func() error {
res, err = cc.client.ObjectSearch(ctx, prm)
res, err = cc.client.objectSearch(ctx, prm)
return err
})
}
@ -1575,7 +1575,7 @@ func (p *Pool) PutContainer(ctx context.Context, prm PrmContainerPut) (*cid.ID,
return nil, err
}
return cp.client.ContainerPut(ctx, prm)
return cp.client.containerPut(ctx, prm)
}
// GetContainer reads NeoFS container by ID.
@ -1585,7 +1585,7 @@ func (p *Pool) GetContainer(ctx context.Context, prm PrmContainerGet) (*containe
return nil, err
}
return cp.client.ContainerGet(ctx, prm)
return cp.client.containerGet(ctx, prm)
}
// ListContainers requests identifiers of the account-owned containers.
@ -1595,7 +1595,7 @@ func (p *Pool) ListContainers(ctx context.Context, prm PrmContainerList) ([]cid.
return nil, err
}
return cp.client.ContainerList(ctx, prm)
return cp.client.containerList(ctx, prm)
}
// DeleteContainer sends request to remove the NeoFS container and waits for the operation to complete.
@ -1611,7 +1611,7 @@ func (p *Pool) DeleteContainer(ctx context.Context, prm PrmContainerDelete) erro
return err
}
return cp.client.ContainerDelete(ctx, prm)
return cp.client.containerDelete(ctx, prm)
}
// GetEACL reads eACL table of the NeoFS container.
@ -1621,7 +1621,7 @@ func (p *Pool) GetEACL(ctx context.Context, prm PrmContainerEACL) (*eacl.Table,
return nil, err
}
return cp.client.ContainerEACL(ctx, prm)
return cp.client.containerEACL(ctx, prm)
}
// SetEACL sends request to update eACL table of the NeoFS container and waits for the operation to complete.
@ -1637,7 +1637,7 @@ func (p *Pool) SetEACL(ctx context.Context, prm PrmContainerSetEACL) error {
return err
}
return cp.client.ContainerSetEACL(ctx, prm)
return cp.client.containerSetEACL(ctx, prm)
}
// Balance requests current balance of the NeoFS account.
@ -1647,7 +1647,7 @@ func (p *Pool) Balance(ctx context.Context, prm PrmBalanceGet) (*accounting.Deci
return nil, err
}
return cp.client.BalanceGet(ctx, prm)
return cp.client.balanceGet(ctx, prm)
}
// waitForContainerPresence waits until the container is found on the NeoFS network.
@ -1658,7 +1658,7 @@ func waitForContainerPresence(ctx context.Context, cli client, cnrID *cid.ID, wa
}
return waitFor(ctx, waitParams, func(ctx context.Context) bool {
_, err := cli.ContainerGet(ctx, prm)
_, err := cli.containerGet(ctx, prm)
return err == nil
})
}
@ -1671,7 +1671,7 @@ func waitForEACLPresence(ctx context.Context, cli client, cnrID *cid.ID, table *
}
return waitFor(ctx, waitParams, func(ctx context.Context) bool {
eaclTable, err := cli.ContainerEACL(ctx, prm)
eaclTable, err := cli.containerEACL(ctx, prm)
if err == nil {
return eacl.EqualTables(*table, *eaclTable)
}
@ -1687,7 +1687,7 @@ func waitForContainerRemoved(ctx context.Context, cli client, cnrID *cid.ID, wai
}
return waitFor(ctx, waitParams, func(ctx context.Context) bool {
_, err := cli.ContainerGet(ctx, prm)
_, err := cli.containerGet(ctx, prm)
return sdkClient.IsErrContainerNotFound(err)
})
}
@ -1722,7 +1722,7 @@ func (p *Pool) NetworkInfo(ctx context.Context) (*netmap.NetworkInfo, error) {
return nil, err
}
return cp.client.NetworkInfo(ctx, PrmNetworkInfo{})
return cp.client.networkInfo(ctx, prmNetworkInfo{})
}
// Close closes the Pool and releases all the associated resources.
@ -1732,7 +1732,7 @@ func (p *Pool) Close() {
}
// creates new session token with specified owner from SessionCreate call result.
func sessionTokenForOwner(id *owner.ID, cliRes *ResCreateSession, exp uint64) *session.Token {
func sessionTokenForOwner(id *owner.ID, cliRes *resCreateSession, exp uint64) *session.Token {
st := session.NewToken()
st.SetOwnerID(id)
st.SetID(cliRes.id)

View file

@ -1,7 +1,6 @@
package pool
// To generate mock define 'type Client client' in pool.go
//go:generate mockgen -destination mock_test.go -package pool . Client
//go:generate mockgen -destination mock_test.go -source pool.go -mock_names client=MockClient -package pool . client
import (
"bytes"
@ -51,9 +50,9 @@ func TestBuildPoolCreateSessionFailed(t *testing.T) {
clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl)
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error session")).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error session")).AnyTimes()
mockClient.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
return mockClient, nil
}
@ -88,25 +87,25 @@ func TestBuildPoolOneNodeFailed(t *testing.T) {
clientCount++
mockClient := NewMockClient(ctrl)
mockInvokes := 0
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*ResCreateSession, error) {
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*resCreateSession, error) {
mockInvokes++
if mockInvokes == 1 {
expectedToken = newToken(t)
return nil, fmt.Errorf("error session")
}
return &ResCreateSession{
return &resCreateSession{
sessionKey: expectedToken.SessionKey(),
id: expectedToken.ID(),
}, nil
}).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient2 := NewMockClient(ctrl2)
mockClient2.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(&ResCreateSession{}, nil).AnyTimes()
mockClient2.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient2.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient2.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).Return(&resCreateSession{}, nil).AnyTimes()
mockClient2.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient2.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
if clientCount == 0 {
return mockClient, nil
@ -161,16 +160,16 @@ func TestOneNode(t *testing.T) {
require.NoError(t, err)
tok.SetID(uid)
tokRes := &ResCreateSession{
tokRes := &resCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}
clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl)
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(tokRes, nil)
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).Return(tokRes, nil)
mockClient.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
return mockClient, nil
}
@ -206,19 +205,19 @@ func TestTwoNodes(t *testing.T) {
var tokens []*session.Token
clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl)
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*resCreateSession, error) {
tok := session.NewToken()
uid, err := uuid.New().MarshalBinary()
require.NoError(t, err)
tok.SetID(uid)
tokens = append(tokens, tok)
return &ResCreateSession{
return &resCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, err
})
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
return mockClient, nil
}
@ -261,30 +260,30 @@ func TestOneOfTwoFailed(t *testing.T) {
clientBuilder := func(_ string) (client, error) {
clientCount++
mockClient := NewMockClient(ctrl)
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*resCreateSession, error) {
tok := newToken(t)
tokens = append(tokens, tok)
return &ResCreateSession{
return &resCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, nil
}).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient2 := NewMockClient(ctrl2)
mockClient2.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
mockClient2.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*resCreateSession, error) {
tok := newToken(t)
tokens = append(tokens, tok)
return &ResCreateSession{
return &resCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, nil
}).AnyTimes()
mockClient2.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).DoAndReturn(func(_ interface{}, _ ...interface{}) (*netmap.NodeInfo, error) {
mockClient2.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).DoAndReturn(func(_ interface{}, _ ...interface{}) (*netmap.NodeInfo, error) {
return nil, fmt.Errorf("error")
}).AnyTimes()
mockClient2.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).DoAndReturn(func(_ interface{}, _ ...interface{}) (*netmap.NetworkInfo, error) {
mockClient2.EXPECT().networkInfo(gomock.Any(), gomock.Any()).DoAndReturn(func(_ interface{}, _ ...interface{}) (*netmap.NetworkInfo, error) {
return nil, fmt.Errorf("error")
}).AnyTimes()
@ -327,9 +326,9 @@ func TestTwoFailed(t *testing.T) {
clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl)
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(&ResCreateSession{}, nil).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error")).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).Return(&resCreateSession{}, nil).AnyTimes()
mockClient.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error")).AnyTimes()
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
return mockClient, nil
}
@ -363,21 +362,21 @@ func TestSessionCache(t *testing.T) {
var tokens []*session.Token
clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl)
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*ResCreateSession, error) {
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}, _ ...interface{}) (*resCreateSession, error) {
tok := session.NewToken()
uid, err := uuid.New().MarshalBinary()
require.NoError(t, err)
tok.SetID(uid)
tokens = append(tokens, tok)
return &ResCreateSession{
return &resCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, err
}).MaxTimes(3)
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().ObjectGet(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("session token does not exist"))
mockClient.EXPECT().ObjectPut(gomock.Any(), gomock.Any()).Return(nil, nil)
mockClient.EXPECT().objectGet(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("session token does not exist"))
mockClient.EXPECT().objectPut(gomock.Any(), gomock.Any()).Return(nil, nil)
return mockClient, nil
}
@ -439,28 +438,28 @@ func TestPriority(t *testing.T) {
tokens := make([]*session.Token, 2)
clientBuilder := func(endpoint string) (client, error) {
mockClient := NewMockClient(ctrl)
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*resCreateSession, error) {
tok := newToken(t)
tokens[0] = tok
return &ResCreateSession{
return &resCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, nil
}).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error")).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(nil, fmt.Errorf("error")).AnyTimes()
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient2 := NewMockClient(ctrl2)
mockClient2.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
mockClient2.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*resCreateSession, error) {
tok := newToken(t)
tokens[1] = tok
return &ResCreateSession{
return &resCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, nil
}).AnyTimes()
mockClient2.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient2.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient2.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient2.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
if endpoint == "peer0" {
return mockClient, nil
@ -511,20 +510,20 @@ func TestSessionCacheWithKey(t *testing.T) {
var tokens []*session.Token
clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl)
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*ResCreateSession, error) {
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).DoAndReturn(func(_, _ interface{}) (*resCreateSession, error) {
tok := session.NewToken()
uid, err := uuid.New().MarshalBinary()
require.NoError(t, err)
tok.SetID(uid)
tokens = append(tokens, tok)
return &ResCreateSession{
return &resCreateSession{
id: tok.ID(),
sessionKey: tok.SessionKey(),
}, err
}).MaxTimes(2)
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().ObjectGet(gomock.Any(), gomock.Any()).Return(nil, nil)
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().objectGet(gomock.Any(), gomock.Any()).Return(nil, nil)
return mockClient, nil
}
@ -576,9 +575,9 @@ func TestSessionTokenOwner(t *testing.T) {
ctrl := gomock.NewController(t)
clientBuilder := func(_ string) (client, error) {
mockClient := NewMockClient(ctrl)
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(&ResCreateSession{}, nil).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).Return(&resCreateSession{}, nil).AnyTimes()
mockClient.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(&netmap.NodeInfo{}, nil).AnyTimes()
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
return mockClient, nil
}
@ -624,10 +623,10 @@ func TestWaitPresence(t *testing.T) {
ctrl := gomock.NewController(t)
mockClient := NewMockClient(ctrl)
mockClient.EXPECT().SessionCreate(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().EndpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().NetworkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().ContainerGet(gomock.Any(), gomock.Any()).Return(&container.Container{}, nil).AnyTimes()
mockClient.EXPECT().sessionCreate(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().endpointInfo(gomock.Any(), gomock.Any()).Return(nil, nil).AnyTimes()
mockClient.EXPECT().networkInfo(gomock.Any(), gomock.Any()).Return(&netmap.NetworkInfo{}, nil).AnyTimes()
mockClient.EXPECT().containerGet(gomock.Any(), gomock.Any()).Return(&container.Container{}, nil).AnyTimes()
cache, err := newCache()
require.NoError(t, err)

View file

@ -48,11 +48,11 @@ type clientMock struct {
err error
}
func (c *clientMock) EndpointInfo(context.Context, PrmEndpointInfo) (*netmap.NodeInfo, error) {
func (c *clientMock) endpointInfo(context.Context, prmEndpointInfo) (*netmap.NodeInfo, error) {
return nil, nil
}
func (c *clientMock) NetworkInfo(context.Context, PrmNetworkInfo) (*netmap.NetworkInfo, error) {
func (c *clientMock) networkInfo(context.Context, prmNetworkInfo) (*netmap.NetworkInfo, error) {
return nil, nil
}