mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-04 04:49:08 +08:00
f12a0490bb
Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
35 lines
845 B
Go
35 lines
845 B
Go
package querynode
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPartition_Segments(t *testing.T) {
|
|
node := newQueryNodeMock()
|
|
collectionID := UniqueID(0)
|
|
initTestMeta(t, node, collectionID, 0)
|
|
|
|
collection, err := node.replica.getCollectionByID(collectionID)
|
|
assert.NoError(t, err)
|
|
|
|
partitions := collection.Partitions()
|
|
targetPartition := (*partitions)[0]
|
|
|
|
const segmentNum = 3
|
|
for i := 0; i < segmentNum; i++ {
|
|
err := node.replica.addSegment(UniqueID(i), targetPartition.ID(), collection.ID(), segTypeGrowing)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
segments := targetPartition.Segments()
|
|
assert.Equal(t, segmentNum+1, len(*segments))
|
|
}
|
|
|
|
func TestPartition_newPartition(t *testing.T) {
|
|
partitionID := defaultPartitionID
|
|
partition := newPartition(partitionID)
|
|
assert.Equal(t, partition.ID(), defaultPartitionID)
|
|
}
|