2021-01-16 02:12:14 +00:00
|
|
|
package querynode
|
2020-10-24 02:45:57 +00:00
|
|
|
|
2020-11-12 03:18:23 +00:00
|
|
|
import (
|
2020-11-12 04:04:12 +00:00
|
|
|
"testing"
|
|
|
|
|
2020-11-12 03:18:23 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPartition_Segments(t *testing.T) {
|
2021-01-15 07:28:54 +00:00
|
|
|
node := newQueryNodeMock()
|
2020-11-13 09:20:13 +00:00
|
|
|
collectionName := "collection0"
|
2020-12-08 06:41:04 +00:00
|
|
|
collectionID := UniqueID(0)
|
|
|
|
initTestMeta(t, node, collectionName, collectionID, 0)
|
2020-11-12 03:18:23 +00:00
|
|
|
|
2020-12-08 06:41:04 +00:00
|
|
|
collection, err := node.replica.getCollectionByName(collectionName)
|
2020-11-13 09:20:13 +00:00
|
|
|
assert.NoError(t, err)
|
2020-11-12 03:18:23 +00:00
|
|
|
|
|
|
|
partitions := collection.Partitions()
|
|
|
|
targetPartition := (*partitions)[0]
|
|
|
|
|
|
|
|
const segmentNum = 3
|
2020-11-12 04:04:12 +00:00
|
|
|
for i := 0; i < segmentNum; i++ {
|
2021-01-20 01:36:50 +00:00
|
|
|
err := node.replica.addSegment2(UniqueID(i), targetPartition.partitionTag, collection.ID(), segTypeGrowing)
|
2020-11-12 03:18:23 +00:00
|
|
|
assert.NoError(t, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
segments := targetPartition.Segments()
|
2020-12-08 06:41:04 +00:00
|
|
|
assert.Equal(t, segmentNum+1, len(*segments))
|
2020-11-12 03:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestPartition_newPartition(t *testing.T) {
|
|
|
|
partitionTag := "default"
|
2021-01-21 07:20:23 +00:00
|
|
|
partition := newPartition2(partitionTag)
|
2020-11-12 03:18:23 +00:00
|
|
|
assert.Equal(t, partition.partitionTag, partitionTag)
|
|
|
|
}
|