2021-10-19 20:23:22 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
2021-10-08 19:10:54 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-10-19 20:23:22 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-10-08 19:10:54 +08:00
|
|
|
//
|
2021-10-19 20:23:22 +08:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2021-10-08 19:10:54 +08:00
|
|
|
|
2021-10-09 16:00:56 +08:00
|
|
|
package grpcdatacoord
|
2021-10-08 19:10:54 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/commonpb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/datapb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/milvuspb"
|
|
|
|
"github.com/stretchr/testify/assert"
|
2021-12-29 14:35:21 +08:00
|
|
|
clientv3 "go.etcd.io/etcd/client/v3"
|
2021-10-08 19:10:54 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
type MockDataCoord struct {
|
2021-11-05 22:25:00 +08:00
|
|
|
states *internalpb.ComponentStates
|
|
|
|
status *commonpb.Status
|
|
|
|
err error
|
|
|
|
initErr error
|
|
|
|
startErr error
|
|
|
|
stopErr error
|
|
|
|
regErr error
|
|
|
|
strResp *milvuspb.StringResponse
|
|
|
|
infoResp *datapb.GetSegmentInfoResponse
|
|
|
|
flushResp *datapb.FlushResponse
|
|
|
|
assignResp *datapb.AssignSegmentIDResponse
|
|
|
|
segStateResp *datapb.GetSegmentStatesResponse
|
|
|
|
binResp *datapb.GetInsertBinlogPathsResponse
|
|
|
|
colStatResp *datapb.GetCollectionStatisticsResponse
|
|
|
|
partStatResp *datapb.GetPartitionStatisticsResponse
|
|
|
|
recoverResp *datapb.GetRecoveryInfoResponse
|
|
|
|
flushSegResp *datapb.GetFlushedSegmentsResponse
|
|
|
|
metricResp *milvuspb.GetMetricsResponse
|
2021-11-09 14:47:02 +08:00
|
|
|
compactionStateResp *milvuspb.GetCompactionStateResponse
|
|
|
|
manualCompactionResp *milvuspb.ManualCompactionResponse
|
|
|
|
compactionPlansResp *milvuspb.GetCompactionPlansResponse
|
2021-11-11 00:54:45 +08:00
|
|
|
watchChannelsResp *datapb.WatchChannelsResponse
|
2021-11-23 10:55:14 +08:00
|
|
|
getFlushStateResp *milvuspb.GetFlushStateResponse
|
2021-11-29 22:35:41 +08:00
|
|
|
dropVChanResp *datapb.DropVirtualChannelResponse
|
2022-04-06 15:33:32 +08:00
|
|
|
setSegmentStateResp *datapb.SetSegmentStateResponse
|
2022-03-22 15:11:24 +08:00
|
|
|
importResp *datapb.ImportTaskResponse
|
2022-04-20 14:03:40 +08:00
|
|
|
updateSegStatResp *commonpb.Status
|
2021-10-08 19:10:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2021-12-29 14:35:21 +08:00
|
|
|
func (m *MockDataCoord) SetEtcdClient(etcdClient *clientv3.Client) {
|
|
|
|
}
|
|
|
|
|
2021-10-08 19:10:54 +08:00
|
|
|
func (m *MockDataCoord) GetComponentStates(ctx context.Context) (*internalpb.ComponentStates, error) {
|
|
|
|
return m.states, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetTimeTickChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
|
|
|
|
return m.strResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetStatisticsChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
|
|
|
|
return m.strResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetSegmentInfo(ctx context.Context, req *datapb.GetSegmentInfoRequest) (*datapb.GetSegmentInfoResponse, error) {
|
|
|
|
return m.infoResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) Flush(ctx context.Context, req *datapb.FlushRequest) (*datapb.FlushResponse, error) {
|
|
|
|
return m.flushResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) AssignSegmentID(ctx context.Context, req *datapb.AssignSegmentIDRequest) (*datapb.AssignSegmentIDResponse, error) {
|
|
|
|
return m.assignResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetSegmentStates(ctx context.Context, req *datapb.GetSegmentStatesRequest) (*datapb.GetSegmentStatesResponse, error) {
|
|
|
|
return m.segStateResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetInsertBinlogPaths(ctx context.Context, req *datapb.GetInsertBinlogPathsRequest) (*datapb.GetInsertBinlogPathsResponse, error) {
|
|
|
|
return m.binResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetCollectionStatistics(ctx context.Context, req *datapb.GetCollectionStatisticsRequest) (*datapb.GetCollectionStatisticsResponse, error) {
|
|
|
|
return m.colStatResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetPartitionStatistics(ctx context.Context, req *datapb.GetPartitionStatisticsRequest) (*datapb.GetPartitionStatisticsResponse, error) {
|
|
|
|
return m.partStatResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetSegmentInfoChannel(ctx context.Context) (*milvuspb.StringResponse, error) {
|
|
|
|
return m.strResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) SaveBinlogPaths(ctx context.Context, req *datapb.SaveBinlogPathsRequest) (*commonpb.Status, error) {
|
|
|
|
return m.status, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetRecoveryInfo(ctx context.Context, req *datapb.GetRecoveryInfoRequest) (*datapb.GetRecoveryInfoResponse, error) {
|
|
|
|
return m.recoverResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetFlushedSegments(ctx context.Context, req *datapb.GetFlushedSegmentsRequest) (*datapb.GetFlushedSegmentsResponse, error) {
|
|
|
|
return m.flushSegResp, m.err
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MockDataCoord) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
|
|
|
|
return m.metricResp, m.err
|
|
|
|
}
|
|
|
|
|
2021-11-05 22:25:00 +08:00
|
|
|
func (m *MockDataCoord) CompleteCompaction(ctx context.Context, req *datapb.CompactionResult) (*commonpb.Status, error) {
|
|
|
|
return m.status, m.err
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:47:02 +08:00
|
|
|
func (m *MockDataCoord) ManualCompaction(ctx context.Context, req *milvuspb.ManualCompactionRequest) (*milvuspb.ManualCompactionResponse, error) {
|
2021-11-05 22:25:00 +08:00
|
|
|
return m.manualCompactionResp, m.err
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:47:02 +08:00
|
|
|
func (m *MockDataCoord) GetCompactionState(ctx context.Context, req *milvuspb.GetCompactionStateRequest) (*milvuspb.GetCompactionStateResponse, error) {
|
2021-11-05 22:25:00 +08:00
|
|
|
return m.compactionStateResp, m.err
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:47:02 +08:00
|
|
|
func (m *MockDataCoord) GetCompactionStateWithPlans(ctx context.Context, req *milvuspb.GetCompactionPlansRequest) (*milvuspb.GetCompactionPlansResponse, error) {
|
|
|
|
return m.compactionPlansResp, m.err
|
|
|
|
}
|
|
|
|
|
2021-11-11 00:54:45 +08:00
|
|
|
func (m *MockDataCoord) WatchChannels(ctx context.Context, req *datapb.WatchChannelsRequest) (*datapb.WatchChannelsResponse, error) {
|
|
|
|
return m.watchChannelsResp, m.err
|
|
|
|
}
|
|
|
|
|
2021-11-23 10:55:14 +08:00
|
|
|
func (m *MockDataCoord) GetFlushState(ctx context.Context, req *milvuspb.GetFlushStateRequest) (*milvuspb.GetFlushStateResponse, error) {
|
|
|
|
return m.getFlushStateResp, m.err
|
|
|
|
}
|
|
|
|
|
2021-11-29 22:35:41 +08:00
|
|
|
func (m *MockDataCoord) DropVirtualChannel(ctx context.Context, req *datapb.DropVirtualChannelRequest) (*datapb.DropVirtualChannelResponse, error) {
|
|
|
|
return m.dropVChanResp, m.err
|
|
|
|
}
|
|
|
|
|
2022-04-06 15:33:32 +08:00
|
|
|
func (m *MockDataCoord) SetSegmentState(ctx context.Context, req *datapb.SetSegmentStateRequest) (*datapb.SetSegmentStateResponse, error) {
|
|
|
|
return m.setSegmentStateResp, m.err
|
|
|
|
}
|
|
|
|
|
2022-04-01 11:33:28 +08:00
|
|
|
func (m *MockDataCoord) Import(ctx context.Context, req *datapb.ImportTaskRequest) (*datapb.ImportTaskResponse, error) {
|
2022-03-22 15:11:24 +08:00
|
|
|
return m.importResp, m.err
|
2022-03-09 18:33:59 +08:00
|
|
|
}
|
|
|
|
|
2022-04-20 14:03:40 +08:00
|
|
|
func (m *MockDataCoord) UpdateSegmentStatistics(ctx context.Context, req *datapb.UpdateSegmentStatisticsRequest) (*commonpb.Status, error) {
|
|
|
|
return m.updateSegStatResp, m.err
|
|
|
|
}
|
|
|
|
|
2021-10-08 19:10:54 +08:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
func Test_NewServer(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
2021-12-29 14:35:21 +08:00
|
|
|
server := NewServer(ctx, nil)
|
2021-10-08 19:10:54 +08:00
|
|
|
assert.NotNil(t, server)
|
|
|
|
|
|
|
|
t.Run("Run", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{}
|
2021-12-29 14:35:21 +08:00
|
|
|
err := server.Run()
|
2021-10-08 19:10:54 +08:00
|
|
|
assert.Nil(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetComponentStates", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
states: &internalpb.ComponentStates{},
|
|
|
|
}
|
|
|
|
states, err := server.GetComponentStates(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, states)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetTimeTickChannel", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
strResp: &milvuspb.StringResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetTimeTickChannel(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetStatisticsChannel", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
strResp: &milvuspb.StringResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetStatisticsChannel(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetSegmentInfo", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
infoResp: &datapb.GetSegmentInfoResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetSegmentInfo(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Flush", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
flushResp: &datapb.FlushResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.Flush(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("AssignSegmentID", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
assignResp: &datapb.AssignSegmentIDResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.AssignSegmentID(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetSegmentStates", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
segStateResp: &datapb.GetSegmentStatesResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetSegmentStates(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetInsertBinlogPaths", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
binResp: &datapb.GetInsertBinlogPathsResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetInsertBinlogPaths(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetCollectionStatistics", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
colStatResp: &datapb.GetCollectionStatisticsResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetCollectionStatistics(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetPartitionStatistics", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
partStatResp: &datapb.GetPartitionStatisticsResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetPartitionStatistics(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetSegmentInfoChannel", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
strResp: &milvuspb.StringResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetSegmentInfoChannel(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("SaveBinlogPaths", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
status: &commonpb.Status{},
|
|
|
|
}
|
|
|
|
resp, err := server.SaveBinlogPaths(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetRecoveryInfo", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
recoverResp: &datapb.GetRecoveryInfoResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetRecoveryInfo(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetFlushedSegments", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
flushSegResp: &datapb.GetFlushedSegmentsResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetFlushedSegments(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetMetrics", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
metricResp: &milvuspb.GetMetricsResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetMetrics(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
2021-11-11 00:54:45 +08:00
|
|
|
t.Run("WatchChannels", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
watchChannelsResp: &datapb.WatchChannelsResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.WatchChannels(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
2021-11-23 10:55:14 +08:00
|
|
|
t.Run("GetFlushState", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
getFlushStateResp: &milvuspb.GetFlushStateResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetFlushState(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
2021-11-29 22:35:41 +08:00
|
|
|
t.Run("DropVirtualChannel", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
dropVChanResp: &datapb.DropVirtualChannelResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.DropVirtualChannel(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
2022-03-11 17:13:59 +08:00
|
|
|
t.Run("CompleteCompaction", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
status: &commonpb.Status{},
|
|
|
|
}
|
|
|
|
resp, err := server.CompleteCompaction(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ManualCompaction", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
manualCompactionResp: &milvuspb.ManualCompactionResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.ManualCompaction(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetCompactionState", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
compactionStateResp: &milvuspb.GetCompactionStateResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetCompactionState(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetCompactionStateWithPlans", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
compactionPlansResp: &milvuspb.GetCompactionPlansResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.GetCompactionStateWithPlans(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
2022-04-06 15:33:32 +08:00
|
|
|
t.Run("set segment state", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
setSegmentStateResp: &datapb.SetSegmentStateResponse{},
|
|
|
|
}
|
|
|
|
resp, err := server.SetSegmentState(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
2022-04-20 14:03:40 +08:00
|
|
|
t.Run("import", func(t *testing.T) {
|
2022-03-11 17:13:59 +08:00
|
|
|
server.dataCoord = &MockDataCoord{
|
2022-03-22 15:11:24 +08:00
|
|
|
importResp: &datapb.ImportTaskResponse{
|
|
|
|
Status: &commonpb.Status{},
|
|
|
|
},
|
2022-03-11 17:13:59 +08:00
|
|
|
}
|
|
|
|
resp, err := server.Import(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
2022-04-20 14:03:40 +08:00
|
|
|
t.Run("update seg stat", func(t *testing.T) {
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
updateSegStatResp: &commonpb.Status{
|
|
|
|
ErrorCode: commonpb.ErrorCode_Success,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
resp, err := server.UpdateSegmentStatistics(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
})
|
|
|
|
|
2021-12-29 14:35:21 +08:00
|
|
|
err := server.Stop()
|
2021-10-08 19:10:54 +08:00
|
|
|
assert.Nil(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_Run(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
2021-12-29 14:35:21 +08:00
|
|
|
server := NewServer(ctx, nil)
|
2021-10-08 19:10:54 +08:00
|
|
|
assert.NotNil(t, server)
|
|
|
|
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
regErr: errors.New("error"),
|
|
|
|
}
|
|
|
|
|
2021-12-29 14:35:21 +08:00
|
|
|
err := server.Run()
|
2021-10-08 19:10:54 +08:00
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
startErr: errors.New("error"),
|
|
|
|
}
|
|
|
|
|
|
|
|
err = server.Run()
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
initErr: errors.New("error"),
|
|
|
|
}
|
|
|
|
|
|
|
|
err = server.Run()
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
server.dataCoord = &MockDataCoord{
|
|
|
|
stopErr: errors.New("error"),
|
|
|
|
}
|
|
|
|
|
|
|
|
err = server.Stop()
|
|
|
|
assert.Error(t, err)
|
|
|
|
}
|