2021-04-19 13:47:10 +08:00
|
|
|
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
|
|
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
|
|
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
|
|
|
|
2021-01-16 10:12:14 +08:00
|
|
|
package querynode
|
2020-09-16 15:21:10 +08:00
|
|
|
|
2020-11-16 17:01:10 +08:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-04-22 14:45:57 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/msgstream"
|
2021-02-04 14:37:12 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
2020-11-16 17:01:10 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// NOTE: start pulsar before test
|
|
|
|
func TestStatsService_start(t *testing.T) {
|
2021-01-15 15:28:54 +08:00
|
|
|
node := newQueryNodeMock()
|
2021-02-03 11:52:19 +08:00
|
|
|
initTestMeta(t, node, 0, 0)
|
2021-02-08 14:30:54 +08:00
|
|
|
|
2021-04-02 13:48:25 +08:00
|
|
|
msFactory := msgstream.NewPmsFactory()
|
2021-02-08 14:30:54 +08:00
|
|
|
m := map[string]interface{}{
|
|
|
|
"PulsarAddress": Params.PulsarAddress,
|
|
|
|
"ReceiveBufSize": 1024,
|
|
|
|
"PulsarBufSize": 1024}
|
|
|
|
msFactory.SetParams(m)
|
2021-05-28 10:26:30 +08:00
|
|
|
node.historical.statsService = newStatsService(node.queryNodeLoopCtx, node.historical.replica, nil, msFactory)
|
|
|
|
node.historical.statsService.start()
|
2021-01-21 15:20:23 +08:00
|
|
|
node.Stop()
|
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) {
|
2021-01-15 15:28:54 +08:00
|
|
|
node := newQueryNodeMock()
|
2021-02-03 11:52:19 +08:00
|
|
|
initTestMeta(t, node, 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
|
|
|
|
2021-04-02 13:48:25 +08:00
|
|
|
msFactory := msgstream.NewPmsFactory()
|
2021-02-08 14:30:54 +08:00
|
|
|
m := map[string]interface{}{
|
|
|
|
"receiveBufSize": receiveBufSize,
|
|
|
|
"pulsarAddress": Params.PulsarAddress,
|
|
|
|
"pulsarBufSize": 1024}
|
|
|
|
err := msFactory.SetParams(m)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
|
|
|
statsStream, err := msFactory.NewMsgStream(node.queryNodeLoopCtx)
|
2021-02-04 14:37:12 +08:00
|
|
|
assert.Nil(t, err)
|
|
|
|
statsStream.AsProducer(producerChannels)
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
var statsMsgStream msgstream.MsgStream = statsStream
|
|
|
|
|
2021-05-28 10:26:30 +08:00
|
|
|
node.historical.statsService = newStatsService(node.queryNodeLoopCtx, node.historical.replica, nil, msFactory)
|
|
|
|
node.historical.statsService.statsStream = statsMsgStream
|
|
|
|
node.historical.statsService.statsStream.Start()
|
2020-11-16 17:01:10 +08:00
|
|
|
|
|
|
|
// send stats
|
2021-05-28 10:26:30 +08:00
|
|
|
node.historical.statsService.publicStatistic(nil)
|
2021-01-21 15:20:23 +08:00
|
|
|
node.Stop()
|
2020-11-16 17:01:10 +08:00
|
|
|
}
|