2020-11-26 16:01:31 +08:00
|
|
|
package querynode
|
2020-11-12 11:18:23 +08:00
|
|
|
|
|
|
|
import (
|
2020-11-12 12:04:12 +08:00
|
|
|
"testing"
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------- collection
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_getCollectionNum(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
|
|
|
initTestMeta(t, node, "collection0", 0, 0)
|
|
|
|
assert.Equal(t, node.replica.getCollectionNum(), 1)
|
|
|
|
node.Close()
|
2020-11-25 10:31:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCollectionReplica_addCollection(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
|
|
|
initTestMeta(t, node, "collection0", 0, 0)
|
|
|
|
node.Close()
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_removeCollection(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
|
|
|
initTestMeta(t, node, "collection0", 0, 0)
|
|
|
|
assert.Equal(t, node.replica.getCollectionNum(), 1)
|
2020-11-12 11:18:23 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
err := node.replica.removeCollection(0)
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
assert.Equal(t, node.replica.getCollectionNum(), 0)
|
|
|
|
node.Close()
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_getCollectionByID(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-13 17:20:13 +08:00
|
|
|
collectionName := "collection0"
|
2020-12-04 14:18:17 +08:00
|
|
|
collectionID := UniqueID(0)
|
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
|
|
|
targetCollection, err := node.replica.getCollectionByID(collectionID)
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, targetCollection)
|
2020-12-04 14:18:17 +08:00
|
|
|
assert.Equal(t, targetCollection.meta.Schema.Name, collectionName)
|
|
|
|
assert.Equal(t, targetCollection.meta.ID, collectionID)
|
|
|
|
node.Close()
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_getCollectionByName(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-13 17:20:13 +08:00
|
|
|
collectionName := "collection0"
|
2020-12-04 14:18:17 +08:00
|
|
|
collectionID := UniqueID(0)
|
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-12 11:18:23 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
targetCollection, err := node.replica.getCollectionByName(collectionName)
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, targetCollection)
|
2020-12-04 14:18:17 +08:00
|
|
|
assert.Equal(t, targetCollection.meta.Schema.Name, collectionName)
|
|
|
|
assert.Equal(t, targetCollection.meta.ID, collectionID)
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-25 10:31:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCollectionReplica_hasCollection(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-25 10:31:51 +08:00
|
|
|
collectionName := "collection0"
|
2020-12-04 14:18:17 +08:00
|
|
|
collectionID := UniqueID(0)
|
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
hasCollection := node.replica.hasCollection(collectionID)
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasCollection, true)
|
2020-12-04 14:18:17 +08:00
|
|
|
hasCollection = node.replica.hasCollection(UniqueID(1))
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasCollection, false)
|
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-24 15:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
//----------------------------------------------------------------------------------------------------- partition
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_getPartitionNum(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-24 15:59:51 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-24 15:59:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
partitionTags := []string{"a", "b", "c"}
|
|
|
|
for _, tag := range partitionTags {
|
|
|
|
err := node.replica.addPartition(collectionID, tag)
|
2020-11-24 15:59:51 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
partition, err := node.replica.getPartitionByTag(collectionID, tag)
|
2020-11-24 15:59:51 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
assert.Equal(t, partition.partitionTag, tag)
|
2020-11-24 15:59:51 +08:00
|
|
|
}
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
partitionNum, err := node.replica.getPartitionNum(collectionID)
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
assert.Equal(t, partitionNum, len(partitionTags)+1) // _default
|
|
|
|
node.Close()
|
2020-11-24 15:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_addPartition(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-25 10:31:51 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
partitionTags := []string{"a", "b", "c"}
|
|
|
|
for _, tag := range partitionTags {
|
|
|
|
err := node.replica.addPartition(collectionID, tag)
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
partition, err := node.replica.getPartitionByTag(collectionID, tag)
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
assert.Equal(t, partition.partitionTag, tag)
|
2020-11-25 10:31:51 +08:00
|
|
|
}
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-25 10:31:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCollectionReplica_removePartition(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-13 17:20:13 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-13 17:20:13 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
partitionTags := []string{"a", "b", "c"}
|
2020-11-12 11:18:23 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
for _, tag := range partitionTags {
|
|
|
|
err := node.replica.addPartition(collectionID, tag)
|
2020-11-13 17:20:13 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
partition, err := node.replica.getPartitionByTag(collectionID, tag)
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
assert.Equal(t, partition.partitionTag, tag)
|
|
|
|
err = node.replica.removePartition(collectionID, tag)
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-25 10:31:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCollectionReplica_addPartitionsByCollectionMeta(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-25 10:31:51 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
collectionMeta := genTestCollectionMeta(collectionName, collectionID)
|
2020-11-25 10:31:51 +08:00
|
|
|
collectionMeta.PartitionTags = []string{"p0", "p1", "p2"}
|
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
err := node.replica.addPartitionsByCollectionMeta(collectionMeta)
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
partitionNum, err := node.replica.getPartitionNum(UniqueID(0))
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
assert.Equal(t, partitionNum, len(collectionMeta.PartitionTags)+1)
|
|
|
|
hasPartition := node.replica.hasPartition(UniqueID(0), "p0")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-04 14:18:17 +08:00
|
|
|
hasPartition = node.replica.hasPartition(UniqueID(0), "p1")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-04 14:18:17 +08:00
|
|
|
hasPartition = node.replica.hasPartition(UniqueID(0), "p2")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-25 10:31:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCollectionReplica_removePartitionsByCollectionMeta(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-25 10:31:51 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
collectionMeta := genTestCollectionMeta(collectionName, collectionID)
|
2020-11-25 10:31:51 +08:00
|
|
|
collectionMeta.PartitionTags = []string{"p0"}
|
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
err := node.replica.addPartitionsByCollectionMeta(collectionMeta)
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
partitionNum, err := node.replica.getPartitionNum(UniqueID(0))
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
assert.Equal(t, partitionNum, len(collectionMeta.PartitionTags)+1)
|
|
|
|
|
|
|
|
hasPartition := node.replica.hasPartition(UniqueID(0), "p0")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-04 14:18:17 +08:00
|
|
|
hasPartition = node.replica.hasPartition(UniqueID(0), "p1")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, false)
|
2020-12-04 14:18:17 +08:00
|
|
|
hasPartition = node.replica.hasPartition(UniqueID(0), "p2")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, false)
|
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-24 15:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_getPartitionByTag(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-13 17:20:13 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-13 17:20:13 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
collectionMeta := genTestCollectionMeta(collectionName, collectionID)
|
2020-11-12 11:18:23 +08:00
|
|
|
|
|
|
|
for _, tag := range collectionMeta.PartitionTags {
|
2020-12-04 14:18:17 +08:00
|
|
|
err := node.replica.addPartition(collectionID, tag)
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
partition, err := node.replica.getPartitionByTag(collectionID, tag)
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
assert.Equal(t, partition.partitionTag, tag)
|
2020-11-13 17:20:13 +08:00
|
|
|
assert.NotNil(t, partition)
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-25 10:31:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCollectionReplica_hasPartition(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-25 10:31:51 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
collectionMeta := genTestCollectionMeta(collectionName, collectionID)
|
|
|
|
err := node.replica.addPartition(collectionID, collectionMeta.PartitionTags[0])
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
hasPartition := node.replica.hasPartition(collectionID, "default")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, true)
|
2020-12-04 14:18:17 +08:00
|
|
|
hasPartition = node.replica.hasPartition(collectionID, "default1")
|
2020-11-25 10:31:51 +08:00
|
|
|
assert.Equal(t, hasPartition, false)
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-24 15:59:51 +08:00
|
|
|
}
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
//----------------------------------------------------------------------------------------------------- segment
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_addSegment(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-13 17:20:13 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-12 11:18:23 +08:00
|
|
|
|
|
|
|
const segmentNum = 3
|
2020-12-04 14:18:17 +08:00
|
|
|
tag := "default"
|
2020-11-12 11:18:23 +08:00
|
|
|
for i := 0; i < segmentNum; i++ {
|
2020-12-04 14:18:17 +08:00
|
|
|
err := node.replica.addSegment(UniqueID(i), tag, collectionID)
|
2020-11-13 17:20:13 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
targetSeg, err := node.replica.getSegmentByID(UniqueID(i))
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, targetSeg.segmentID, UniqueID(i))
|
|
|
|
}
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_removeSegment(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-13 17:20:13 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-12 11:18:23 +08:00
|
|
|
|
|
|
|
const segmentNum = 3
|
2020-12-04 14:18:17 +08:00
|
|
|
tag := "default"
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
for i := 0; i < segmentNum; i++ {
|
2020-12-04 14:18:17 +08:00
|
|
|
err := node.replica.addSegment(UniqueID(i), tag, collectionID)
|
2020-11-13 17:20:13 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
targetSeg, err := node.replica.getSegmentByID(UniqueID(i))
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, targetSeg.segmentID, UniqueID(i))
|
2020-12-04 14:18:17 +08:00
|
|
|
err = node.replica.removeSegment(UniqueID(i))
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-24 16:12:39 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_getSegmentByID(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-24 16:12:39 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-24 16:12:39 +08:00
|
|
|
|
|
|
|
const segmentNum = 3
|
2020-12-04 14:18:17 +08:00
|
|
|
tag := "default"
|
|
|
|
|
2020-11-24 16:12:39 +08:00
|
|
|
for i := 0; i < segmentNum; i++ {
|
2020-12-04 14:18:17 +08:00
|
|
|
err := node.replica.addSegment(UniqueID(i), tag, collectionID)
|
2020-11-24 16:12:39 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
targetSeg, err := node.replica.getSegmentByID(UniqueID(i))
|
2020-11-24 16:12:39 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, targetSeg.segmentID, UniqueID(i))
|
|
|
|
}
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|
|
|
|
|
2020-11-25 10:31:51 +08:00
|
|
|
func TestCollectionReplica_hasSegment(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-13 17:20:13 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-12 11:18:23 +08:00
|
|
|
|
|
|
|
const segmentNum = 3
|
2020-12-04 14:18:17 +08:00
|
|
|
tag := "default"
|
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
for i := 0; i < segmentNum; i++ {
|
2020-12-04 14:18:17 +08:00
|
|
|
err := node.replica.addSegment(UniqueID(i), tag, collectionID)
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
2020-12-04 14:18:17 +08:00
|
|
|
targetSeg, err := node.replica.getSegmentByID(UniqueID(i))
|
2020-11-13 16:53:55 +08:00
|
|
|
assert.NoError(t, err)
|
2020-11-13 17:20:13 +08:00
|
|
|
assert.Equal(t, targetSeg.segmentID, UniqueID(i))
|
2020-12-04 14:18:17 +08:00
|
|
|
hasSeg := node.replica.hasSegment(UniqueID(i))
|
2020-11-24 16:12:39 +08:00
|
|
|
assert.Equal(t, hasSeg, true)
|
2020-12-04 14:18:17 +08:00
|
|
|
hasSeg = node.replica.hasSegment(UniqueID(i + 100))
|
2020-11-24 16:12:39 +08:00
|
|
|
assert.Equal(t, hasSeg, false)
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-25 10:31:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestCollectionReplica_freeAll(t *testing.T) {
|
2020-12-04 14:18:17 +08:00
|
|
|
node := newQueryNode()
|
2020-11-25 10:31:51 +08:00
|
|
|
collectionName := "collection0"
|
|
|
|
collectionID := UniqueID(0)
|
2020-12-04 14:18:17 +08:00
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-12-04 14:18:17 +08:00
|
|
|
node.Close()
|
2020-11-25 10:31:51 +08:00
|
|
|
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|