2020-11-26 16:01:31 +08:00
|
|
|
package querynode
|
2020-11-05 10:52:50 +08:00
|
|
|
|
2020-11-16 17:01:10 +08:00
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"math"
|
2020-12-07 15:22:20 +08:00
|
|
|
"os"
|
2020-11-16 17:01:10 +08:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
"github.com/golang/protobuf/proto"
|
2020-11-16 17:01:10 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
2020-12-07 15:22:20 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
|
2020-11-16 17:01:10 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/etcdpb"
|
2020-12-07 15:22:20 +08:00
|
|
|
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
|
2020-11-16 17:01:10 +08:00
|
|
|
)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
Params.Init()
|
|
|
|
exitCode := m.Run()
|
|
|
|
os.Exit(exitCode)
|
|
|
|
}
|
|
|
|
|
2020-11-16 17:01:10 +08:00
|
|
|
func TestMetaService_start(t *testing.T) {
|
|
|
|
var ctx context.Context
|
|
|
|
|
|
|
|
if closeWithDeadline {
|
|
|
|
var cancel context.CancelFunc
|
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel = context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
} else {
|
|
|
|
ctx = context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
// init query node
|
2020-11-17 20:00:23 +08:00
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
(*node.metaService).start()
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_getCollectionObjId(t *testing.T) {
|
|
|
|
var key = "/collection/collection0"
|
|
|
|
var collectionObjID1 = GetCollectionObjID(key)
|
|
|
|
|
|
|
|
assert.Equal(t, collectionObjID1, "/collection/collection0")
|
|
|
|
|
|
|
|
key = "fakeKey"
|
|
|
|
var collectionObjID2 = GetCollectionObjID(key)
|
|
|
|
|
|
|
|
assert.Equal(t, collectionObjID2, "fakeKey")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_getSegmentObjId(t *testing.T) {
|
|
|
|
var key = "/segment/segment0"
|
|
|
|
var segmentObjID1 = GetSegmentObjID(key)
|
|
|
|
|
|
|
|
assert.Equal(t, segmentObjID1, "/segment/segment0")
|
|
|
|
|
|
|
|
key = "fakeKey"
|
|
|
|
var segmentObjID2 = GetSegmentObjID(key)
|
|
|
|
|
|
|
|
assert.Equal(t, segmentObjID2, "fakeKey")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_isCollectionObj(t *testing.T) {
|
2020-11-28 19:06:48 +08:00
|
|
|
var key = "by-dev/meta/collection/collection0"
|
2020-11-16 17:01:10 +08:00
|
|
|
var b1 = isCollectionObj(key)
|
|
|
|
|
|
|
|
assert.Equal(t, b1, true)
|
|
|
|
|
2020-11-28 19:06:48 +08:00
|
|
|
key = "by-dev/meta/segment/segment0"
|
2020-11-16 17:01:10 +08:00
|
|
|
var b2 = isCollectionObj(key)
|
|
|
|
|
|
|
|
assert.Equal(t, b2, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_isSegmentObj(t *testing.T) {
|
2020-11-28 19:06:48 +08:00
|
|
|
var key = "by-dev/meta/segment/segment0"
|
2020-11-16 17:01:10 +08:00
|
|
|
var b1 = isSegmentObj(key)
|
|
|
|
|
|
|
|
assert.Equal(t, b1, true)
|
|
|
|
|
2020-11-28 19:06:48 +08:00
|
|
|
key = "by-dev/meta/collection/collection0"
|
2020-11-16 17:01:10 +08:00
|
|
|
var b2 = isSegmentObj(key)
|
|
|
|
|
|
|
|
assert.Equal(t, b2, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_isSegmentChannelRangeInQueryNodeChannelRange(t *testing.T) {
|
|
|
|
var s = etcdpb.SegmentMeta{
|
|
|
|
SegmentID: UniqueID(0),
|
|
|
|
CollectionID: UniqueID(0),
|
|
|
|
PartitionTag: "partition0",
|
|
|
|
ChannelStart: 0,
|
2020-11-26 16:01:31 +08:00
|
|
|
ChannelEnd: 1,
|
2020-11-16 17:01:10 +08:00
|
|
|
OpenTime: Timestamp(0),
|
|
|
|
CloseTime: Timestamp(math.MaxUint64),
|
|
|
|
NumRows: UniqueID(0),
|
|
|
|
}
|
|
|
|
|
|
|
|
var b = isSegmentChannelRangeInQueryNodeChannelRange(&s)
|
|
|
|
assert.Equal(t, b, true)
|
|
|
|
|
|
|
|
s = etcdpb.SegmentMeta{
|
|
|
|
SegmentID: UniqueID(0),
|
|
|
|
CollectionID: UniqueID(0),
|
|
|
|
PartitionTag: "partition0",
|
|
|
|
ChannelStart: 128,
|
|
|
|
ChannelEnd: 256,
|
|
|
|
OpenTime: Timestamp(0),
|
|
|
|
CloseTime: Timestamp(math.MaxUint64),
|
|
|
|
NumRows: UniqueID(0),
|
|
|
|
}
|
|
|
|
|
|
|
|
b = isSegmentChannelRangeInQueryNodeChannelRange(&s)
|
|
|
|
assert.Equal(t, b, false)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_printCollectionStruct(t *testing.T) {
|
|
|
|
collectionName := "collection0"
|
2020-12-07 15:22:20 +08:00
|
|
|
fieldVec := schemapb.FieldSchema{
|
|
|
|
Name: "vec",
|
|
|
|
IsPrimaryKey: false,
|
|
|
|
DataType: schemapb.DataType_VECTOR_FLOAT,
|
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "dim",
|
|
|
|
Value: "16",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
fieldInt := schemapb.FieldSchema{
|
|
|
|
Name: "age",
|
|
|
|
IsPrimaryKey: false,
|
|
|
|
DataType: schemapb.DataType_INT32,
|
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "dim",
|
|
|
|
Value: "1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
schema := schemapb.CollectionSchema{
|
|
|
|
Name: collectionName,
|
|
|
|
AutoID: true,
|
|
|
|
Fields: []*schemapb.FieldSchema{
|
|
|
|
&fieldVec, &fieldInt,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
collectionMeta := etcdpb.CollectionMeta{
|
|
|
|
ID: UniqueID(0),
|
|
|
|
Schema: &schema,
|
|
|
|
CreateTime: Timestamp(0),
|
|
|
|
SegmentIDs: []UniqueID{0},
|
|
|
|
PartitionTags: []string{"default"},
|
|
|
|
}
|
|
|
|
|
|
|
|
printCollectionStruct(&collectionMeta)
|
2020-11-16 17:01:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_printSegmentStruct(t *testing.T) {
|
|
|
|
var s = etcdpb.SegmentMeta{
|
|
|
|
SegmentID: UniqueID(0),
|
|
|
|
CollectionID: UniqueID(0),
|
|
|
|
PartitionTag: "partition0",
|
|
|
|
ChannelStart: 128,
|
|
|
|
ChannelEnd: 256,
|
|
|
|
OpenTime: Timestamp(0),
|
|
|
|
CloseTime: Timestamp(math.MaxUint64),
|
|
|
|
NumRows: UniqueID(0),
|
|
|
|
}
|
|
|
|
|
|
|
|
printSegmentStruct(&s)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_processCollectionCreate(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel := context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
id := "0"
|
|
|
|
value := `schema: <
|
|
|
|
name: "test"
|
|
|
|
fields: <
|
|
|
|
name: "vec"
|
|
|
|
data_type: VECTOR_FLOAT
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "16"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
fields: <
|
|
|
|
name: "age"
|
|
|
|
data_type: INT32
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "1"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
segmentIDs: 0
|
|
|
|
partition_tags: "default"
|
|
|
|
`
|
|
|
|
|
|
|
|
node.metaService.processCollectionCreate(id, value)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
collectionNum := (*node.replica).getCollectionNum()
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.Equal(t, collectionNum, 1)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
collection, err := (*node.replica).getCollectionByName("test")
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, collection.ID(), UniqueID(0))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_processSegmentCreate(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel := context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
|
|
|
|
2020-11-16 17:01:10 +08:00
|
|
|
collectionName := "collection0"
|
2020-12-07 15:22:20 +08:00
|
|
|
fieldVec := schemapb.FieldSchema{
|
|
|
|
Name: "vec",
|
|
|
|
IsPrimaryKey: false,
|
|
|
|
DataType: schemapb.DataType_VECTOR_FLOAT,
|
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "dim",
|
|
|
|
Value: "16",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
fieldInt := schemapb.FieldSchema{
|
|
|
|
Name: "age",
|
|
|
|
IsPrimaryKey: false,
|
|
|
|
DataType: schemapb.DataType_INT32,
|
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "dim",
|
|
|
|
Value: "1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
schema := schemapb.CollectionSchema{
|
|
|
|
Name: collectionName,
|
|
|
|
AutoID: true,
|
|
|
|
Fields: []*schemapb.FieldSchema{
|
|
|
|
&fieldVec, &fieldInt,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
collectionMeta := etcdpb.CollectionMeta{
|
|
|
|
ID: UniqueID(0),
|
|
|
|
Schema: &schema,
|
|
|
|
CreateTime: Timestamp(0),
|
|
|
|
SegmentIDs: []UniqueID{0},
|
|
|
|
PartitionTags: []string{"default"},
|
|
|
|
}
|
|
|
|
|
|
|
|
colMetaBlob := proto.MarshalTextString(&collectionMeta)
|
|
|
|
|
|
|
|
err := (*node.replica).addCollection(&collectionMeta, string(colMetaBlob))
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = (*node.replica).addPartition(UniqueID(0), "default")
|
|
|
|
assert.NoError(t, err)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
id := "0"
|
|
|
|
value := `partition_tag: "default"
|
|
|
|
channel_start: 0
|
2020-11-26 16:01:31 +08:00
|
|
|
channel_end: 1
|
2020-11-16 17:01:10 +08:00
|
|
|
close_time: 18446744073709551615
|
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processSegmentCreate(id, value)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
s, err := (*node.replica).getSegmentByID(UniqueID(0))
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, s.segmentID, UniqueID(0))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_processCreate(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel := context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
2020-11-28 19:06:48 +08:00
|
|
|
key1 := "by-dev/meta/collection/0"
|
2020-11-16 17:01:10 +08:00
|
|
|
msg1 := `schema: <
|
|
|
|
name: "test"
|
|
|
|
fields: <
|
|
|
|
name: "vec"
|
|
|
|
data_type: VECTOR_FLOAT
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "16"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
fields: <
|
|
|
|
name: "age"
|
|
|
|
data_type: INT32
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "1"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
segmentIDs: 0
|
|
|
|
partition_tags: "default"
|
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processCreate(key1, msg1)
|
2020-12-07 15:22:20 +08:00
|
|
|
collectionNum := (*node.replica).getCollectionNum()
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.Equal(t, collectionNum, 1)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
collection, err := (*node.replica).getCollectionByName("test")
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, collection.ID(), UniqueID(0))
|
|
|
|
|
2020-11-28 19:06:48 +08:00
|
|
|
key2 := "by-dev/meta/segment/0"
|
2020-11-16 17:01:10 +08:00
|
|
|
msg2 := `partition_tag: "default"
|
|
|
|
channel_start: 0
|
2020-11-26 16:01:31 +08:00
|
|
|
channel_end: 1
|
2020-11-16 17:01:10 +08:00
|
|
|
close_time: 18446744073709551615
|
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processCreate(key2, msg2)
|
2020-12-07 15:22:20 +08:00
|
|
|
s, err := (*node.replica).getSegmentByID(UniqueID(0))
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, s.segmentID, UniqueID(0))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_processSegmentModify(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel := context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
|
|
|
|
2020-11-16 17:01:10 +08:00
|
|
|
collectionName := "collection0"
|
2020-12-07 15:22:20 +08:00
|
|
|
fieldVec := schemapb.FieldSchema{
|
|
|
|
Name: "vec",
|
|
|
|
IsPrimaryKey: false,
|
|
|
|
DataType: schemapb.DataType_VECTOR_FLOAT,
|
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "dim",
|
|
|
|
Value: "16",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
fieldInt := schemapb.FieldSchema{
|
|
|
|
Name: "age",
|
|
|
|
IsPrimaryKey: false,
|
|
|
|
DataType: schemapb.DataType_INT32,
|
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "dim",
|
|
|
|
Value: "1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
schema := schemapb.CollectionSchema{
|
|
|
|
Name: collectionName,
|
|
|
|
AutoID: true,
|
|
|
|
Fields: []*schemapb.FieldSchema{
|
|
|
|
&fieldVec, &fieldInt,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
collectionMeta := etcdpb.CollectionMeta{
|
|
|
|
ID: UniqueID(0),
|
|
|
|
Schema: &schema,
|
|
|
|
CreateTime: Timestamp(0),
|
|
|
|
SegmentIDs: []UniqueID{0},
|
|
|
|
PartitionTags: []string{"default"},
|
|
|
|
}
|
|
|
|
|
|
|
|
colMetaBlob := proto.MarshalTextString(&collectionMeta)
|
|
|
|
|
|
|
|
err := (*node.replica).addCollection(&collectionMeta, string(colMetaBlob))
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = (*node.replica).addPartition(UniqueID(0), "default")
|
|
|
|
assert.NoError(t, err)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
id := "0"
|
|
|
|
value := `partition_tag: "default"
|
|
|
|
channel_start: 0
|
2020-11-26 16:01:31 +08:00
|
|
|
channel_end: 1
|
2020-11-16 17:01:10 +08:00
|
|
|
close_time: 18446744073709551615
|
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processSegmentCreate(id, value)
|
2020-12-07 15:22:20 +08:00
|
|
|
s, err := (*node.replica).getSegmentByID(UniqueID(0))
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-07 15:22:20 +08:00
|
|
|
assert.Equal(t, s.segmentID, UniqueID(0))
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
newValue := `partition_tag: "default"
|
|
|
|
channel_start: 0
|
2020-11-26 16:01:31 +08:00
|
|
|
channel_end: 1
|
2020-11-16 17:01:10 +08:00
|
|
|
close_time: 18446744073709551615
|
|
|
|
`
|
|
|
|
|
|
|
|
// TODO: modify segment for testing processCollectionModify
|
|
|
|
(*node.metaService).processSegmentModify(id, newValue)
|
2020-12-07 15:22:20 +08:00
|
|
|
seg, err := (*node.replica).getSegmentByID(UniqueID(0))
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-07 15:22:20 +08:00
|
|
|
assert.Equal(t, seg.segmentID, UniqueID(0))
|
2020-11-16 17:01:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_processCollectionModify(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel := context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
id := "0"
|
|
|
|
value := `schema: <
|
|
|
|
name: "test"
|
|
|
|
fields: <
|
|
|
|
name: "vec"
|
|
|
|
data_type: VECTOR_FLOAT
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "16"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
fields: <
|
|
|
|
name: "age"
|
|
|
|
data_type: INT32
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "1"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
segmentIDs: 0
|
2020-11-25 10:31:51 +08:00
|
|
|
partition_tags: "p0"
|
|
|
|
partition_tags: "p1"
|
|
|
|
partition_tags: "p2"
|
2020-11-16 17:01:10 +08:00
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processCollectionCreate(id, value)
|
2020-12-07 15:22:20 +08:00
|
|
|
collectionNum := (*node.replica).getCollectionNum()
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.Equal(t, collectionNum, 1)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
collection, err := (*node.replica).getCollectionByName("test")
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, collection.ID(), UniqueID(0))
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
partitionNum, err := (*node.replica).getPartitionNum(UniqueID(0))
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, partitionNum, 3)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition := (*node.replica).hasPartition(UniqueID(0), "p0")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p1")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p2")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p3")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, false)
|
|
|
|
|
2020-11-16 17:01:10 +08:00
|
|
|
newValue := `schema: <
|
|
|
|
name: "test"
|
|
|
|
fields: <
|
|
|
|
name: "vec"
|
|
|
|
data_type: VECTOR_FLOAT
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "16"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
fields: <
|
|
|
|
name: "age"
|
|
|
|
data_type: INT32
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "1"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
segmentIDs: 0
|
2020-11-25 10:31:51 +08:00
|
|
|
partition_tags: "p1"
|
|
|
|
partition_tags: "p2"
|
|
|
|
partition_tags: "p3"
|
2020-11-16 17:01:10 +08:00
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processCollectionModify(id, newValue)
|
2020-12-07 15:22:20 +08:00
|
|
|
collection, err = (*node.replica).getCollectionByName("test")
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, collection.ID(), UniqueID(0))
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
partitionNum, err = (*node.replica).getPartitionNum(UniqueID(0))
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, partitionNum, 3)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p0")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, false)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p1")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p2")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p3")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-11-16 17:01:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_processModify(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel := context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
2020-11-28 19:06:48 +08:00
|
|
|
key1 := "by-dev/meta/collection/0"
|
2020-11-16 17:01:10 +08:00
|
|
|
msg1 := `schema: <
|
|
|
|
name: "test"
|
|
|
|
fields: <
|
|
|
|
name: "vec"
|
|
|
|
data_type: VECTOR_FLOAT
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "16"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
fields: <
|
|
|
|
name: "age"
|
|
|
|
data_type: INT32
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "1"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
segmentIDs: 0
|
2020-11-25 10:31:51 +08:00
|
|
|
partition_tags: "p0"
|
|
|
|
partition_tags: "p1"
|
|
|
|
partition_tags: "p2"
|
2020-11-16 17:01:10 +08:00
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processCreate(key1, msg1)
|
2020-12-07 15:22:20 +08:00
|
|
|
collectionNum := (*node.replica).getCollectionNum()
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.Equal(t, collectionNum, 1)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
collection, err := (*node.replica).getCollectionByName("test")
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, collection.ID(), UniqueID(0))
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
partitionNum, err := (*node.replica).getPartitionNum(UniqueID(0))
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, partitionNum, 3)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition := (*node.replica).hasPartition(UniqueID(0), "p0")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p1")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p2")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p3")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, false)
|
|
|
|
|
2020-11-28 19:06:48 +08:00
|
|
|
key2 := "by-dev/meta/segment/0"
|
2020-11-25 10:31:51 +08:00
|
|
|
msg2 := `partition_tag: "p1"
|
2020-11-16 17:01:10 +08:00
|
|
|
channel_start: 0
|
2020-11-26 16:01:31 +08:00
|
|
|
channel_end: 1
|
2020-11-16 17:01:10 +08:00
|
|
|
close_time: 18446744073709551615
|
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processCreate(key2, msg2)
|
2020-12-07 15:22:20 +08:00
|
|
|
s, err := (*node.replica).getSegmentByID(UniqueID(0))
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, s.segmentID, UniqueID(0))
|
|
|
|
|
|
|
|
// modify
|
|
|
|
// TODO: use different index for testing processCollectionModify
|
|
|
|
msg3 := `schema: <
|
|
|
|
name: "test"
|
|
|
|
fields: <
|
|
|
|
name: "vec"
|
|
|
|
data_type: VECTOR_FLOAT
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "16"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
fields: <
|
|
|
|
name: "age"
|
|
|
|
data_type: INT32
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "1"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
segmentIDs: 0
|
2020-11-25 10:31:51 +08:00
|
|
|
partition_tags: "p1"
|
|
|
|
partition_tags: "p2"
|
|
|
|
partition_tags: "p3"
|
2020-11-16 17:01:10 +08:00
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processModify(key1, msg3)
|
2020-12-07 15:22:20 +08:00
|
|
|
collection, err = (*node.replica).getCollectionByName("test")
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, collection.ID(), UniqueID(0))
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
partitionNum, err = (*node.replica).getPartitionNum(UniqueID(0))
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, partitionNum, 3)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p0")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, false)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p1")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p2")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-07 15:22:20 +08:00
|
|
|
hasPartition = (*node.replica).hasPartition(UniqueID(0), "p3")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
|
|
|
|
|
|
|
msg4 := `partition_tag: "p1"
|
2020-11-16 17:01:10 +08:00
|
|
|
channel_start: 0
|
2020-11-26 16:01:31 +08:00
|
|
|
channel_end: 1
|
2020-11-16 17:01:10 +08:00
|
|
|
close_time: 18446744073709551615
|
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processModify(key2, msg4)
|
2020-12-07 15:22:20 +08:00
|
|
|
seg, err := (*node.replica).getSegmentByID(UniqueID(0))
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, seg.segmentID, UniqueID(0))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_processSegmentDelete(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel := context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
|
|
|
|
2020-11-16 17:01:10 +08:00
|
|
|
collectionName := "collection0"
|
2020-12-07 15:22:20 +08:00
|
|
|
fieldVec := schemapb.FieldSchema{
|
|
|
|
Name: "vec",
|
|
|
|
IsPrimaryKey: false,
|
|
|
|
DataType: schemapb.DataType_VECTOR_FLOAT,
|
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "dim",
|
|
|
|
Value: "16",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
fieldInt := schemapb.FieldSchema{
|
|
|
|
Name: "age",
|
|
|
|
IsPrimaryKey: false,
|
|
|
|
DataType: schemapb.DataType_INT32,
|
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: "dim",
|
|
|
|
Value: "1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
schema := schemapb.CollectionSchema{
|
|
|
|
Name: collectionName,
|
|
|
|
AutoID: true,
|
|
|
|
Fields: []*schemapb.FieldSchema{
|
|
|
|
&fieldVec, &fieldInt,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
collectionMeta := etcdpb.CollectionMeta{
|
|
|
|
ID: UniqueID(0),
|
|
|
|
Schema: &schema,
|
|
|
|
CreateTime: Timestamp(0),
|
|
|
|
SegmentIDs: []UniqueID{0},
|
|
|
|
PartitionTags: []string{"default"},
|
|
|
|
}
|
|
|
|
|
|
|
|
colMetaBlob := proto.MarshalTextString(&collectionMeta)
|
|
|
|
|
|
|
|
err := (*node.replica).addCollection(&collectionMeta, string(colMetaBlob))
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = (*node.replica).addPartition(UniqueID(0), "default")
|
|
|
|
assert.NoError(t, err)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
id := "0"
|
|
|
|
value := `partition_tag: "default"
|
|
|
|
channel_start: 0
|
2020-11-26 16:01:31 +08:00
|
|
|
channel_end: 1
|
2020-11-16 17:01:10 +08:00
|
|
|
close_time: 18446744073709551615
|
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processSegmentCreate(id, value)
|
2020-12-07 15:22:20 +08:00
|
|
|
seg, err := (*node.replica).getSegmentByID(UniqueID(0))
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, seg.segmentID, UniqueID(0))
|
|
|
|
|
|
|
|
(*node.metaService).processSegmentDelete("0")
|
2020-12-07 15:22:20 +08:00
|
|
|
mapSize := (*node.replica).getSegmentNum()
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.Equal(t, mapSize, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_processCollectionDelete(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel := context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
id := "0"
|
|
|
|
value := `schema: <
|
|
|
|
name: "test"
|
|
|
|
fields: <
|
|
|
|
name: "vec"
|
|
|
|
data_type: VECTOR_FLOAT
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "16"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
fields: <
|
|
|
|
name: "age"
|
|
|
|
data_type: INT32
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "1"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
segmentIDs: 0
|
|
|
|
partition_tags: "default"
|
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processCollectionCreate(id, value)
|
2020-12-07 15:22:20 +08:00
|
|
|
collectionNum := (*node.replica).getCollectionNum()
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.Equal(t, collectionNum, 1)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
collection, err := (*node.replica).getCollectionByName("test")
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, collection.ID(), UniqueID(0))
|
|
|
|
|
|
|
|
(*node.metaService).processCollectionDelete(id)
|
2020-12-07 15:22:20 +08:00
|
|
|
collectionNum = (*node.replica).getCollectionNum()
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.Equal(t, collectionNum, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_processDelete(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel := context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
2020-11-28 19:06:48 +08:00
|
|
|
key1 := "by-dev/meta/collection/0"
|
2020-11-16 17:01:10 +08:00
|
|
|
msg1 := `schema: <
|
|
|
|
name: "test"
|
|
|
|
fields: <
|
|
|
|
name: "vec"
|
|
|
|
data_type: VECTOR_FLOAT
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "16"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
fields: <
|
|
|
|
name: "age"
|
|
|
|
data_type: INT32
|
|
|
|
type_params: <
|
|
|
|
key: "dim"
|
|
|
|
value: "1"
|
|
|
|
>
|
|
|
|
>
|
|
|
|
>
|
|
|
|
segmentIDs: 0
|
|
|
|
partition_tags: "default"
|
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processCreate(key1, msg1)
|
2020-12-07 15:22:20 +08:00
|
|
|
collectionNum := (*node.replica).getCollectionNum()
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.Equal(t, collectionNum, 1)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
collection, err := (*node.replica).getCollectionByName("test")
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, collection.ID(), UniqueID(0))
|
|
|
|
|
2020-11-28 19:06:48 +08:00
|
|
|
key2 := "by-dev/meta/segment/0"
|
2020-11-16 17:01:10 +08:00
|
|
|
msg2 := `partition_tag: "default"
|
|
|
|
channel_start: 0
|
2020-11-26 16:01:31 +08:00
|
|
|
channel_end: 1
|
2020-11-16 17:01:10 +08:00
|
|
|
close_time: 18446744073709551615
|
|
|
|
`
|
|
|
|
|
|
|
|
(*node.metaService).processCreate(key2, msg2)
|
2020-12-07 15:22:20 +08:00
|
|
|
seg, err := (*node.replica).getSegmentByID(UniqueID(0))
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, seg.segmentID, UniqueID(0))
|
|
|
|
|
|
|
|
(*node.metaService).processDelete(key1)
|
2020-12-07 15:22:20 +08:00
|
|
|
collectionsSize := (*node.replica).getCollectionNum()
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.Equal(t, collectionsSize, 0)
|
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
mapSize := (*node.replica).getSegmentNum()
|
2020-11-16 17:01:10 +08:00
|
|
|
assert.Equal(t, mapSize, 0)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_processResp(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
var ctx context.Context
|
|
|
|
if closeWithDeadline {
|
|
|
|
var cancel context.CancelFunc
|
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel = context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
} else {
|
|
|
|
ctx = context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
metaChan := (*node.metaService).kvBase.WatchWithPrefix("")
|
|
|
|
|
|
|
|
select {
|
2020-12-07 15:22:20 +08:00
|
|
|
case <-node.ctx.Done():
|
2020-11-16 17:01:10 +08:00
|
|
|
return
|
|
|
|
case resp := <-metaChan:
|
|
|
|
_ = (*node.metaService).processResp(resp)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_loadCollections(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
var ctx context.Context
|
|
|
|
if closeWithDeadline {
|
|
|
|
var cancel context.CancelFunc
|
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel = context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
} else {
|
|
|
|
ctx = context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
err2 := (*node.metaService).loadCollections()
|
|
|
|
assert.Nil(t, err2)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMetaService_loadSegments(t *testing.T) {
|
2020-12-07 15:22:20 +08:00
|
|
|
var ctx context.Context
|
|
|
|
if closeWithDeadline {
|
|
|
|
var cancel context.CancelFunc
|
|
|
|
d := time.Now().Add(ctxTimeInMillisecond * time.Millisecond)
|
|
|
|
ctx, cancel = context.WithDeadline(context.Background(), d)
|
|
|
|
defer cancel()
|
|
|
|
} else {
|
|
|
|
ctx = context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
// init metaService
|
|
|
|
node := NewQueryNode(ctx, 0)
|
|
|
|
node.metaService = newMetaService(ctx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
err2 := (*node.metaService).loadSegments()
|
|
|
|
assert.Nil(t, err2)
|
|
|
|
}
|