Add unittest for distributed/proxy (#9875)

Signed-off-by: yhmo <yihua.mo@zilliz.com>
pull/9886/head
groot 2021-10-14 17:48:34 +08:00 committed by GitHub
parent 7205fd3d9b
commit bd7baf8912
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1151 additions and 21 deletions

View File

@ -27,6 +27,7 @@ import (
grpcindexcoordclient "github.com/milvus-io/milvus/internal/distributed/indexcoord/client"
grpcquerycoordclient "github.com/milvus-io/milvus/internal/distributed/querycoord/client"
rcc "github.com/milvus-io/milvus/internal/distributed/rootcoord/client"
"github.com/milvus-io/milvus/internal/types"
grpc_opentracing "github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing"
"github.com/milvus-io/milvus/internal/log"
@ -48,15 +49,15 @@ const (
type Server struct {
ctx context.Context
wg sync.WaitGroup
proxy *proxy.Proxy
proxy types.ProxyComponent
grpcServer *grpc.Server
grpcErrChan chan error
rootCoordClient *rcc.GrpcClient
dataCoordClient *grpcdatacoordclient.Client
queryCooedClient *grpcquerycoordclient.Client
indexCoordClient *grpcindexcoordclient.Client
rootCoordClient types.RootCoord
dataCoordClient types.DataCoord
queryCooedClient types.QueryCoord
indexCoordClient types.IndexCoord
tracer opentracing.Tracer
closer io.Closer
@ -168,10 +169,13 @@ func (s *Server) init() error {
rootCoordAddr := Params.RootCoordAddress
log.Debug("Proxy", zap.String("RootCoord address", rootCoordAddr))
s.rootCoordClient, err = rcc.NewClient(s.ctx, proxy.Params.MetaRootPath, proxy.Params.EtcdEndpoints)
if err != nil {
log.Debug("Proxy new rootCoordClient failed ", zap.Error(err))
return err
if s.rootCoordClient == nil {
s.rootCoordClient, err = rcc.NewClient(s.ctx, proxy.Params.MetaRootPath, proxy.Params.EtcdEndpoints)
if err != nil {
log.Debug("Proxy new rootCoordClient failed ", zap.Error(err))
return err
}
}
err = s.rootCoordClient.Init()
if err != nil {
@ -188,10 +192,13 @@ func (s *Server) init() error {
dataCoordAddr := Params.DataCoordAddress
log.Debug("Proxy", zap.String("data coordinator address", dataCoordAddr))
s.dataCoordClient, err = grpcdatacoordclient.NewClient(s.ctx, proxy.Params.MetaRootPath, proxy.Params.EtcdEndpoints)
if err != nil {
log.Debug("Proxy new dataCoordClient failed ", zap.Error(err))
return err
if s.dataCoordClient == nil {
s.dataCoordClient, err = grpcdatacoordclient.NewClient(s.ctx, proxy.Params.MetaRootPath, proxy.Params.EtcdEndpoints)
if err != nil {
log.Debug("Proxy new dataCoordClient failed ", zap.Error(err))
return err
}
}
err = s.dataCoordClient.Init()
if err != nil {
@ -204,10 +211,13 @@ func (s *Server) init() error {
indexCoordAddr := Params.IndexCoordAddress
log.Debug("Proxy", zap.String("index coordinator address", indexCoordAddr))
s.indexCoordClient, err = grpcindexcoordclient.NewClient(s.ctx, proxy.Params.MetaRootPath, proxy.Params.EtcdEndpoints)
if err != nil {
log.Debug("Proxy new indexCoordClient failed ", zap.Error(err))
return err
if s.indexCoordClient == nil {
s.indexCoordClient, err = grpcindexcoordclient.NewClient(s.ctx, proxy.Params.MetaRootPath, proxy.Params.EtcdEndpoints)
if err != nil {
log.Debug("Proxy new indexCoordClient failed ", zap.Error(err))
return err
}
}
err = s.indexCoordClient.Init()
if err != nil {
@ -220,9 +230,12 @@ func (s *Server) init() error {
queryCoordAddr := Params.QueryCoordAddress
log.Debug("Proxy", zap.String("query coordinator address", queryCoordAddr))
s.queryCooedClient, err = grpcquerycoordclient.NewClient(s.ctx, proxy.Params.MetaRootPath, proxy.Params.EtcdEndpoints)
if err != nil {
return err
if s.queryCooedClient == nil {
s.queryCooedClient, err = grpcquerycoordclient.NewClient(s.ctx, proxy.Params.MetaRootPath, proxy.Params.EtcdEndpoints)
if err != nil {
return err
}
}
err = s.queryCooedClient.Init()
if err != nil {

View File

@ -15,11 +15,768 @@ import (
"context"
"testing"
"github.com/milvus-io/milvus/internal/proto/commonpb"
"github.com/milvus-io/milvus/internal/proto/datapb"
"github.com/milvus-io/milvus/internal/proto/indexpb"
"github.com/milvus-io/milvus/internal/proto/internalpb"
"github.com/milvus-io/milvus/internal/proto/milvuspb"
"github.com/milvus-io/milvus/internal/proto/proxypb"
"github.com/milvus-io/milvus/internal/proto/querypb"
"github.com/milvus-io/milvus/internal/proto/rootcoordpb"
"github.com/milvus-io/milvus/internal/types"
"github.com/stretchr/testify/assert"
)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type MockBase struct {
}
func (m *MockBase) GetComponentStates(ctx context.Context) (*internalpb.ComponentStates, error) {
return &internalpb.ComponentStates{
State: &internalpb.ComponentInfo{StateCode: internalpb.StateCode_Healthy},
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success},
}, nil
}
func (m *MockBase) GetTimeTickChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
return nil, nil
}
func (m *MockBase) GetStatisticsChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
return nil, nil
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type MockRootCoord struct {
MockBase
initErr error
startErr error
regErr error
stopErr error
}
func (m *MockRootCoord) Init() error {
return m.initErr
}
func (m *MockRootCoord) Start() error {
return m.startErr
}
func (m *MockRootCoord) Stop() error {
return m.stopErr
}
func (m *MockRootCoord) Register() error {
return m.regErr
}
func (m *MockRootCoord) CreateCollection(ctx context.Context, req *milvuspb.CreateCollectionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) DropCollection(ctx context.Context, req *milvuspb.DropCollectionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) HasCollection(ctx context.Context, req *milvuspb.HasCollectionRequest) (*milvuspb.BoolResponse, error) {
return nil, nil
}
func (m *MockRootCoord) DescribeCollection(ctx context.Context, req *milvuspb.DescribeCollectionRequest) (*milvuspb.DescribeCollectionResponse, error) {
return nil, nil
}
func (m *MockRootCoord) ShowCollections(ctx context.Context, req *milvuspb.ShowCollectionsRequest) (*milvuspb.ShowCollectionsResponse, error) {
return nil, nil
}
func (m *MockRootCoord) CreatePartition(ctx context.Context, req *milvuspb.CreatePartitionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) DropPartition(ctx context.Context, req *milvuspb.DropPartitionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) HasPartition(ctx context.Context, req *milvuspb.HasPartitionRequest) (*milvuspb.BoolResponse, error) {
return nil, nil
}
func (m *MockRootCoord) ShowPartitions(ctx context.Context, req *milvuspb.ShowPartitionsRequest) (*milvuspb.ShowPartitionsResponse, error) {
return nil, nil
}
func (m *MockRootCoord) CreateIndex(ctx context.Context, req *milvuspb.CreateIndexRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) DescribeIndex(ctx context.Context, req *milvuspb.DescribeIndexRequest) (*milvuspb.DescribeIndexResponse, error) {
return nil, nil
}
func (m *MockRootCoord) DropIndex(ctx context.Context, req *milvuspb.DropIndexRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) CreateAlias(ctx context.Context, req *milvuspb.CreateAliasRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) DropAlias(ctx context.Context, req *milvuspb.DropAliasRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) AlterAlias(ctx context.Context, req *milvuspb.AlterAliasRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) AllocTimestamp(ctx context.Context, req *rootcoordpb.AllocTimestampRequest) (*rootcoordpb.AllocTimestampResponse, error) {
return nil, nil
}
func (m *MockRootCoord) AllocID(ctx context.Context, req *rootcoordpb.AllocIDRequest) (*rootcoordpb.AllocIDResponse, error) {
return nil, nil
}
func (m *MockRootCoord) UpdateChannelTimeTick(ctx context.Context, req *internalpb.ChannelTimeTickMsg) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) DescribeSegment(ctx context.Context, req *milvuspb.DescribeSegmentRequest) (*milvuspb.DescribeSegmentResponse, error) {
return nil, nil
}
func (m *MockRootCoord) ShowSegments(ctx context.Context, req *milvuspb.ShowSegmentsRequest) (*milvuspb.ShowSegmentsResponse, error) {
return nil, nil
}
func (m *MockRootCoord) ReleaseDQLMessageStream(ctx context.Context, in *proxypb.ReleaseDQLMessageStreamRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) SegmentFlushCompleted(ctx context.Context, in *datapb.SegmentFlushCompletedMsg) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockRootCoord) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
return nil, nil
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type MockIndexCoord struct {
MockBase
initErr error
startErr error
regErr error
stopErr error
}
func (m *MockIndexCoord) Init() error {
return m.initErr
}
func (m *MockIndexCoord) Start() error {
return m.startErr
}
func (m *MockIndexCoord) Stop() error {
return m.stopErr
}
func (m *MockIndexCoord) Register() error {
return m.regErr
}
func (m *MockIndexCoord) BuildIndex(ctx context.Context, req *indexpb.BuildIndexRequest) (*indexpb.BuildIndexResponse, error) {
return nil, nil
}
func (m *MockIndexCoord) DropIndex(ctx context.Context, req *indexpb.DropIndexRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockIndexCoord) GetIndexStates(ctx context.Context, req *indexpb.GetIndexStatesRequest) (*indexpb.GetIndexStatesResponse, error) {
return nil, nil
}
func (m *MockIndexCoord) GetIndexFilePaths(ctx context.Context, req *indexpb.GetIndexFilePathsRequest) (*indexpb.GetIndexFilePathsResponse, error) {
return nil, nil
}
func (m *MockIndexCoord) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
return nil, nil
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type MockQueryCoord struct {
MockBase
initErr error
startErr error
stopErr error
regErr error
}
func (m *MockQueryCoord) Init() error {
return m.initErr
}
func (m *MockQueryCoord) Start() error {
return m.startErr
}
func (m *MockQueryCoord) Stop() error {
return m.stopErr
}
func (m *MockQueryCoord) Register() error {
return m.regErr
}
func (m *MockQueryCoord) UpdateStateCode(code internalpb.StateCode) {
}
func (m *MockQueryCoord) SetRootCoord(types.RootCoord) error {
return nil
}
func (m *MockQueryCoord) SetDataCoord(types.DataCoord) error {
return nil
}
func (m *MockQueryCoord) GetComponentStates(ctx context.Context) (*internalpb.ComponentStates, error) {
return nil, nil
}
func (m *MockQueryCoord) GetTimeTickChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
return nil, nil
}
func (m *MockQueryCoord) GetStatisticsChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
return nil, nil
}
func (m *MockQueryCoord) ShowCollections(ctx context.Context, req *querypb.ShowCollectionsRequest) (*querypb.ShowCollectionsResponse, error) {
return nil, nil
}
func (m *MockQueryCoord) LoadCollection(ctx context.Context, req *querypb.LoadCollectionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockQueryCoord) ReleaseCollection(ctx context.Context, req *querypb.ReleaseCollectionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockQueryCoord) ShowPartitions(ctx context.Context, req *querypb.ShowPartitionsRequest) (*querypb.ShowPartitionsResponse, error) {
return nil, nil
}
func (m *MockQueryCoord) GetPartitionStates(ctx context.Context, req *querypb.GetPartitionStatesRequest) (*querypb.GetPartitionStatesResponse, error) {
return nil, nil
}
func (m *MockQueryCoord) LoadPartitions(ctx context.Context, req *querypb.LoadPartitionsRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockQueryCoord) ReleasePartitions(ctx context.Context, req *querypb.ReleasePartitionsRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockQueryCoord) CreateQueryChannel(ctx context.Context, req *querypb.CreateQueryChannelRequest) (*querypb.CreateQueryChannelResponse, error) {
return nil, nil
}
func (m *MockQueryCoord) GetSegmentInfo(ctx context.Context, req *querypb.GetSegmentInfoRequest) (*querypb.GetSegmentInfoResponse, error) {
return nil, nil
}
func (m *MockQueryCoord) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
return nil, nil
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type MockDataCoord struct {
MockBase
err error
initErr error
startErr error
stopErr error
regErr error
}
func (m *MockDataCoord) Init() error {
return m.initErr
}
func (m *MockDataCoord) Start() error {
return m.startErr
}
func (m *MockDataCoord) Stop() error {
return m.stopErr
}
func (m *MockDataCoord) Register() error {
return m.regErr
}
func (m *MockDataCoord) GetSegmentInfo(ctx context.Context, req *datapb.GetSegmentInfoRequest) (*datapb.GetSegmentInfoResponse, error) {
return nil, nil
}
func (m *MockDataCoord) Flush(ctx context.Context, req *datapb.FlushRequest) (*datapb.FlushResponse, error) {
return nil, nil
}
func (m *MockDataCoord) AssignSegmentID(ctx context.Context, req *datapb.AssignSegmentIDRequest) (*datapb.AssignSegmentIDResponse, error) {
return nil, nil
}
func (m *MockDataCoord) GetSegmentStates(ctx context.Context, req *datapb.GetSegmentStatesRequest) (*datapb.GetSegmentStatesResponse, error) {
return nil, nil
}
func (m *MockDataCoord) GetInsertBinlogPaths(ctx context.Context, req *datapb.GetInsertBinlogPathsRequest) (*datapb.GetInsertBinlogPathsResponse, error) {
return nil, nil
}
func (m *MockDataCoord) GetCollectionStatistics(ctx context.Context, req *datapb.GetCollectionStatisticsRequest) (*datapb.GetCollectionStatisticsResponse, error) {
return nil, nil
}
func (m *MockDataCoord) GetPartitionStatistics(ctx context.Context, req *datapb.GetPartitionStatisticsRequest) (*datapb.GetPartitionStatisticsResponse, error) {
return nil, nil
}
func (m *MockDataCoord) GetSegmentInfoChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
return nil, nil
}
func (m *MockDataCoord) SaveBinlogPaths(ctx context.Context, req *datapb.SaveBinlogPathsRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockDataCoord) GetRecoveryInfo(ctx context.Context, req *datapb.GetRecoveryInfoRequest) (*datapb.GetRecoveryInfoResponse, error) {
return nil, nil
}
func (m *MockDataCoord) GetFlushedSegments(ctx context.Context, req *datapb.GetFlushedSegmentsRequest) (*datapb.GetFlushedSegmentsResponse, error) {
return nil, nil
}
func (m *MockDataCoord) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
return nil, nil
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
type MockProxy struct {
MockBase
err error
initErr error
startErr error
stopErr error
regErr error
}
func (m *MockProxy) Init() error {
return m.initErr
}
func (m *MockProxy) Start() error {
return m.startErr
}
func (m *MockProxy) Stop() error {
return m.stopErr
}
func (m *MockProxy) Register() error {
return m.regErr
}
func (m *MockProxy) InvalidateCollectionMetaCache(ctx context.Context, request *proxypb.InvalidateCollMetaCacheRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) ReleaseDQLMessageStream(ctx context.Context, in *proxypb.ReleaseDQLMessageStreamRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) CreateCollection(ctx context.Context, request *milvuspb.CreateCollectionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) DropCollection(ctx context.Context, request *milvuspb.DropCollectionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) HasCollection(ctx context.Context, request *milvuspb.HasCollectionRequest) (*milvuspb.BoolResponse, error) {
return nil, nil
}
func (m *MockProxy) LoadCollection(ctx context.Context, request *milvuspb.LoadCollectionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) ReleaseCollection(ctx context.Context, request *milvuspb.ReleaseCollectionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) DescribeCollection(ctx context.Context, request *milvuspb.DescribeCollectionRequest) (*milvuspb.DescribeCollectionResponse, error) {
return nil, nil
}
func (m *MockProxy) GetCollectionStatistics(ctx context.Context, request *milvuspb.GetCollectionStatisticsRequest) (*milvuspb.GetCollectionStatisticsResponse, error) {
return nil, nil
}
func (m *MockProxy) ShowCollections(ctx context.Context, request *milvuspb.ShowCollectionsRequest) (*milvuspb.ShowCollectionsResponse, error) {
return nil, nil
}
func (m *MockProxy) CreatePartition(ctx context.Context, request *milvuspb.CreatePartitionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) DropPartition(ctx context.Context, request *milvuspb.DropPartitionRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) HasPartition(ctx context.Context, request *milvuspb.HasPartitionRequest) (*milvuspb.BoolResponse, error) {
return nil, nil
}
func (m *MockProxy) LoadPartitions(ctx context.Context, request *milvuspb.LoadPartitionsRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) ReleasePartitions(ctx context.Context, request *milvuspb.ReleasePartitionsRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) GetPartitionStatistics(ctx context.Context, request *milvuspb.GetPartitionStatisticsRequest) (*milvuspb.GetPartitionStatisticsResponse, error) {
return nil, nil
}
func (m *MockProxy) ShowPartitions(ctx context.Context, request *milvuspb.ShowPartitionsRequest) (*milvuspb.ShowPartitionsResponse, error) {
return nil, nil
}
func (m *MockProxy) CreateIndex(ctx context.Context, request *milvuspb.CreateIndexRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) DropIndex(ctx context.Context, request *milvuspb.DropIndexRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) DescribeIndex(ctx context.Context, request *milvuspb.DescribeIndexRequest) (*milvuspb.DescribeIndexResponse, error) {
return nil, nil
}
func (m *MockProxy) GetIndexBuildProgress(ctx context.Context, request *milvuspb.GetIndexBuildProgressRequest) (*milvuspb.GetIndexBuildProgressResponse, error) {
return nil, nil
}
func (m *MockProxy) GetIndexState(ctx context.Context, request *milvuspb.GetIndexStateRequest) (*milvuspb.GetIndexStateResponse, error) {
return nil, nil
}
func (m *MockProxy) Insert(ctx context.Context, request *milvuspb.InsertRequest) (*milvuspb.MutationResult, error) {
return nil, nil
}
func (m *MockProxy) Delete(ctx context.Context, request *milvuspb.DeleteRequest) (*milvuspb.MutationResult, error) {
return nil, nil
}
func (m *MockProxy) Search(ctx context.Context, request *milvuspb.SearchRequest) (*milvuspb.SearchResults, error) {
return nil, nil
}
func (m *MockProxy) Flush(ctx context.Context, request *milvuspb.FlushRequest) (*milvuspb.FlushResponse, error) {
return nil, nil
}
func (m *MockProxy) Query(ctx context.Context, request *milvuspb.QueryRequest) (*milvuspb.QueryResults, error) {
return nil, nil
}
func (m *MockProxy) CalcDistance(ctx context.Context, request *milvuspb.CalcDistanceRequest) (*milvuspb.CalcDistanceResults, error) {
return nil, nil
}
func (m *MockProxy) GetDdChannel(ctx context.Context, request *internalpb.GetDdChannelRequest) (*milvuspb.StringResponse, error) {
return nil, nil
}
func (m *MockProxy) GetPersistentSegmentInfo(ctx context.Context, request *milvuspb.GetPersistentSegmentInfoRequest) (*milvuspb.GetPersistentSegmentInfoResponse, error) {
return nil, nil
}
func (m *MockProxy) GetQuerySegmentInfo(ctx context.Context, request *milvuspb.GetQuerySegmentInfoRequest) (*milvuspb.GetQuerySegmentInfoResponse, error) {
return nil, nil
}
func (m *MockProxy) Dummy(ctx context.Context, request *milvuspb.DummyRequest) (*milvuspb.DummyResponse, error) {
return nil, nil
}
func (m *MockProxy) RegisterLink(ctx context.Context, request *milvuspb.RegisterLinkRequest) (*milvuspb.RegisterLinkResponse, error) {
return nil, nil
}
func (m *MockProxy) GetMetrics(ctx context.Context, request *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
return nil, nil
}
func (m *MockProxy) CreateAlias(ctx context.Context, request *milvuspb.CreateAliasRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) DropAlias(ctx context.Context, request *milvuspb.DropAliasRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) AlterAlias(ctx context.Context, request *milvuspb.AlterAliasRequest) (*commonpb.Status, error) {
return nil, nil
}
func (m *MockProxy) SetRootCoordClient(rootCoord types.RootCoord) {
}
func (m *MockProxy) SetDataCoordClient(dataCoord types.DataCoord) {
}
func (m *MockProxy) SetIndexCoordClient(indexCoord types.IndexCoord) {
}
func (m *MockProxy) SetQueryCoordClient(queryCoord types.QueryCoord) {
}
func (m *MockProxy) UpdateStateCode(stateCode internalpb.StateCode) {
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
func Test_NewServer(t *testing.T) {
server, err := NewServer(context.Background(), nil)
ctx := context.Background()
server, err := NewServer(ctx, nil)
assert.NotNil(t, server)
assert.Nil(t, err)
server.proxy = &MockProxy{}
server.rootCoordClient = &MockRootCoord{}
server.indexCoordClient = &MockIndexCoord{}
server.queryCooedClient = &MockQueryCoord{}
server.dataCoordClient = &MockDataCoord{}
t.Run("Run", func(t *testing.T) {
err = server.Run()
assert.Nil(t, err)
})
t.Run("GetComponentStates", func(t *testing.T) {
_, err := server.GetComponentStates(ctx, nil)
assert.Nil(t, err)
})
t.Run("GetStatisticsChannel", func(t *testing.T) {
_, err := server.GetStatisticsChannel(ctx, nil)
assert.Nil(t, err)
})
t.Run("InvalidateCollectionMetaCache", func(t *testing.T) {
_, err := server.InvalidateCollectionMetaCache(ctx, nil)
assert.Nil(t, err)
})
t.Run("ReleaseDQLMessageStream", func(t *testing.T) {
_, err := server.ReleaseDQLMessageStream(ctx, nil)
assert.Nil(t, err)
})
t.Run("CreateCollection", func(t *testing.T) {
_, err := server.CreateCollection(ctx, nil)
assert.Nil(t, err)
})
t.Run("DropCollection", func(t *testing.T) {
_, err := server.DropCollection(ctx, nil)
assert.Nil(t, err)
})
t.Run("HasCollection", func(t *testing.T) {
_, err := server.HasCollection(ctx, nil)
assert.Nil(t, err)
})
t.Run("LoadCollection", func(t *testing.T) {
_, err := server.LoadCollection(ctx, nil)
assert.Nil(t, err)
})
t.Run("ReleaseCollection", func(t *testing.T) {
_, err := server.ReleaseCollection(ctx, nil)
assert.Nil(t, err)
})
t.Run("DescribeCollection", func(t *testing.T) {
_, err := server.DescribeCollection(ctx, nil)
assert.Nil(t, err)
})
t.Run("GetCollectionStatistics", func(t *testing.T) {
_, err := server.GetCollectionStatistics(ctx, nil)
assert.Nil(t, err)
})
t.Run("ShowCollections", func(t *testing.T) {
_, err := server.ShowCollections(ctx, nil)
assert.Nil(t, err)
})
t.Run("CreatePartition", func(t *testing.T) {
_, err := server.CreatePartition(ctx, nil)
assert.Nil(t, err)
})
t.Run("DropPartition", func(t *testing.T) {
_, err := server.DropPartition(ctx, nil)
assert.Nil(t, err)
})
t.Run("HasPartition", func(t *testing.T) {
_, err := server.HasPartition(ctx, nil)
assert.Nil(t, err)
})
t.Run("LoadPartitions", func(t *testing.T) {
_, err := server.LoadPartitions(ctx, nil)
assert.Nil(t, err)
})
t.Run("ReleasePartitions", func(t *testing.T) {
_, err := server.ReleasePartitions(ctx, nil)
assert.Nil(t, err)
})
t.Run("GetPartitionStatistics", func(t *testing.T) {
_, err := server.GetPartitionStatistics(ctx, nil)
assert.Nil(t, err)
})
t.Run("ShowPartitions", func(t *testing.T) {
_, err := server.ShowPartitions(ctx, nil)
assert.Nil(t, err)
})
t.Run("CreateIndex", func(t *testing.T) {
_, err := server.CreateIndex(ctx, nil)
assert.Nil(t, err)
})
t.Run("DropIndex", func(t *testing.T) {
_, err := server.DropIndex(ctx, nil)
assert.Nil(t, err)
})
t.Run("DescribeIndex", func(t *testing.T) {
_, err := server.DescribeIndex(ctx, nil)
assert.Nil(t, err)
})
t.Run("GetIndexBuildProgress", func(t *testing.T) {
_, err := server.GetIndexBuildProgress(ctx, nil)
assert.Nil(t, err)
})
t.Run("GetIndexState", func(t *testing.T) {
_, err := server.GetIndexState(ctx, nil)
assert.Nil(t, err)
})
t.Run("Insert", func(t *testing.T) {
_, err := server.Insert(ctx, nil)
assert.Nil(t, err)
})
t.Run("Delete", func(t *testing.T) {
_, err := server.Delete(ctx, nil)
assert.Nil(t, err)
})
t.Run("Search", func(t *testing.T) {
_, err := server.Search(ctx, nil)
assert.Nil(t, err)
})
t.Run("Flush", func(t *testing.T) {
_, err := server.Flush(ctx, nil)
assert.Nil(t, err)
})
t.Run("Query", func(t *testing.T) {
_, err := server.Query(ctx, nil)
assert.Nil(t, err)
})
t.Run("CalcDistance", func(t *testing.T) {
_, err := server.CalcDistance(ctx, nil)
assert.Nil(t, err)
})
t.Run("GetDdChannel", func(t *testing.T) {
_, err := server.GetDdChannel(ctx, nil)
assert.Nil(t, err)
})
t.Run("GetPersistentSegmentInfo", func(t *testing.T) {
_, err := server.GetPersistentSegmentInfo(ctx, nil)
assert.Nil(t, err)
})
t.Run("GetQuerySegmentInfo", func(t *testing.T) {
_, err := server.GetQuerySegmentInfo(ctx, nil)
assert.Nil(t, err)
})
t.Run("Dummy", func(t *testing.T) {
_, err := server.Dummy(ctx, nil)
assert.Nil(t, err)
})
t.Run("RegisterLink", func(t *testing.T) {
_, err := server.RegisterLink(ctx, nil)
assert.Nil(t, err)
})
t.Run("GetMetrics", func(t *testing.T) {
_, err := server.GetMetrics(ctx, nil)
assert.Nil(t, err)
})
t.Run("CreateAlias", func(t *testing.T) {
_, err := server.CreateAlias(ctx, nil)
assert.Nil(t, err)
})
t.Run("DropAlias", func(t *testing.T) {
_, err := server.DropAlias(ctx, nil)
assert.Nil(t, err)
})
t.Run("AlterAlias", func(t *testing.T) {
_, err := server.AlterAlias(ctx, nil)
assert.Nil(t, err)
})
err = server.Stop()
assert.Nil(t, err)
}

View File

@ -539,6 +539,366 @@ type Proxy interface {
ReleaseDQLMessageStream(ctx context.Context, in *proxypb.ReleaseDQLMessageStreamRequest) (*commonpb.Status, error)
}
type ProxyComponent interface {
Proxy
// SetRootCoord set RootCoord for Proxy
// `rootCoord` is a client of root coordinator.
SetRootCoordClient(rootCoord RootCoord)
// SetDataCoord set DataCoord for Proxy
// `dataCoord` is a client of data coordinator.
SetDataCoordClient(dataCoord DataCoord)
// SetIndexCoord set IndexCoord for Proxy
// `indexCoord` is a client of index coordinator.
SetIndexCoordClient(indexCoord IndexCoord)
// SetQueryCoord set QueryCoord for Proxy
// `queryCoord` is a client of query coordinator.
SetQueryCoordClient(queryCoord QueryCoord)
// UpdateStateCode updates state code for Proxy
// `stateCode` is current statement of this proxy node, indicating whether it's healthy.
UpdateStateCode(stateCode internalpb.StateCode)
// CreateCollection notifies Proxy to create a collection
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, collection schema
//
// The `ErrorCode` of `Status` is `Success` if create collection successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error`, and the `Reason` of `Status` will record the fail cause.
// error is always nil
CreateCollection(ctx context.Context, request *milvuspb.CreateCollectionRequest) (*commonpb.Status, error)
// DropCollection notifies Proxy to drop a collection
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved) and collection name
//
// The `ErrorCode` of `Status` is `Success` if drop collection successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error`, and the `Reason` of `Status` will record the fail cause.
// error is always nil
DropCollection(ctx context.Context, request *milvuspb.DropCollectionRequest) (*commonpb.Status, error)
// HasCollection notifies Proxy to check a collection's existence at specified timestamp
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name and timestamp
//
// The `Status` in response struct `BoolResponse` indicates if this operation is processed successfully or fail cause;
// the `Value` in `BoolResponse` is `true` if the collection exists at the specified timestamp, `false` otherwise.
// Timestamp is ignored if set to 0.
// error is always nil
HasCollection(ctx context.Context, request *milvuspb.HasCollectionRequest) (*milvuspb.BoolResponse, error)
// LoadCollection notifies Proxy to load a collection's data
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name
//
// The `ErrorCode` of `Status` is `Success` if load collection successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error
// error is always nil
LoadCollection(ctx context.Context, request *milvuspb.LoadCollectionRequest) (*commonpb.Status, error)
// ReleaseCollection notifies Proxy to release a collection's data
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name
//
// The `ErrorCode` of `Status` is `Success` if release collection successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error
// error is always nil
ReleaseCollection(ctx context.Context, request *milvuspb.ReleaseCollectionRequest) (*commonpb.Status, error)
// DescribeCollection notifies Proxy to return a collection's description
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name or collection id
//
// The `Status` in response struct `DescribeCollectionResponse` indicates if this operation is processed successfully or fail cause;
// the `Schema` in `DescribeCollectionResponse` return collection's schema.
// error is always nil
DescribeCollection(ctx context.Context, request *milvuspb.DescribeCollectionRequest) (*milvuspb.DescribeCollectionResponse, error)
// GetCollectionStatistics notifies Proxy to return a collection's statistics
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name
//
// The `Status` in response struct `GetCollectionStatisticsResponse` indicates if this operation is processed successfully or fail cause;
// the `Stats` in `GetCollectionStatisticsResponse` return collection's statistics in key-value format.
// error is always nil
GetCollectionStatistics(ctx context.Context, request *milvuspb.GetCollectionStatisticsRequest) (*milvuspb.GetCollectionStatisticsResponse, error)
// ShowCollections notifies Proxy to return collections list in current db at specified timestamp
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), timestamp
//
// The `Status` in response struct `ShowCollectionsResponse` indicates if this operation is processed successfully or fail cause;
// the `CollectionNames` in `ShowCollectionsResponse` return collection names list.
// the `CollectionIds` in `ShowCollectionsResponse` return collection ids list.
// error is always nil
ShowCollections(ctx context.Context, request *milvuspb.ShowCollectionsRequest) (*milvuspb.ShowCollectionsResponse, error)
// CreatePartition notifies Proxy to create a partition
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition name
//
// The `ErrorCode` of `Status` is `Success` if create partition successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error`, and the `Reason` of `Status` will record the fail cause.
// error is always nil
CreatePartition(ctx context.Context, request *milvuspb.CreatePartitionRequest) (*commonpb.Status, error)
// DropPartition notifies Proxy to drop a partition
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition name
//
// The `ErrorCode` of `Status` is `Success` if drop partition successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error`, and the `Reason` of `Status` will record the fail cause.
// error is always nil
DropPartition(ctx context.Context, request *milvuspb.DropPartitionRequest) (*commonpb.Status, error)
// HasPartition notifies Proxy to check a partition's existence
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition name
//
// The `ErrorCode` of `Status` is `Success` if check partition's existence successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error`, and the `Reason` of `Status` will record the fail cause.
// error is always nil
HasPartition(ctx context.Context, request *milvuspb.HasPartitionRequest) (*milvuspb.BoolResponse, error)
// LoadPartitions notifies Proxy to load partition's data
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition names
//
// The `ErrorCode` of `Status` is `Success` if load partitions successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error
// error is always nil
LoadPartitions(ctx context.Context, request *milvuspb.LoadPartitionsRequest) (*commonpb.Status, error)
// ReleasePartitions notifies Proxy to release collection's data
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition names
//
// The `ErrorCode` of `Status` is `Success` if release collection successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error
// error is always nil
ReleasePartitions(ctx context.Context, request *milvuspb.ReleasePartitionsRequest) (*commonpb.Status, error)
// GetPartitionStatistics notifies Proxy to return a partiiton's statistics
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition name
//
// The `Status` in response struct `GetPartitionStatisticsResponse` indicates if this operation is processed successfully or fail cause;
// the `Stats` in `GetPartitionStatisticsResponse` return collection's statistics in key-value format.
// error is always nil
GetPartitionStatistics(ctx context.Context, request *milvuspb.GetPartitionStatisticsRequest) (*milvuspb.GetPartitionStatisticsResponse, error)
// ShowPartitions notifies Proxy to return collections list in current db at specified timestamp
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition names(optional)
// When partition names is specified, will return these patitions's inMemory_percentages.
//
// The `Status` in response struct `ShowPartitionsResponse` indicates if this operation is processed successfully or fail cause;
// the `PartitionNames` in `ShowPartitionsResponse` return partition names list.
// the `PartitionIds` in `ShowPartitionsResponse` return partition ids list.
// the `InMemoryPercentages` in `ShowPartitionsResponse` return partitions's inMemory_percentages if the partition names of req is specified.
// error is always nil
ShowPartitions(ctx context.Context, request *milvuspb.ShowPartitionsRequest) (*milvuspb.ShowPartitionsResponse, error)
// CreateIndex notifies Proxy to create index of a field
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, field name, index parameters
//
// The `ErrorCode` of `Status` is `Success` if create index successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error`, and the `Reason` of `Status` will record the fail cause.
// error is always nil
CreateIndex(ctx context.Context, request *milvuspb.CreateIndexRequest) (*commonpb.Status, error)
// DropIndex notifies Proxy to drop an index
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, field name, index name
//
// The `ErrorCode` of `Status` is `Success` if drop index successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error`, and the `Reason` of `Status` will record the fail cause.
// error is always nil
DropIndex(ctx context.Context, request *milvuspb.DropIndexRequest) (*commonpb.Status, error)
// DescribeIndex notifies Proxy to return index's description
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, field name, index name
//
// The `Status` in response struct `DescribeIndexResponse` indicates if this operation is processed successfully or fail cause;
// the `IndexDescriptions` in `DescribeIndexResponse` return index's description.
// error is always nil
DescribeIndex(ctx context.Context, request *milvuspb.DescribeIndexRequest) (*milvuspb.DescribeIndexResponse, error)
// GetIndexBuildProgress notifies Proxy to return index build progress
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, field name, index name
//
// The `Status` in response struct `GetIndexBuildProgressResponse` indicates if this operation is processed successfully or fail cause;
// the `IndexdRows` in `GetIndexBuildProgressResponse` return the num of indexed rows.
// the `TotalRows` in `GetIndexBuildProgressResponse` return the total number of segment rows.
// error is always nil
GetIndexBuildProgress(ctx context.Context, request *milvuspb.GetIndexBuildProgressRequest) (*milvuspb.GetIndexBuildProgressResponse, error)
// GetIndexState notifies Proxy to return index state
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, field name, index name
//
// The `Status` in response struct `GetIndexStateResponse` indicates if this operation is processed successfully or fail cause;
// the `State` in `GetIndexStateResponse` return the state of index: Unissued/InProgress/Finished/Failed.
// error is always nil
GetIndexState(ctx context.Context, request *milvuspb.GetIndexStateRequest) (*milvuspb.GetIndexStateResponse, error)
// Insert notifies Proxy to insert rows
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition name(optional), fields data
//
// The `Status` in response struct `MutationResult` indicates if this operation is processed successfully or fail cause;
// the `IDs` in `MutationResult` return the id list of inserted rows.
// the `SuccIndex` in `MutationResult` return the succeed number of inserted rows.
// the `ErrIndex` in `MutationResult` return the failed number of insert rows.
// error is always nil
Insert(ctx context.Context, request *milvuspb.InsertRequest) (*milvuspb.MutationResult, error)
// Delete notifies Proxy to delete rows
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition name(optional), filter expression
//
// The `Status` in response struct `MutationResult` indicates if this operation is processed successfully or fail cause;
// the `IDs` in `MutationResult` return the id list of deleted rows.
// the `SuccIndex` in `MutationResult` return the succeed number of deleted rows.
// the `ErrIndex` in `MutationResult` return the failed number of delete rows.
// error is always nil
Delete(ctx context.Context, request *milvuspb.DeleteRequest) (*milvuspb.MutationResult, error)
// Search notifies Proxy to do search
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition name(optional), filter expression
//
// The `Status` in response struct `SearchResults` indicates if this operation is processed successfully or fail cause;
// the `Results` in `SearchResults` return search results.
// error is always nil
Search(ctx context.Context, request *milvuspb.SearchRequest) (*milvuspb.SearchResults, error)
// Flush notifies Proxy to flush buffer into storage
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name
//
// The `Status` in response struct `FlushResponse` indicates if this operation is processed successfully or fail cause;
// error is always nil
Flush(ctx context.Context, request *milvuspb.FlushRequest) (*milvuspb.FlushResponse, error)
// Query notifies Proxy to query rows
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, partition names(optional), filter expression, output fields
//
// The `Status` in response struct `QueryResults` indicates if this operation is processed successfully or fail cause;
// the `FieldsData` in `QueryResults` return query results.
// error is always nil
Query(ctx context.Context, request *milvuspb.QueryRequest) (*milvuspb.QueryResults, error)
// CalcDistance notifies Proxy to calculate distance between specified vectors
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), vectors to calculate
//
// The `Status` in response struct `CalcDistanceResults` indicates if this operation is processed successfully or fail cause;
// The `Array` in response struct `CalcDistanceResults` return distance result
// Return generic error when specified vectors not found or float/binary vectors mismatch, otherwise return nil
CalcDistance(ctx context.Context, request *milvuspb.CalcDistanceRequest) (*milvuspb.CalcDistanceResults, error)
// Not yet implemented
GetDdChannel(ctx context.Context, request *internalpb.GetDdChannelRequest) (*milvuspb.StringResponse, error)
// GetPersistentSegmentInfo notifies Proxy to return sealed segments's information of a collection from data coord
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name
//
// The `Status` in response struct `GetPersistentSegmentInfoResponse` indicates if this operation is processed successfully or fail cause;
// the `Infos` in `GetPersistentSegmentInfoResponse` return sealed segments's information of a collection.
// error is always nil
GetPersistentSegmentInfo(ctx context.Context, request *milvuspb.GetPersistentSegmentInfoRequest) (*milvuspb.GetPersistentSegmentInfoResponse, error)
// GetQuerySegmentInfo notifies Proxy to return growing segments's information of a collection from query coord
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name
//
// The `Status` in response struct `GetQuerySegmentInfoResponse` indicates if this operation is processed successfully or fail cause;
// the `Infos` in `GetQuerySegmentInfoResponse` return growing segments's information of a collection.
// error is always nil
GetQuerySegmentInfo(ctx context.Context, request *milvuspb.GetQuerySegmentInfoRequest) (*milvuspb.GetQuerySegmentInfoResponse, error)
// For internal usage
Dummy(ctx context.Context, request *milvuspb.DummyRequest) (*milvuspb.DummyResponse, error)
// RegisterLink notifies Proxy to its state code
//
// ctx is the context to control request deadline and cancellation
//
// The `Status` in response struct `RegisterLinkResponse` indicates if this proxy is healthy or not
// error is always nil
RegisterLink(ctx context.Context, request *milvuspb.RegisterLinkRequest) (*milvuspb.RegisterLinkResponse, error)
// GetMetrics gets the metrics of the proxy.
GetMetrics(ctx context.Context, request *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error)
// CreateAlias notifies Proxy to create alias for a collection
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, alias
//
// The `ErrorCode` of `Status` is `Success` if create alias successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error`, and the `Reason` of `Status` will record the fail cause.
// error is always nil
CreateAlias(ctx context.Context, request *milvuspb.CreateAliasRequest) (*commonpb.Status, error)
// DropAlias notifies Proxy to drop an alias
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, alias
//
// The `ErrorCode` of `Status` is `Success` if drop alias successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error`, and the `Reason` of `Status` will record the fail cause.
// error is always nil
DropAlias(ctx context.Context, request *milvuspb.DropAliasRequest) (*commonpb.Status, error)
// AlterAlias notifies Proxy to alter an alias from a colection to another
//
// ctx is the context to control request deadline and cancellation
// req contains the request params, including database name(reserved), collection name, alias
//
// The `ErrorCode` of `Status` is `Success` if alter alias successfully;
// otherwise, the `ErrorCode` of `Status` will be `Error`, and the `Reason` of `Status` will record the fail cause.
// error is always nil
AlterAlias(ctx context.Context, request *milvuspb.AlterAliasRequest) (*commonpb.Status, error)
}
// QueryNode is the interface `querynode` package implements
type QueryNode interface {
Component