2021-01-16 10:12:14 +08:00
|
|
|
package querynode
|
2020-10-24 10:45:57 +08:00
|
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPartition_Segments(t *testing.T) {
|
2021-01-15 15:28:54 +08:00
|
|
|
node := newQueryNodeMock()
|
2020-12-08 14:41:04 +08:00
|
|
|
collectionID := UniqueID(0)
|
2021-02-03 11:52:19 +08:00
|
|
|
initTestMeta(t, node, collectionID, 0)
|
2020-11-12 11:18:23 +08:00
|
|
|
|
2021-02-03 11:52:19 +08:00
|
|
|
collection, err := node.replica.getCollectionByID(collectionID)
|
2020-11-13 17:20:13 +08:00
|
|
|
assert.NoError(t, err)
|
2020-11-12 11:18:23 +08:00
|
|
|
|
|
|
|
partitions := collection.Partitions()
|
|
|
|
targetPartition := (*partitions)[0]
|
|
|
|
|
|
|
|
const segmentNum = 3
|
2020-11-12 12:04:12 +08:00
|
|
|
for i := 0; i < segmentNum; i++ {
|
2021-02-03 17:30:10 +08:00
|
|
|
err := node.replica.addSegment2(UniqueID(i), targetPartition.partitionTag, collection.ID(), segTypeGrowing)
|
2020-11-12 11:18:23 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
segments := targetPartition.Segments()
|
2020-12-08 14:41:04 +08:00
|
|
|
assert.Equal(t, segmentNum+1, len(*segments))
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestPartition_newPartition(t *testing.T) {
|
2021-02-03 17:30:10 +08:00
|
|
|
partitionTag := "default"
|
|
|
|
partition := newPartition2(partitionTag)
|
|
|
|
assert.Equal(t, partition.partitionTag, partitionTag)
|
2020-11-12 11:18:23 +08:00
|
|
|
}
|