2020-11-26 16:01:31 +08:00
|
|
|
package querynode
|
2020-09-16 15:21:10 +08:00
|
|
|
|
2020-11-16 17:01:10 +08:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/zilliztech/milvus-distributed/internal/msgstream"
|
|
|
|
)
|
|
|
|
|
|
|
|
// NOTE: start pulsar before test
|
|
|
|
func TestStatsService_start(t *testing.T) {
|
2020-12-08 14:41:04 +08:00
|
|
|
node := newQueryNode()
|
|
|
|
initTestMeta(t, node, "collection0", 0, 0)
|
|
|
|
node.statsService = newStatsService(node.queryNodeLoopCtx, node.replica)
|
2020-11-16 17:01:10 +08:00
|
|
|
node.statsService.start()
|
2020-12-08 14:41:04 +08:00
|
|
|
node.Close()
|
2020-11-16 17:01:10 +08:00
|
|
|
}
|
|
|
|
|
2020-12-08 14:41:04 +08:00
|
|
|
//NOTE: start pulsar before test
|
2020-12-10 16:31:09 +08:00
|
|
|
func TestSegmentManagement_sendSegmentStatistic(t *testing.T) {
|
2020-12-08 14:41:04 +08:00
|
|
|
node := newQueryNode()
|
|
|
|
initTestMeta(t, node, "collection0", 0, 0)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
const receiveBufSize = 1024
|
|
|
|
// start pulsar
|
2020-12-10 16:31:09 +08:00
|
|
|
producerChannels := []string{Params.StatsChannelName}
|
2020-11-16 17:01:10 +08:00
|
|
|
|
2020-12-10 16:31:09 +08:00
|
|
|
pulsarURL := Params.PulsarAddress
|
2020-12-08 14:41:04 +08:00
|
|
|
|
|
|
|
statsStream := msgstream.NewPulsarMsgStream(node.queryNodeLoopCtx, receiveBufSize)
|
2020-11-18 19:46:18 +08:00
|
|
|
statsStream.SetPulsarClient(pulsarURL)
|
2020-11-16 17:01:10 +08:00
|
|
|
statsStream.CreatePulsarProducers(producerChannels)
|
|
|
|
|
|
|
|
var statsMsgStream msgstream.MsgStream = statsStream
|
|
|
|
|
2020-12-08 14:41:04 +08:00
|
|
|
node.statsService = newStatsService(node.queryNodeLoopCtx, node.replica)
|
|
|
|
node.statsService.statsStream = statsMsgStream
|
|
|
|
node.statsService.statsStream.Start()
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
// send stats
|
|
|
|
node.statsService.sendSegmentStatistic()
|
2020-12-08 14:41:04 +08:00
|
|
|
node.Close()
|
2020-11-16 17:01:10 +08:00
|
|
|
}
|