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 (
|
|
|
|
"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"
|
2023-04-06 19:14:32 +08:00
|
|
|
|
|
|
|
"github.com/milvus-io/milvus/pkg/config"
|
2023-11-06 06:02:16 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/hardware"
|
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) {
|
2022-11-04 14:25:38 +08:00
|
|
|
Init()
|
|
|
|
params := Get()
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-01-10 19:03:35 +08:00
|
|
|
t.Run("test commonConfig", func(t *testing.T) {
|
2023-08-23 20:46:23 +08:00
|
|
|
Params := ¶ms.CommonCfg
|
2022-01-10 19:03:35 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.NotEqual(t, Params.DefaultPartitionName.GetValue(), "")
|
|
|
|
t.Logf("default partition name = %s", Params.DefaultPartitionName.GetValue())
|
2022-01-10 19:03:35 +08:00
|
|
|
|
2023-08-23 20:46:23 +08:00
|
|
|
assert.NotEqual(t, Params.DefaultIndexName.GetValue(), "")
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("default index name = %s", Params.DefaultIndexName.GetValue())
|
2022-01-10 19:03:35 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.EntityExpirationTTL.GetAsInt64(), int64(-1))
|
|
|
|
t.Logf("default entity expiration = %d", Params.EntityExpirationTTL.GetAsInt64())
|
2022-04-28 11:51:47 +08:00
|
|
|
|
|
|
|
// test the case coommo
|
2022-12-07 18:01:19 +08:00
|
|
|
params.Save("common.entityExpiration", "50")
|
2023-01-18 13:57:43 +08:00
|
|
|
assert.Equal(t, Params.EntityExpirationTTL.GetAsInt(), 50)
|
2022-04-28 11:51:47 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.NotEqual(t, Params.SimdType.GetValue(), "")
|
|
|
|
t.Logf("knowhere simd type = %s", Params.SimdType.GetValue())
|
2022-02-02 00:35:43 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.IndexSliceSize.GetAsInt64(), int64(DefaultIndexSliceSize))
|
|
|
|
t.Logf("knowhere index slice size = %d", Params.IndexSliceSize.GetAsInt64())
|
2022-04-08 20:29:33 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.GracefulTime.GetAsInt64(), int64(DefaultGracefulTime))
|
|
|
|
t.Logf("default grafeful time = %d", Params.GracefulTime.GetAsInt64())
|
2022-05-24 12:05:59 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.GracefulStopTimeout.GetAsInt64(), int64(DefaultGracefulStopTimeout))
|
|
|
|
assert.Equal(t, params.QueryNodeCfg.GracefulStopTimeout.GetAsInt64(), Params.GracefulStopTimeout.GetAsInt64())
|
2022-12-16 10:03:27 +08:00
|
|
|
assert.Equal(t, params.IndexNodeCfg.GracefulStopTimeout.GetAsInt64(), Params.GracefulStopTimeout.GetAsInt64())
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("default grafeful stop timeout = %d", Params.GracefulStopTimeout.GetAsInt())
|
|
|
|
params.Save(Params.GracefulStopTimeout.Key, "50")
|
|
|
|
assert.Equal(t, Params.GracefulStopTimeout.GetAsInt64(), int64(50))
|
2022-12-06 22:59:19 +08:00
|
|
|
|
2022-02-02 00:35:43 +08:00
|
|
|
// -- rootcoord --
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.RootCoordTimeTick.GetValue(), "by-dev-rootcoord-timetick")
|
|
|
|
t.Logf("rootcoord timetick channel = %s", Params.RootCoordTimeTick.GetValue())
|
2022-02-02 00:35:43 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.RootCoordStatistics.GetValue(), "by-dev-rootcoord-statistics")
|
|
|
|
t.Logf("rootcoord statistics channel = %s", Params.RootCoordStatistics.GetValue())
|
2022-02-02 00:35:43 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.RootCoordDml.GetValue(), "by-dev-rootcoord-dml")
|
|
|
|
t.Logf("rootcoord dml channel = %s", Params.RootCoordDml.GetValue())
|
2022-02-02 00:35:43 +08:00
|
|
|
|
|
|
|
// -- querycoord --
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.QueryCoordTimeTick.GetValue(), "by-dev-queryTimeTick")
|
|
|
|
t.Logf("querycoord timetick channel = %s", Params.QueryCoordTimeTick.GetValue())
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-02-02 00:35:43 +08:00
|
|
|
// -- datacoord --
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.DataCoordTimeTick.GetValue(), "by-dev-datacoord-timetick-channel")
|
|
|
|
t.Logf("datacoord timetick channel = %s", Params.DataCoordTimeTick.GetValue())
|
2022-02-02 00:35:43 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.DataCoordSegmentInfo.GetValue(), "by-dev-segment-info-channel")
|
|
|
|
t.Logf("datacoord segment info channel = %s", Params.DataCoordSegmentInfo.GetValue())
|
2022-02-02 00:35:43 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.DataCoordSubName.GetValue(), "by-dev-dataCoord")
|
|
|
|
t.Logf("datacoord subname = %s", Params.DataCoordSubName.GetValue())
|
2022-02-09 14:41:45 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.DataNodeSubName.GetValue(), "by-dev-dataNode")
|
|
|
|
t.Logf("datanode subname = %s", Params.DataNodeSubName.GetValue())
|
2022-09-29 18:35:02 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.SessionTTL.GetAsInt64(), int64(DefaultSessionTTL))
|
|
|
|
t.Logf("default session TTL time = %d", Params.SessionTTL.GetAsInt64())
|
|
|
|
assert.Equal(t, Params.SessionRetryTimes.GetAsInt64(), int64(DefaultSessionRetryTimes))
|
|
|
|
t.Logf("default session retry times = %d", Params.SessionRetryTimes.GetAsInt64())
|
2022-12-09 16:13:20 +08:00
|
|
|
|
|
|
|
params.Save("common.security.superUsers", "super1,super2,super3")
|
|
|
|
assert.Equal(t, []string{"super1", "super2", "super3"}, Params.SuperUsers.GetAsStrings())
|
|
|
|
|
|
|
|
params.Save("common.security.superUsers", "")
|
|
|
|
assert.Equal(t, []string{""}, Params.SuperUsers.GetAsStrings())
|
2023-04-03 16:44:23 +08:00
|
|
|
|
|
|
|
assert.Equal(t, false, Params.PreCreatedTopicEnabled.GetAsBool())
|
|
|
|
|
|
|
|
params.Save("common.preCreatedTopic.names", "topic1,topic2,topic3")
|
|
|
|
assert.Equal(t, []string{"topic1", "topic2", "topic3"}, Params.TopicNames.GetAsStrings())
|
|
|
|
|
|
|
|
params.Save("common.preCreatedTopic.timeticker", "timeticker")
|
|
|
|
assert.Equal(t, []string{"timeticker"}, Params.TimeTicker.GetAsStrings())
|
2022-02-02 00:35:43 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test rootCoordConfig", func(t *testing.T) {
|
2023-08-23 20:46:23 +08:00
|
|
|
Params := ¶ms.RootCoordCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.NotEqual(t, Params.MaxPartitionNum.GetAsInt64(), 0)
|
|
|
|
t.Logf("master MaxPartitionNum = %d", Params.MaxPartitionNum.GetAsInt64())
|
|
|
|
assert.NotEqual(t, Params.MinSegmentSizeToEnableIndex.GetAsInt64(), 0)
|
|
|
|
t.Logf("master MinSegmentSizeToEnableIndex = %d", Params.MinSegmentSizeToEnableIndex.GetAsInt64())
|
|
|
|
assert.NotEqual(t, Params.ImportTaskExpiration.GetAsFloat(), 0)
|
|
|
|
t.Logf("master ImportTaskRetention = %f", Params.ImportTaskRetention.GetAsFloat())
|
|
|
|
assert.Equal(t, Params.EnableActiveStandby.GetAsBool(), false)
|
|
|
|
t.Logf("rootCoord EnableActiveStandby = %t", Params.EnableActiveStandby.GetAsBool())
|
|
|
|
|
|
|
|
SetCreateTime(time.Now())
|
|
|
|
SetUpdateTime(time.Now())
|
2021-12-23 18:39:11 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test proxyConfig", func(t *testing.T) {
|
2023-08-23 20:46:23 +08:00
|
|
|
Params := ¶ms.ProxyCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2023-08-23 20:46:23 +08:00
|
|
|
t.Logf("TimeTickInterval: %v", &Params.TimeTickInterval)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2023-09-04 17:51:48 +08:00
|
|
|
t.Logf("healthCheckTimeout: %v", &Params.HealthCheckTimeout)
|
2023-06-29 17:10:23 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("MsgStreamTimeTickBufSize: %d", Params.MsgStreamTimeTickBufSize.GetAsInt64())
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("MaxNameLength: %d", Params.MaxNameLength.GetAsInt64())
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("MaxFieldNum: %d", Params.MaxFieldNum.GetAsInt64())
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("MaxShardNum: %d", Params.MaxShardNum.GetAsInt64())
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("MaxDimension: %d", Params.MaxDimension.GetAsInt64())
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("MaxTaskNum: %d", Params.MaxTaskNum.GetAsInt64())
|
2022-11-10 17:09:06 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("AccessLog.Enable: %t", Params.AccessLog.Enable.GetAsBool())
|
2022-11-10 17:09:06 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("AccessLog.MaxSize: %d", Params.AccessLog.MaxSize.GetAsInt64())
|
2022-11-10 17:09:06 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("AccessLog.MaxBackups: %d", Params.AccessLog.MaxBackups.GetAsInt64())
|
2022-11-10 17:09:06 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
t.Logf("AccessLog.MaxDays: %d", Params.AccessLog.RotatedTime.GetAsInt64())
|
2023-03-08 15:13:51 +08:00
|
|
|
|
|
|
|
t.Logf("ShardLeaderCacheInterval: %d", Params.ShardLeaderCacheInterval.GetAsInt64())
|
2023-06-25 19:46:44 +08:00
|
|
|
|
|
|
|
assert.Equal(t, Params.ReplicaSelectionPolicy.GetValue(), "look_aside")
|
|
|
|
params.Save(Params.ReplicaSelectionPolicy.Key, "round_robin")
|
|
|
|
assert.Equal(t, Params.ReplicaSelectionPolicy.GetValue(), "round_robin")
|
|
|
|
params.Save(Params.ReplicaSelectionPolicy.Key, "look_aside")
|
|
|
|
assert.Equal(t, Params.ReplicaSelectionPolicy.GetValue(), "look_aside")
|
2023-07-25 18:51:01 +08:00
|
|
|
assert.Equal(t, Params.CheckQueryNodeHealthInterval.GetAsInt(), 1000)
|
|
|
|
assert.Equal(t, Params.CostMetricsExpireTime.GetAsInt(), 1000)
|
2023-08-03 15:55:09 +08:00
|
|
|
assert.Equal(t, Params.RetryTimesOnReplica.GetAsInt(), 2)
|
2023-09-04 17:51:48 +08:00
|
|
|
assert.EqualValues(t, Params.HealthCheckTimeout.GetAsInt64(), 3000)
|
2021-12-23 18:39:11 +08:00
|
|
|
})
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
// t.Run("test proxyConfig panic", func(t *testing.T) {
|
|
|
|
// Params := params.ProxyCfg
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.timeTickInterval", func() {
|
|
|
|
// params.Save("proxy.timeTickInterval", "")
|
|
|
|
// Params.TimeTickInterval.GetValue()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.msgStream.timeTick.bufSize", func() {
|
|
|
|
// params.Save("proxy.msgStream.timeTick.bufSize", "abc")
|
|
|
|
// Params.MsgStreamTimeTickBufSize.GetAsInt()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.maxNameLength", func() {
|
|
|
|
// params.Save("proxy.maxNameLength", "abc")
|
|
|
|
// Params.MaxNameLength.GetAsInt()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.maxUsernameLength", func() {
|
|
|
|
// params.Save("proxy.maxUsernameLength", "abc")
|
|
|
|
// Params.MaxUsernameLength.GetAsInt()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.minPasswordLength", func() {
|
|
|
|
// params.Save("proxy.minPasswordLength", "abc")
|
|
|
|
// Params.MinPasswordLength.GetAsInt()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.maxPasswordLength", func() {
|
|
|
|
// params.Save("proxy.maxPasswordLength", "abc")
|
|
|
|
// Params.MaxPasswordLength.GetAsInt()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.maxFieldNum", func() {
|
|
|
|
// params.Save("proxy.maxFieldNum", "abc")
|
|
|
|
// Params.MaxFieldNum.GetAsInt()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.maxShardNum", func() {
|
|
|
|
// params.Save("proxy.maxShardNum", "abc")
|
|
|
|
// Params.MaxShardNum.GetAsInt()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.maxDimension", func() {
|
|
|
|
// params.Save("proxy.maxDimension", "-asdf")
|
|
|
|
// Params.MaxDimension.GetAsInt()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.maxTaskNum", func() {
|
|
|
|
// params.Save("proxy.maxTaskNum", "-asdf")
|
|
|
|
// Params.MaxTaskNum.GetAsInt()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.maxUserNum", func() {
|
|
|
|
// params.Save("proxy.maxUserNum", "abc")
|
|
|
|
// Params.MaxUserNum.GetAsInt()
|
|
|
|
// })
|
|
|
|
//
|
|
|
|
// shouldPanic(t, "proxy.maxRoleNum", func() {
|
|
|
|
// params.Save("proxy.maxRoleNum", "abc")
|
|
|
|
// Params.MaxRoleNum.GetAsInt()
|
|
|
|
// })
|
|
|
|
// })
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-09-29 18:35:02 +08:00
|
|
|
t.Run("test queryCoordConfig", func(t *testing.T) {
|
2023-08-31 09:59:01 +08:00
|
|
|
Params := ¶ms.QueryCoordCfg
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, Params.EnableActiveStandby.GetAsBool(), false)
|
|
|
|
t.Logf("queryCoord EnableActiveStandby = %t", Params.EnableActiveStandby.GetAsBool())
|
2023-01-30 10:19:48 +08:00
|
|
|
|
|
|
|
params.Save("queryCoord.NextTargetSurviveTime", "100")
|
2023-08-31 09:59:01 +08:00
|
|
|
NextTargetSurviveTime := &Params.NextTargetSurviveTime
|
2023-01-30 10:19:48 +08:00
|
|
|
assert.Equal(t, int64(100), NextTargetSurviveTime.GetAsInt64())
|
|
|
|
|
|
|
|
params.Save("queryCoord.UpdateNextTargetInterval", "100")
|
2023-08-31 09:59:01 +08:00
|
|
|
UpdateNextTargetInterval := &Params.UpdateNextTargetInterval
|
2023-01-30 10:19:48 +08:00
|
|
|
assert.Equal(t, int64(100), UpdateNextTargetInterval.GetAsInt64())
|
|
|
|
|
|
|
|
params.Save("queryCoord.checkNodeInReplicaInterval", "100")
|
2023-08-31 09:59:01 +08:00
|
|
|
checkNodeInReplicaInterval := &Params.CheckNodeInReplicaInterval
|
2023-01-30 10:19:48 +08:00
|
|
|
assert.Equal(t, 100, checkNodeInReplicaInterval.GetAsInt())
|
|
|
|
|
|
|
|
params.Save("queryCoord.checkResourceGroupInterval", "10")
|
2023-08-31 09:59:01 +08:00
|
|
|
checkResourceGroupInterval := &Params.CheckResourceGroupInterval
|
2023-01-30 10:19:48 +08:00
|
|
|
assert.Equal(t, 10, checkResourceGroupInterval.GetAsInt())
|
|
|
|
|
2023-08-31 09:59:01 +08:00
|
|
|
enableResourceGroupAutoRecover := &Params.EnableRGAutoRecover
|
2023-01-30 10:19:48 +08:00
|
|
|
assert.Equal(t, true, enableResourceGroupAutoRecover.GetAsBool())
|
|
|
|
params.Save("queryCoord.enableRGAutoRecover", "false")
|
2023-08-31 09:59:01 +08:00
|
|
|
enableResourceGroupAutoRecover = &Params.EnableRGAutoRecover
|
2023-01-30 10:19:48 +08:00
|
|
|
assert.Equal(t, false, enableResourceGroupAutoRecover.GetAsBool())
|
2023-04-20 09:52:31 +08:00
|
|
|
|
|
|
|
checkHealthInterval := Params.CheckHealthInterval.GetAsInt()
|
|
|
|
assert.Equal(t, 3000, checkHealthInterval)
|
|
|
|
checkHealthRPCTimeout := Params.CheckHealthRPCTimeout.GetAsInt()
|
|
|
|
assert.Equal(t, 100, checkHealthRPCTimeout)
|
2023-05-04 12:22:40 +08:00
|
|
|
|
|
|
|
assert.Equal(t, 0.1, Params.GlobalRowCountFactor.GetAsFloat())
|
|
|
|
params.Save("queryCoord.globalRowCountFactor", "0.4")
|
|
|
|
assert.Equal(t, 0.4, Params.GlobalRowCountFactor.GetAsFloat())
|
|
|
|
|
|
|
|
assert.Equal(t, 0.05, Params.ScoreUnbalanceTolerationFactor.GetAsFloat())
|
|
|
|
params.Save("queryCoord.scoreUnbalanceTolerationFactor", "0.4")
|
|
|
|
assert.Equal(t, 0.4, Params.ScoreUnbalanceTolerationFactor.GetAsFloat())
|
|
|
|
|
|
|
|
assert.Equal(t, 1.3, Params.ReverseUnbalanceTolerationFactor.GetAsFloat())
|
|
|
|
params.Save("queryCoord.reverseUnBalanceTolerationFactor", "1.5")
|
|
|
|
assert.Equal(t, 1.5, Params.ReverseUnbalanceTolerationFactor.GetAsFloat())
|
2023-07-19 16:50:57 +08:00
|
|
|
|
|
|
|
assert.Equal(t, 1000, Params.SegmentCheckInterval.GetAsInt())
|
|
|
|
assert.Equal(t, 1000, Params.ChannelCheckInterval.GetAsInt())
|
|
|
|
assert.Equal(t, 10000, Params.BalanceCheckInterval.GetAsInt())
|
2023-07-19 21:22:58 +08:00
|
|
|
assert.Equal(t, 10000, Params.IndexCheckInterval.GetAsInt())
|
2023-09-27 11:43:28 +08:00
|
|
|
assert.Equal(t, 3, Params.CollectionRecoverTimesLimit.GetAsInt())
|
2023-11-07 14:02:20 +08:00
|
|
|
assert.Equal(t, false, Params.AutoBalance.GetAsBool())
|
|
|
|
assert.Equal(t, 10, Params.CheckAutoBalanceConfigInterval.GetAsInt())
|
2022-09-29 18:35:02 +08:00
|
|
|
})
|
|
|
|
|
2021-12-23 18:39:11 +08:00
|
|
|
t.Run("test queryNodeConfig", func(t *testing.T) {
|
2023-08-31 09:59:01 +08:00
|
|
|
Params := ¶ms.QueryNodeCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
interval := Params.StatsPublishInterval.GetAsInt()
|
2021-12-23 18:39:11 +08:00
|
|
|
assert.Equal(t, 1000, interval)
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
length := Params.FlowGraphMaxQueueLength.GetAsInt32()
|
2023-08-09 10:05:14 +08:00
|
|
|
assert.Equal(t, int32(16), length)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
maxParallelism := Params.FlowGraphMaxParallelism.GetAsInt32()
|
2021-12-23 18:39:11 +08:00
|
|
|
assert.Equal(t, int32(1024), maxParallelism)
|
2022-05-05 09:49:50 +08:00
|
|
|
|
|
|
|
// test query side config
|
2022-12-07 18:01:19 +08:00
|
|
|
chunkRows := Params.ChunkRows.GetAsInt64()
|
2022-07-19 13:50:28 +08:00
|
|
|
assert.Equal(t, int64(1024), chunkRows)
|
2022-05-05 09:49:50 +08:00
|
|
|
|
2023-11-01 02:20:15 +08:00
|
|
|
nlist := Params.InterimIndexNlist.GetAsInt64()
|
2022-07-19 13:50:28 +08:00
|
|
|
assert.Equal(t, int64(128), nlist)
|
2022-05-05 09:49:50 +08:00
|
|
|
|
2023-11-01 02:20:15 +08:00
|
|
|
nprobe := Params.InterimIndexNProbe.GetAsInt64()
|
2022-05-05 09:49:50 +08:00
|
|
|
assert.Equal(t, int64(16), nprobe)
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, true, Params.GroupEnabled.GetAsBool())
|
|
|
|
assert.Equal(t, int32(10240), Params.MaxReceiveChanSize.GetAsInt32())
|
|
|
|
assert.Equal(t, int32(10240), Params.MaxUnsolvedQueueSize.GetAsInt32())
|
|
|
|
assert.Equal(t, 10.0, Params.CPURatio.GetAsFloat())
|
2023-11-06 06:02:16 +08:00
|
|
|
assert.Equal(t, uint32(hardware.GetCPUNum()), Params.KnowhereThreadPoolSize.GetAsUint32())
|
2022-05-23 16:41:58 +08:00
|
|
|
|
2023-09-28 15:47:27 +08:00
|
|
|
// chunk cache
|
|
|
|
assert.Equal(t, "willneed", Params.ReadAheadPolicy.GetValue())
|
|
|
|
|
2022-05-05 09:49:50 +08:00
|
|
|
// test small indexNlist/NProbe default
|
2022-12-07 18:01:19 +08:00
|
|
|
params.Remove("queryNode.segcore.smallIndex.nlist")
|
|
|
|
params.Remove("queryNode.segcore.smallIndex.nprobe")
|
|
|
|
params.Save("queryNode.segcore.chunkRows", "8192")
|
|
|
|
chunkRows = Params.ChunkRows.GetAsInt64()
|
2022-05-05 09:49:50 +08:00
|
|
|
assert.Equal(t, int64(8192), chunkRows)
|
|
|
|
|
2023-11-01 02:20:15 +08:00
|
|
|
enableInterimIndex := Params.EnableTempSegmentIndex.GetAsBool()
|
|
|
|
assert.Equal(t, true, enableInterimIndex)
|
2023-04-26 10:14:41 +08:00
|
|
|
|
2023-11-01 02:20:15 +08:00
|
|
|
params.Save("queryNode.segcore.interimIndex.enableIndex", "true")
|
|
|
|
enableInterimIndex = Params.EnableTempSegmentIndex.GetAsBool()
|
|
|
|
assert.Equal(t, true, enableInterimIndex)
|
2023-04-26 10:14:41 +08:00
|
|
|
|
2023-11-01 02:20:15 +08:00
|
|
|
nlist = Params.InterimIndexNlist.GetAsInt64()
|
2022-05-05 09:49:50 +08:00
|
|
|
assert.Equal(t, int64(128), nlist)
|
|
|
|
|
2023-11-01 02:20:15 +08:00
|
|
|
nprobe = Params.InterimIndexNProbe.GetAsInt64()
|
2023-04-26 10:14:41 +08:00
|
|
|
assert.Equal(t, int64(16), nprobe)
|
2022-05-05 09:49:50 +08:00
|
|
|
|
2023-04-26 10:14:41 +08:00
|
|
|
params.Remove("queryNode.segcore.growing.nlist")
|
|
|
|
params.Remove("queryNode.segcore.growing.nprobe")
|
2022-12-07 18:01:19 +08:00
|
|
|
params.Save("queryNode.segcore.chunkRows", "64")
|
|
|
|
chunkRows = Params.ChunkRows.GetAsInt64()
|
2022-05-05 09:49:50 +08:00
|
|
|
assert.Equal(t, int64(1024), chunkRows)
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
params.Save("queryNode.gracefulStopTimeout", "100")
|
2023-08-31 09:59:01 +08:00
|
|
|
gracefulStopTimeout := &Params.GracefulStopTimeout
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, int64(100), gracefulStopTimeout.GetAsInt64())
|
2023-08-09 11:37:15 +08:00
|
|
|
|
|
|
|
assert.Equal(t, false, Params.EnableWorkerSQCostMetrics.GetAsBool())
|
2021-12-23 18:39:11 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test dataCoordConfig", func(t *testing.T) {
|
2023-08-31 09:59:01 +08:00
|
|
|
Params := ¶ms.DataCoordCfg
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, 24*60*60*time.Second, Params.SegmentMaxLifetime.GetAsDuration(time.Second))
|
|
|
|
assert.True(t, Params.EnableGarbageCollection.GetAsBool())
|
|
|
|
assert.Equal(t, Params.EnableActiveStandby.GetAsBool(), false)
|
|
|
|
t.Logf("dataCoord EnableActiveStandby = %t", Params.EnableActiveStandby.GetAsBool())
|
2023-11-07 14:02:20 +08:00
|
|
|
|
|
|
|
assert.Equal(t, false, Params.AutoBalance.GetAsBool())
|
|
|
|
assert.Equal(t, 10, Params.CheckAutoBalanceConfigInterval.GetAsInt())
|
2021-12-23 18:39:11 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test dataNodeConfig", func(t *testing.T) {
|
2023-08-31 09:59:01 +08:00
|
|
|
Params := ¶ms.DataNodeCfg
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-11-04 14:25:38 +08:00
|
|
|
SetNodeID(2)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-11-04 14:25:38 +08:00
|
|
|
id := GetNodeID()
|
2022-02-09 14:41:45 +08:00
|
|
|
t.Logf("NodeID: %d", id)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
length := Params.FlowGraphMaxQueueLength.GetAsInt()
|
2022-02-09 14:41:45 +08:00
|
|
|
t.Logf("flowGraphMaxQueueLength: %d", length)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
maxParallelism := Params.FlowGraphMaxParallelism.GetAsInt()
|
2022-02-09 14:41:45 +08:00
|
|
|
t.Logf("flowGraphMaxParallelism: %d", maxParallelism)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2023-06-16 14:14:39 +08:00
|
|
|
maxParallelSyncTaskNum := Params.MaxParallelSyncTaskNum.GetAsInt()
|
|
|
|
t.Logf("maxParallelSyncTaskNum: %d", maxParallelSyncTaskNum)
|
|
|
|
|
2022-12-07 18:01:19 +08:00
|
|
|
size := Params.FlushInsertBufferSize.GetAsInt()
|
2022-02-09 14:41:45 +08:00
|
|
|
t.Logf("FlushInsertBufferSize: %d", size)
|
2021-12-23 18:39:11 +08:00
|
|
|
|
2023-08-31 09:59:01 +08:00
|
|
|
period := &Params.SyncPeriod
|
2022-11-12 21:09:04 +08:00
|
|
|
t.Logf("SyncPeriod: %v", period)
|
2022-12-07 18:01:19 +08:00
|
|
|
assert.Equal(t, 10*time.Minute, Params.SyncPeriod.GetAsDuration(time.Second))
|
2023-07-24 14:23:00 +08:00
|
|
|
|
2023-08-31 09:59:01 +08:00
|
|
|
bulkinsertTimeout := &Params.BulkInsertTimeoutSeconds
|
2023-07-24 14:23:00 +08:00
|
|
|
t.Logf("BulkInsertTimeoutSeconds: %v", bulkinsertTimeout)
|
|
|
|
assert.Equal(t, "18000", Params.BulkInsertTimeoutSeconds.GetValue())
|
2023-10-19 08:28:08 +08:00
|
|
|
|
|
|
|
channelWorkPoolSize := Params.ChannelWorkPoolSize.GetAsInt()
|
|
|
|
t.Logf("channelWorkPoolSize: %d", channelWorkPoolSize)
|
|
|
|
assert.Equal(t, -1, Params.ChannelWorkPoolSize.GetAsInt())
|
2021-12-23 18:39:11 +08:00
|
|
|
})
|
|
|
|
|
2022-12-16 10:03:27 +08:00
|
|
|
t.Run("test indexNodeConfig", func(t *testing.T) {
|
2023-08-31 09:59:01 +08:00
|
|
|
Params := ¶ms.IndexNodeCfg
|
2022-12-16 10:03:27 +08:00
|
|
|
params.Save(Params.GracefulStopTimeout.Key, "50")
|
|
|
|
assert.Equal(t, Params.GracefulStopTimeout.GetAsInt64(), int64(50))
|
|
|
|
})
|
|
|
|
|
2023-03-03 15:21:48 +08:00
|
|
|
t.Run("channel config priority", func(t *testing.T) {
|
2023-08-31 09:59:01 +08:00
|
|
|
Params := ¶ms.CommonCfg
|
2023-03-03 15:21:48 +08:00
|
|
|
params.Save(Params.RootCoordDml.Key, "dml1")
|
|
|
|
params.Save(Params.RootCoordDml.FallbackKeys[0], "dml2")
|
|
|
|
|
|
|
|
assert.Equal(t, "by-dev-dml1", Params.RootCoordDml.GetValue())
|
|
|
|
})
|
2021-12-23 18:39:11 +08:00
|
|
|
}
|
2023-02-09 14:28:31 +08:00
|
|
|
|
|
|
|
func TestForbiddenItem(t *testing.T) {
|
|
|
|
Init()
|
|
|
|
params := Get()
|
|
|
|
|
2023-09-05 10:31:48 +08:00
|
|
|
params.baseTable.mgr.OnEvent(&config.Event{
|
2023-02-09 14:28:31 +08:00
|
|
|
Key: params.CommonCfg.ClusterPrefix.Key,
|
|
|
|
Value: "new-cluster",
|
|
|
|
})
|
|
|
|
assert.Equal(t, "by-dev", params.CommonCfg.ClusterPrefix.GetValue())
|
|
|
|
}
|