2021-12-17 10:23:15 +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.
|
|
|
|
|
|
|
|
package paramtable
|
|
|
|
|
|
|
|
import (
|
2021-12-23 18:39:11 +08:00
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
"path"
|
2021-12-17 10:23:15 +08:00
|
|
|
"testing"
|
2021-12-23 18:39:11 +08:00
|
|
|
"time"
|
2021-12-17 10:23:15 +08:00
|
|
|
|
2021-12-23 18:39:11 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
2021-12-17 10:23:15 +08:00
|
|
|
)
|
|
|
|
|
2021-12-23 18:39:11 +08:00
|
|
|
func shouldPanic(t *testing.T, name string, f func()) {
|
|
|
|
defer func() { recover() }()
|
|
|
|
f()
|
|
|
|
t.Errorf("%s should have panicked", name)
|
|
|
|
}
|
|
|
|
|
2022-02-08 20:57:47 +08:00
|
|
|
func TestComponentParam(t *testing.T) {
|
|
|
|
var CParams ComponentParam
|
|
|
|
CParams.Init()
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-01-10 19:03:35 +08:00
|
|
|
t.Run("test commonConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params := CParams.CommonCfg
|
2022-01-10 19:03:35 +08:00
|
|
|
|
|
|
|
assert.NotEqual(t, Params.DefaultPartitionName, "")
|
|
|
|
t.Logf("default partition name = %s", Params.DefaultPartitionName)
|
|
|
|
|
|
|
|
assert.NotEqual(t, Params.DefaultIndexName, "")
|
|
|
|
t.Logf("default index name = %s", Params.DefaultIndexName)
|
|
|
|
|
|
|
|
assert.Equal(t, Params.RetentionDuration, int64(DefaultRetentionDuration))
|
|
|
|
})
|
|
|
|
|
2022-01-11 09:35:34 +08:00
|
|
|
t.Run("test knowhereConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params := CParams.KnowhereCfg
|
2022-01-11 09:35:34 +08:00
|
|
|
|
|
|
|
assert.NotEqual(t, Params.SimdType, "")
|
|
|
|
t.Logf("knowhere simd type = %s", Params.SimdType)
|
|
|
|
})
|
|
|
|
|
2022-02-02 00:35:43 +08:00
|
|
|
t.Run("test knowhereConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params := CParams.MsgChannelCfg
|
2022-02-02 00:35:43 +08:00
|
|
|
|
|
|
|
// -- rootcoord --
|
|
|
|
assert.Equal(t, Params.RootCoordTimeTick, "by-dev-rootcoord-timetick")
|
|
|
|
t.Logf("rootcoord timetick channel = %s", Params.RootCoordTimeTick)
|
|
|
|
|
|
|
|
assert.Equal(t, Params.RootCoordStatistics, "by-dev-rootcoord-statistics")
|
|
|
|
t.Logf("rootcoord statistics channel = %s", Params.RootCoordStatistics)
|
|
|
|
|
|
|
|
assert.Equal(t, Params.RootCoordDml, "by-dev-rootcoord-dml")
|
|
|
|
t.Logf("rootcoord dml channel = %s", Params.RootCoordDml)
|
|
|
|
|
|
|
|
assert.Equal(t, Params.RootCoordDelta, "by-dev-rootcoord-delta")
|
|
|
|
t.Logf("rootcoord delta channel = %s", Params.RootCoordDelta)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-02-02 00:35:43 +08:00
|
|
|
assert.Equal(t, Params.RootCoordSubName, "by-dev-rootCoord")
|
|
|
|
t.Logf("rootcoord subname = %s", Params.RootCoordSubName)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-02-02 00:35:43 +08:00
|
|
|
// -- querycoord --
|
|
|
|
assert.Equal(t, Params.QueryCoordSearch, "by-dev-search")
|
|
|
|
t.Logf("querycoord search channel = %s", Params.QueryCoordSearch)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-02-02 00:35:43 +08:00
|
|
|
assert.Equal(t, Params.QueryCoordSearchResult, "by-dev-searchResult")
|
|
|
|
t.Logf("querycoord search result channel = %s", Params.QueryCoordSearchResult)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-02-02 00:35:43 +08:00
|
|
|
assert.Equal(t, Params.QueryCoordTimeTick, "by-dev-queryTimeTick")
|
|
|
|
t.Logf("querycoord timetick channel = %s", Params.QueryCoordTimeTick)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-02-02 00:35:43 +08:00
|
|
|
// -- querynode --
|
|
|
|
assert.Equal(t, Params.QueryNodeStats, "by-dev-query-node-stats")
|
|
|
|
t.Logf("querynode stats channel = %s", Params.QueryNodeStats)
|
|
|
|
|
|
|
|
// -- datacoord --
|
|
|
|
assert.Equal(t, Params.DataCoordTimeTick, "by-dev-datacoord-timetick-channel")
|
|
|
|
t.Logf("datacoord timetick channel = %s", Params.DataCoordTimeTick)
|
|
|
|
|
|
|
|
assert.Equal(t, Params.DataCoordSegmentInfo, "by-dev-segment-info-channel")
|
|
|
|
t.Logf("datacoord segment info channel = %s", Params.DataCoordSegmentInfo)
|
|
|
|
|
|
|
|
assert.Equal(t, Params.DataCoordSubName, "by-dev-dataCoord")
|
|
|
|
t.Logf("datacoord subname = %s", Params.DataCoordSubName)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test rootCoordConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params := CParams.RootCoordCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
|
|
|
assert.NotEqual(t, Params.MaxPartitionNum, 0)
|
|
|
|
t.Logf("master MaxPartitionNum = %d", Params.MaxPartitionNum)
|
|
|
|
|
|
|
|
assert.NotEqual(t, Params.MinSegmentSizeToEnableIndex, 0)
|
|
|
|
t.Logf("master MinSegmentSizeToEnableIndex = %d", Params.MinSegmentSizeToEnableIndex)
|
|
|
|
|
|
|
|
Params.CreatedTime = time.Now()
|
|
|
|
Params.UpdatedTime = time.Now()
|
|
|
|
t.Logf("created time: %v", Params.CreatedTime)
|
|
|
|
t.Logf("updated time: %v", Params.UpdatedTime)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test proxyConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params := CParams.ProxyCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
|
|
|
t.Logf("TimeTickInterval: %v", Params.TimeTickInterval)
|
|
|
|
|
|
|
|
assert.Equal(t, Params.ProxySubName, "by-dev-proxy-0")
|
|
|
|
t.Logf("ProxySubName: %s", Params.ProxySubName)
|
|
|
|
|
|
|
|
t.Logf("MsgStreamTimeTickBufSize: %d", Params.MsgStreamTimeTickBufSize)
|
|
|
|
|
|
|
|
t.Logf("MaxNameLength: %d", Params.MaxNameLength)
|
|
|
|
|
|
|
|
t.Logf("MaxFieldNum: %d", Params.MaxFieldNum)
|
|
|
|
|
|
|
|
t.Logf("MaxShardNum: %d", Params.MaxShardNum)
|
|
|
|
|
|
|
|
t.Logf("MaxDimension: %d", Params.MaxDimension)
|
|
|
|
|
|
|
|
t.Logf("MaxTaskNum: %d", Params.MaxTaskNum)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test proxyConfig panic", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params := CParams.ProxyCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
|
|
|
shouldPanic(t, "proxy.timeTickInterval", func() {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params.Base.Save("proxy.timeTickInterval", "")
|
2021-12-23 18:39:11 +08:00
|
|
|
Params.initTimeTickInterval()
|
|
|
|
})
|
|
|
|
|
|
|
|
shouldPanic(t, "proxy.msgStream.timeTick.bufSize", func() {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params.Base.Save("proxy.msgStream.timeTick.bufSize", "abc")
|
2021-12-23 18:39:11 +08:00
|
|
|
Params.initMsgStreamTimeTickBufSize()
|
|
|
|
})
|
|
|
|
|
|
|
|
shouldPanic(t, "proxy.maxNameLength", func() {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params.Base.Save("proxy.maxNameLength", "abc")
|
2021-12-23 18:39:11 +08:00
|
|
|
Params.initMaxNameLength()
|
|
|
|
})
|
|
|
|
|
|
|
|
shouldPanic(t, "proxy.maxFieldNum", func() {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params.Base.Save("proxy.maxFieldNum", "abc")
|
2021-12-23 18:39:11 +08:00
|
|
|
Params.initMaxFieldNum()
|
|
|
|
})
|
|
|
|
|
|
|
|
shouldPanic(t, "proxy.maxShardNum", func() {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params.Base.Save("proxy.maxShardNum", "abc")
|
2021-12-23 18:39:11 +08:00
|
|
|
Params.initMaxShardNum()
|
|
|
|
})
|
|
|
|
|
|
|
|
shouldPanic(t, "proxy.maxDimension", func() {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params.Base.Save("proxy.maxDimension", "-asdf")
|
2021-12-23 18:39:11 +08:00
|
|
|
Params.initMaxDimension()
|
|
|
|
})
|
|
|
|
|
|
|
|
shouldPanic(t, "proxy.maxTaskNum", func() {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params.Base.Save("proxy.maxTaskNum", "-asdf")
|
2021-12-23 18:39:11 +08:00
|
|
|
Params.initMaxTaskNum()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test queryCoordConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
//Params := CParams.QueryCoordCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test queryNodeConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params := CParams.QueryNodeCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
|
|
|
cacheSize := Params.CacheSize
|
|
|
|
assert.Equal(t, int64(32), cacheSize)
|
|
|
|
err := os.Setenv("CACHE_SIZE", "2")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
Params.initCacheSize()
|
|
|
|
assert.Equal(t, int64(2), Params.CacheSize)
|
|
|
|
err = os.Setenv("CACHE_SIZE", "32")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
Params.initCacheSize()
|
|
|
|
assert.Equal(t, int64(32), Params.CacheSize)
|
|
|
|
|
|
|
|
interval := Params.StatsPublishInterval
|
|
|
|
assert.Equal(t, 1000, interval)
|
|
|
|
|
|
|
|
bufSize := Params.SearchReceiveBufSize
|
|
|
|
assert.Equal(t, int64(512), bufSize)
|
|
|
|
|
|
|
|
bufSize = Params.SearchResultReceiveBufSize
|
|
|
|
assert.Equal(t, int64(64), bufSize)
|
|
|
|
|
|
|
|
bufSize = Params.SearchPulsarBufSize
|
|
|
|
assert.Equal(t, int64(512), bufSize)
|
|
|
|
|
|
|
|
length := Params.FlowGraphMaxQueueLength
|
|
|
|
assert.Equal(t, int32(1024), length)
|
|
|
|
|
|
|
|
maxParallelism := Params.FlowGraphMaxParallelism
|
|
|
|
assert.Equal(t, int32(1024), maxParallelism)
|
|
|
|
|
|
|
|
Params.QueryNodeID = 3
|
2022-02-02 00:35:43 +08:00
|
|
|
Params.initQueryNodeSubName()
|
|
|
|
name := Params.QueryNodeSubName
|
2022-01-17 17:37:37 +08:00
|
|
|
assert.Equal(t, name, "by-dev-queryNode")
|
2021-12-23 18:39:11 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test dataCoordConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
//Params := CParams.DataCoordCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test dataNodeConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params := CParams.DataNodeCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
|
|
|
Params.NodeID = 2
|
2022-02-02 00:35:43 +08:00
|
|
|
Params.Refresh()
|
2021-12-23 18:39:11 +08:00
|
|
|
|
|
|
|
id := Params.NodeID
|
|
|
|
log.Println("NodeID:", id)
|
|
|
|
|
|
|
|
alias := Params.Alias
|
|
|
|
log.Println("Alias:", alias)
|
|
|
|
|
|
|
|
length := Params.FlowGraphMaxQueueLength
|
|
|
|
log.Println("flowGraphMaxQueueLength:", length)
|
|
|
|
|
|
|
|
maxParallelism := Params.FlowGraphMaxParallelism
|
|
|
|
log.Println("flowGraphMaxParallelism:", maxParallelism)
|
|
|
|
|
|
|
|
size := Params.FlushInsertBufferSize
|
|
|
|
log.Println("FlushInsertBufferSize:", size)
|
|
|
|
|
|
|
|
path1 := Params.InsertBinlogRootPath
|
|
|
|
log.Println("InsertBinlogRootPath:", path1)
|
|
|
|
|
2022-02-02 00:35:43 +08:00
|
|
|
name := Params.DataNodeSubName
|
2021-12-23 18:39:11 +08:00
|
|
|
assert.Equal(t, name, "by-dev-dataNode-2")
|
2022-02-02 00:35:43 +08:00
|
|
|
log.Println("DataNodeSubName:", name)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
|
|
|
Params.CreatedTime = time.Now()
|
|
|
|
log.Println("CreatedTime: ", Params.CreatedTime)
|
|
|
|
|
|
|
|
Params.UpdatedTime = time.Now()
|
|
|
|
log.Println("UpdatedTime: ", Params.UpdatedTime)
|
|
|
|
|
|
|
|
assert.Equal(t, path.Join("files", "insert_log"), Params.InsertBinlogRootPath)
|
|
|
|
|
|
|
|
assert.Equal(t, path.Join("files", "stats_log"), Params.StatsBinlogRootPath)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test indexCoordConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params := CParams.IndexCoordCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
|
|
|
t.Logf("Address: %v", Params.Address)
|
|
|
|
|
|
|
|
t.Logf("Port: %v", Params.Port)
|
|
|
|
|
|
|
|
Params.CreatedTime = time.Now()
|
|
|
|
t.Logf("CreatedTime: %v", Params.CreatedTime)
|
|
|
|
|
|
|
|
Params.UpdatedTime = time.Now()
|
|
|
|
t.Logf("UpdatedTime: %v", Params.UpdatedTime)
|
|
|
|
|
|
|
|
t.Logf("IndexStorageRootPath: %v", Params.IndexStorageRootPath)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test indexNodeConfig", func(t *testing.T) {
|
2022-02-08 20:57:47 +08:00
|
|
|
Params := CParams.IndexNodeCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
|
|
|
t.Logf("IP: %v", Params.IP)
|
|
|
|
|
|
|
|
t.Logf("Address: %v", Params.Address)
|
|
|
|
|
|
|
|
t.Logf("Port: %v", Params.Port)
|
|
|
|
|
|
|
|
t.Logf("NodeID: %v", Params.NodeID)
|
|
|
|
|
|
|
|
t.Logf("Alias: %v", Params.Alias)
|
|
|
|
|
|
|
|
Params.CreatedTime = time.Now()
|
|
|
|
t.Logf("CreatedTime: %v", Params.CreatedTime)
|
|
|
|
|
|
|
|
Params.UpdatedTime = time.Now()
|
|
|
|
t.Logf("UpdatedTime: %v", Params.UpdatedTime)
|
|
|
|
|
|
|
|
t.Logf("IndexStorageRootPath: %v", Params.IndexStorageRootPath)
|
|
|
|
})
|
|
|
|
}
|