2021-12-09 14:37: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-04-19 13:47:10 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-12-09 14:37:22 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-04-19 13:47:10 +08:00
|
|
|
//
|
2021-12-09 14:37: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-04-19 13:47:10 +08:00
|
|
|
|
2021-01-16 10:12:14 +08:00
|
|
|
package querynode
|
2020-09-12 16:57:37 +08:00
|
|
|
|
2020-11-16 17:01:10 +08:00
|
|
|
import (
|
|
|
|
"context"
|
2020-12-10 16:31:09 +08:00
|
|
|
"math/rand"
|
2020-12-08 14:41:04 +08:00
|
|
|
"os"
|
2020-12-10 16:31:09 +08:00
|
|
|
"strconv"
|
2020-11-16 17:01:10 +08:00
|
|
|
"testing"
|
|
|
|
"time"
|
2020-12-08 14:41:04 +08:00
|
|
|
|
2021-10-20 17:54:43 +08:00
|
|
|
"github.com/golang/protobuf/proto"
|
2020-12-08 14:41:04 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
2020-12-10 16:31:09 +08:00
|
|
|
|
2021-06-19 11:45:09 +08:00
|
|
|
etcdkv "github.com/milvus-io/milvus/internal/kv/etcd"
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/msgstream"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/commonpb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/etcdpb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/querypb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/schemapb"
|
|
|
|
"github.com/milvus-io/milvus/internal/types"
|
2020-11-16 17:01:10 +08:00
|
|
|
)
|
|
|
|
|
2021-09-22 11:30:07 +08:00
|
|
|
// mock of query coordinator client
|
2021-06-22 16:44:09 +08:00
|
|
|
type queryCoordMock struct {
|
|
|
|
types.QueryCoord
|
2021-03-08 10:09:48 +08:00
|
|
|
}
|
2021-01-29 15:22:24 +08:00
|
|
|
|
2020-12-08 14:41:04 +08:00
|
|
|
func setup() {
|
2021-02-23 11:40:30 +08:00
|
|
|
os.Setenv("QUERY_NODE_ID", "1")
|
2020-11-16 21:10:43 +08:00
|
|
|
Params.Init()
|
2020-12-22 22:08:03 +08:00
|
|
|
Params.MetaRootPath = "/etcd/test/root/querynode"
|
2020-12-08 14:41:04 +08:00
|
|
|
}
|
|
|
|
|
2021-08-16 12:24:09 +08:00
|
|
|
func genTestCollectionSchema(collectionID UniqueID, isBinary bool, dim int) *schemapb.CollectionSchema {
|
2021-01-06 18:19:44 +08:00
|
|
|
var fieldVec schemapb.FieldSchema
|
|
|
|
if isBinary {
|
|
|
|
fieldVec = schemapb.FieldSchema{
|
|
|
|
FieldID: UniqueID(100),
|
|
|
|
Name: "vec",
|
|
|
|
IsPrimaryKey: false,
|
2021-03-12 14:22:09 +08:00
|
|
|
DataType: schemapb.DataType_BinaryVector,
|
2021-01-06 18:19:44 +08:00
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "dim",
|
2021-08-16 12:24:09 +08:00
|
|
|
Value: strconv.Itoa(dim * 8),
|
2021-01-06 18:19:44 +08:00
|
|
|
},
|
2020-12-08 14:41:04 +08:00
|
|
|
},
|
2021-01-06 18:19:44 +08:00
|
|
|
IndexParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "metric_type",
|
|
|
|
Value: "JACCARD",
|
|
|
|
},
|
2020-12-08 14:41:04 +08:00
|
|
|
},
|
2021-01-06 18:19:44 +08:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fieldVec = schemapb.FieldSchema{
|
|
|
|
FieldID: UniqueID(100),
|
|
|
|
Name: "vec",
|
|
|
|
IsPrimaryKey: false,
|
2021-03-12 14:22:09 +08:00
|
|
|
DataType: schemapb.DataType_FloatVector,
|
2021-01-06 18:19:44 +08:00
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "dim",
|
2021-08-16 12:24:09 +08:00
|
|
|
Value: strconv.Itoa(dim),
|
2021-01-06 18:19:44 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
IndexParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "metric_type",
|
|
|
|
Value: "L2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2020-12-08 14:41:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
fieldInt := schemapb.FieldSchema{
|
2021-01-04 10:13:01 +08:00
|
|
|
FieldID: UniqueID(101),
|
2020-12-08 14:41:04 +08:00
|
|
|
Name: "age",
|
|
|
|
IsPrimaryKey: false,
|
2021-03-12 14:22:09 +08:00
|
|
|
DataType: schemapb.DataType_Int32,
|
2020-12-08 14:41:04 +08:00
|
|
|
}
|
|
|
|
|
2021-08-16 12:24:09 +08:00
|
|
|
schema := &schemapb.CollectionSchema{
|
2020-12-08 14:41:04 +08:00
|
|
|
AutoID: true,
|
|
|
|
Fields: []*schemapb.FieldSchema{
|
|
|
|
&fieldVec, &fieldInt,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2021-08-16 12:24:09 +08:00
|
|
|
return schema
|
|
|
|
}
|
|
|
|
|
|
|
|
func genTestCollectionMeta(collectionID UniqueID, isBinary bool) *etcdpb.CollectionInfo {
|
|
|
|
schema := genTestCollectionSchema(collectionID, isBinary, 16)
|
|
|
|
|
2021-02-03 18:12:48 +08:00
|
|
|
collectionMeta := etcdpb.CollectionInfo{
|
|
|
|
ID: collectionID,
|
2021-08-16 12:24:09 +08:00
|
|
|
Schema: schema,
|
2021-02-03 18:12:48 +08:00
|
|
|
CreateTime: Timestamp(0),
|
|
|
|
PartitionIDs: []UniqueID{defaultPartitionID},
|
2020-12-08 14:41:04 +08:00
|
|
|
}
|
2021-01-04 10:13:01 +08:00
|
|
|
|
2020-12-08 14:41:04 +08:00
|
|
|
return &collectionMeta
|
|
|
|
}
|
|
|
|
|
2021-09-03 17:12:55 +08:00
|
|
|
func genTestCollectionMetaWithPK(collectionID UniqueID, isBinary bool) *etcdpb.CollectionInfo {
|
|
|
|
schema := genTestCollectionSchema(collectionID, isBinary, 16)
|
|
|
|
schema.Fields = append(schema.Fields, &schemapb.FieldSchema{
|
|
|
|
FieldID: UniqueID(0),
|
|
|
|
Name: "id",
|
|
|
|
IsPrimaryKey: true,
|
|
|
|
DataType: schemapb.DataType_Int64,
|
|
|
|
})
|
|
|
|
|
|
|
|
collectionMeta := etcdpb.CollectionInfo{
|
|
|
|
ID: collectionID,
|
|
|
|
Schema: schema,
|
|
|
|
CreateTime: Timestamp(0),
|
|
|
|
PartitionIDs: []UniqueID{defaultPartitionID},
|
|
|
|
}
|
|
|
|
|
|
|
|
return &collectionMeta
|
|
|
|
}
|
|
|
|
|
2021-02-03 11:52:19 +08:00
|
|
|
func initTestMeta(t *testing.T, node *QueryNode, collectionID UniqueID, segmentID UniqueID, optional ...bool) {
|
2021-01-12 18:03:24 +08:00
|
|
|
isBinary := false
|
|
|
|
if len(optional) > 0 {
|
|
|
|
isBinary = optional[0]
|
|
|
|
}
|
2021-02-03 11:52:19 +08:00
|
|
|
collectionMeta := genTestCollectionMeta(collectionID, isBinary)
|
2020-12-08 14:41:04 +08:00
|
|
|
|
2021-05-28 10:26:30 +08:00
|
|
|
var err = node.historical.replica.addCollection(collectionMeta.ID, collectionMeta.Schema)
|
2020-12-08 14:41:04 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2021-05-28 10:26:30 +08:00
|
|
|
collection, err := node.historical.replica.getCollectionByID(collectionID)
|
2020-12-08 14:41:04 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-10 16:31:09 +08:00
|
|
|
assert.Equal(t, collection.ID(), collectionID)
|
2021-05-28 10:26:30 +08:00
|
|
|
assert.Equal(t, node.historical.replica.getCollectionNum(), 1)
|
2020-12-08 14:41:04 +08:00
|
|
|
|
2021-05-28 10:26:30 +08:00
|
|
|
err = node.historical.replica.addPartition(collection.ID(), collectionMeta.PartitionIDs[0])
|
2020-12-08 14:41:04 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2021-06-15 12:41:40 +08:00
|
|
|
err = node.historical.replica.addSegment(segmentID, collectionMeta.PartitionIDs[0], collectionID, "", segmentTypeGrowing, true)
|
2020-12-08 14:41:04 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
2021-03-12 14:22:09 +08:00
|
|
|
func initSearchChannel(ctx context.Context, searchChan string, resultChan string, node *QueryNode) {
|
|
|
|
searchReq := &querypb.AddQueryChannelRequest{
|
2021-12-15 16:53:12 +08:00
|
|
|
QueryChannel: searchChan,
|
|
|
|
QueryResultChannel: resultChan,
|
2021-02-09 17:09:26 +08:00
|
|
|
}
|
2021-03-12 14:22:09 +08:00
|
|
|
_, err := node.AddQueryChannel(ctx, searchReq)
|
2021-02-09 17:09:26 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-15 15:28:54 +08:00
|
|
|
func newQueryNodeMock() *QueryNode {
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
var ctx context.Context
|
2020-12-08 14:41:04 +08:00
|
|
|
|
2021-02-05 10:53:11 +08:00
|
|
|
if debug {
|
|
|
|
ctx = context.Background()
|
|
|
|
} else {
|
2020-11-16 17:01:10 +08:00
|
|
|
var cancel context.CancelFunc
|
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel = context.WithDeadline(context.Background(), d)
|
2020-12-10 16:31:09 +08:00
|
|
|
go func() {
|
|
|
|
<-ctx.Done()
|
|
|
|
cancel()
|
|
|
|
}()
|
2020-11-16 17:01:10 +08:00
|
|
|
}
|
|
|
|
|
2021-08-13 11:04:09 +08:00
|
|
|
etcdKV, err := etcdkv.NewEtcdKV(Params.EtcdEndpoints, Params.MetaRootPath)
|
2021-06-19 11:45:09 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-06-09 11:37:55 +08:00
|
|
|
msFactory, err := newMessageStreamFactory()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2021-07-13 14:16:00 +08:00
|
|
|
svr := NewQueryNode(ctx, msFactory)
|
2021-12-17 14:41:33 +08:00
|
|
|
tsReplica := newTSafeReplica()
|
2021-11-06 11:02:58 +08:00
|
|
|
streamingReplica := newCollectionReplica(etcdKV)
|
|
|
|
historicalReplica := newCollectionReplica(etcdKV)
|
2021-11-12 18:27:10 +08:00
|
|
|
svr.historical = newHistorical(svr.queryNodeLoopCtx, historicalReplica, etcdKV, tsReplica)
|
2021-11-06 11:02:58 +08:00
|
|
|
svr.streaming = newStreaming(ctx, streamingReplica, msFactory, etcdKV, tsReplica)
|
|
|
|
svr.dataSyncService = newDataSyncService(ctx, svr.streaming.replica, svr.historical.replica, tsReplica, msFactory)
|
2021-11-12 18:27:10 +08:00
|
|
|
svr.statsService = newStatsService(ctx, svr.historical.replica, nil, msFactory)
|
2021-11-21 07:33:14 +08:00
|
|
|
svr.loader = newSegmentLoader(ctx, nil, nil, svr.historical.replica, svr.streaming.replica, etcdKV, msgstream.NewPmsFactory())
|
2021-07-14 11:15:54 +08:00
|
|
|
svr.etcdKV = etcdKV
|
2021-01-29 15:22:24 +08:00
|
|
|
|
2020-12-08 14:41:04 +08:00
|
|
|
return svr
|
|
|
|
}
|
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
func makeNewChannelNames(names []string, suffix string) []string {
|
|
|
|
var ret []string
|
|
|
|
for _, name := range names {
|
|
|
|
ret = append(ret, name+suffix)
|
|
|
|
}
|
|
|
|
return ret
|
|
|
|
}
|
|
|
|
|
2021-04-02 04:39:23 +08:00
|
|
|
func newMessageStreamFactory() (msgstream.Factory, error) {
|
|
|
|
const receiveBufSize = 1024
|
|
|
|
|
|
|
|
pulsarURL := Params.PulsarAddress
|
|
|
|
msFactory := msgstream.NewPmsFactory()
|
|
|
|
m := map[string]interface{}{
|
|
|
|
"receiveBufSize": receiveBufSize,
|
|
|
|
"pulsarAddress": pulsarURL,
|
|
|
|
"pulsarBufSize": 1024}
|
|
|
|
err := msFactory.SetParams(m)
|
|
|
|
return msFactory, err
|
|
|
|
}
|
|
|
|
|
2020-12-08 14:41:04 +08:00
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
setup()
|
2021-09-23 10:53:53 +08:00
|
|
|
Params.StatsChannelName = Params.StatsChannelName + strconv.Itoa(rand.Int())
|
2020-12-08 14:41:04 +08:00
|
|
|
exitCode := m.Run()
|
|
|
|
os.Exit(exitCode)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE: start pulsar and etcd before test
|
|
|
|
func TestQueryNode_Start(t *testing.T) {
|
2021-01-15 15:28:54 +08:00
|
|
|
localNode := newQueryNodeMock()
|
2021-01-21 15:20:23 +08:00
|
|
|
localNode.Start()
|
2021-02-23 11:40:30 +08:00
|
|
|
<-localNode.queryNodeLoopCtx.Done()
|
2021-01-21 15:20:23 +08:00
|
|
|
localNode.Stop()
|
2020-11-16 17:01:10 +08:00
|
|
|
}
|
2021-09-11 17:26:01 +08:00
|
|
|
|
|
|
|
func TestQueryNode_SetCoord(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
node, err := genSimpleQueryNode(ctx)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = node.SetIndexCoord(nil)
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
err = node.SetRootCoord(nil)
|
|
|
|
assert.Error(t, err)
|
|
|
|
|
|
|
|
// TODO: add mock coords
|
|
|
|
//err = node.SetIndexCoord(newIndexCorrd)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQueryNode_register(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
node, err := genSimpleQueryNode(ctx)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2021-12-15 11:47:10 +08:00
|
|
|
err = node.initSession()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2021-09-11 17:26:01 +08:00
|
|
|
err = node.Register()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQueryNode_init(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
node, err := genSimpleQueryNode(ctx)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = node.Init()
|
2021-11-12 18:27:10 +08:00
|
|
|
assert.Error(t, err)
|
2021-09-11 17:26:01 +08:00
|
|
|
}
|
2021-10-20 17:54:43 +08:00
|
|
|
|
|
|
|
func genSimpleQueryNodeToTestWatchChangeInfo(ctx context.Context) (*QueryNode, error) {
|
|
|
|
node, err := genSimpleQueryNode(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = node.queryService.addQueryCollection(defaultCollectionID)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
qc, err := node.queryService.getQueryCollection(defaultCollectionID)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-11-17 12:13:10 +08:00
|
|
|
qc.globalSegmentManager.addGlobalSegmentInfo(genSimpleSegmentInfo())
|
2021-10-20 17:54:43 +08:00
|
|
|
return node, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQueryNode_waitChangeInfo(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
node, err := genSimpleQueryNodeToTestWatchChangeInfo(ctx)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = node.waitChangeInfo(genSimpleChangeInfo())
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQueryNode_adjustByChangeInfo(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
2021-11-17 12:13:10 +08:00
|
|
|
t.Run("test cleanup segments", func(t *testing.T) {
|
2021-10-20 17:54:43 +08:00
|
|
|
node, err := genSimpleQueryNodeToTestWatchChangeInfo(ctx)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2021-11-17 12:13:10 +08:00
|
|
|
err = node.removeSegments(genSimpleChangeInfo())
|
2021-10-20 17:54:43 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
})
|
|
|
|
|
2021-11-17 12:13:10 +08:00
|
|
|
t.Run("test cleanup segments no segment", func(t *testing.T) {
|
2021-10-20 17:54:43 +08:00
|
|
|
node, err := genSimpleQueryNodeToTestWatchChangeInfo(ctx)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = node.historical.replica.removeSegment(defaultSegmentID)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2021-10-26 15:18:22 +08:00
|
|
|
segmentChangeInfos := genSimpleChangeInfo()
|
|
|
|
segmentChangeInfos.Infos[0].OnlineSegments = nil
|
|
|
|
segmentChangeInfos.Infos[0].OfflineNodeID = Params.QueryNodeID
|
2021-10-20 17:54:43 +08:00
|
|
|
|
|
|
|
qc, err := node.queryService.getQueryCollection(defaultCollectionID)
|
|
|
|
assert.NoError(t, err)
|
2021-11-17 12:13:10 +08:00
|
|
|
qc.globalSegmentManager.removeGlobalSealedSegmentInfo(defaultSegmentID)
|
2021-10-20 17:54:43 +08:00
|
|
|
|
2021-11-17 12:13:10 +08:00
|
|
|
err = node.removeSegments(segmentChangeInfos)
|
2021-10-20 17:54:43 +08:00
|
|
|
assert.Error(t, err)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQueryNode_watchChangeInfo(t *testing.T) {
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
t.Run("test watchChangeInfo", func(t *testing.T) {
|
|
|
|
node, err := genSimpleQueryNodeToTestWatchChangeInfo(ctx)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
go node.watchChangeInfo()
|
|
|
|
|
|
|
|
info := genSimpleSegmentInfo()
|
|
|
|
value, err := proto.Marshal(info)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
err = saveChangeInfo("0", string(value))
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test watchChangeInfo key error", func(t *testing.T) {
|
|
|
|
node, err := genSimpleQueryNodeToTestWatchChangeInfo(ctx)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
go node.watchChangeInfo()
|
|
|
|
|
|
|
|
err = saveChangeInfo("*$&#%^^", "%EUY%&#^$%&@")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test watchChangeInfo unmarshal error", func(t *testing.T) {
|
|
|
|
node, err := genSimpleQueryNodeToTestWatchChangeInfo(ctx)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
go node.watchChangeInfo()
|
|
|
|
|
|
|
|
err = saveChangeInfo("0", "$%^$*&%^#$&*")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test watchChangeInfo adjustByChangeInfo error", func(t *testing.T) {
|
|
|
|
node, err := genSimpleQueryNodeToTestWatchChangeInfo(ctx)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = node.historical.replica.removeSegment(defaultSegmentID)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2021-10-26 15:18:22 +08:00
|
|
|
segmentChangeInfos := genSimpleChangeInfo()
|
|
|
|
segmentChangeInfos.Infos[0].OnlineSegments = nil
|
|
|
|
segmentChangeInfos.Infos[0].OfflineNodeID = Params.QueryNodeID
|
2021-10-20 17:54:43 +08:00
|
|
|
|
|
|
|
qc, err := node.queryService.getQueryCollection(defaultCollectionID)
|
|
|
|
assert.NoError(t, err)
|
2021-11-17 12:13:10 +08:00
|
|
|
qc.globalSegmentManager.removeGlobalSealedSegmentInfo(defaultSegmentID)
|
2021-10-20 17:54:43 +08:00
|
|
|
|
|
|
|
go node.watchChangeInfo()
|
|
|
|
|
2021-10-26 15:18:22 +08:00
|
|
|
value, err := proto.Marshal(segmentChangeInfos)
|
2021-10-20 17:54:43 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
err = saveChangeInfo("0", string(value))
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
})
|
|
|
|
}
|