mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 05:18:52 +08:00
83c60fd84f
Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
36 lines
903 B
Go
36 lines
903 B
Go
package querynode
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPartition_Segments(t *testing.T) {
|
|
node := newQueryNodeMock()
|
|
collectionName := "collection0"
|
|
collectionID := UniqueID(0)
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
|
|
|
collection, err := node.replica.getCollectionByName(collectionName)
|
|
assert.NoError(t, err)
|
|
|
|
partitions := collection.Partitions()
|
|
targetPartition := (*partitions)[0]
|
|
|
|
const segmentNum = 3
|
|
for i := 0; i < segmentNum; i++ {
|
|
err := node.replica.addSegment2(UniqueID(i), targetPartition.partitionTag, collection.ID(), segTypeGrowing)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
segments := targetPartition.Segments()
|
|
assert.Equal(t, segmentNum+1, len(*segments))
|
|
}
|
|
|
|
func TestPartition_newPartition(t *testing.T) {
|
|
partitionTag := "default"
|
|
partition := newPartition2(partitionTag)
|
|
assert.Equal(t, partition.partitionTag, partitionTag)
|
|
}
|