2022-09-16 09:56:47 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you 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 (
|
2022-10-14 14:27:25 +08:00
|
|
|
"math"
|
2022-09-16 09:56:47 +08:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestQuotaParam(t *testing.T) {
|
|
|
|
qc := quotaConfig{}
|
|
|
|
qc.init(&baseParams)
|
|
|
|
|
|
|
|
t.Run("test quota", func(t *testing.T) {
|
2022-10-17 16:23:25 +08:00
|
|
|
assert.True(t, qc.QuotaAndLimitsEnabled)
|
2022-09-16 09:56:47 +08:00
|
|
|
assert.Equal(t, float64(3), qc.QuotaCenterCollectInterval)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test ddl", func(t *testing.T) {
|
2022-09-26 16:48:53 +08:00
|
|
|
assert.Equal(t, false, qc.DDLLimitEnabled)
|
2022-09-16 09:56:47 +08:00
|
|
|
assert.Equal(t, defaultMax, qc.DDLCollectionRate)
|
|
|
|
assert.Equal(t, defaultMax, qc.DDLPartitionRate)
|
2022-10-09 14:30:58 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test functional params", func(t *testing.T) {
|
|
|
|
assert.Equal(t, false, qc.IndexLimitEnabled)
|
|
|
|
assert.Equal(t, defaultMax, qc.MaxIndexRate)
|
|
|
|
assert.Equal(t, false, qc.FlushLimitEnabled)
|
|
|
|
assert.Equal(t, defaultMax, qc.MaxFlushRate)
|
|
|
|
assert.Equal(t, false, qc.CompactionLimitEnabled)
|
|
|
|
assert.Equal(t, defaultMax, qc.MaxCompactionRate)
|
2022-09-16 09:56:47 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test dml", func(t *testing.T) {
|
2022-09-26 16:48:53 +08:00
|
|
|
assert.Equal(t, false, qc.DMLLimitEnabled)
|
2022-09-16 09:56:47 +08:00
|
|
|
assert.Equal(t, defaultMax, qc.DMLMaxInsertRate)
|
|
|
|
assert.Equal(t, defaultMin, qc.DMLMinInsertRate)
|
|
|
|
assert.Equal(t, defaultMax, qc.DMLMaxDeleteRate)
|
|
|
|
assert.Equal(t, defaultMin, qc.DMLMinDeleteRate)
|
|
|
|
assert.Equal(t, defaultMax, qc.DMLMaxBulkLoadRate)
|
|
|
|
assert.Equal(t, defaultMin, qc.DMLMinBulkLoadRate)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test dql", func(t *testing.T) {
|
2022-09-26 16:48:53 +08:00
|
|
|
assert.Equal(t, false, qc.DQLLimitEnabled)
|
2022-09-16 09:56:47 +08:00
|
|
|
assert.Equal(t, defaultMax, qc.DQLMaxSearchRate)
|
|
|
|
assert.Equal(t, defaultMin, qc.DQLMinSearchRate)
|
|
|
|
assert.Equal(t, defaultMax, qc.DQLMaxQueryRate)
|
|
|
|
assert.Equal(t, defaultMin, qc.DQLMinQueryRate)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test limits", func(t *testing.T) {
|
|
|
|
assert.Equal(t, 64, qc.MaxCollectionNum)
|
|
|
|
})
|
|
|
|
|
2022-09-26 16:48:53 +08:00
|
|
|
t.Run("test limit writing", func(t *testing.T) {
|
2022-09-16 09:56:47 +08:00
|
|
|
assert.False(t, qc.ForceDenyWriting)
|
2022-11-17 20:21:14 +08:00
|
|
|
assert.Equal(t, false, qc.TtProtectionEnabled)
|
|
|
|
assert.Equal(t, math.MaxInt64, int(qc.MaxTimeTickDelay))
|
2022-09-16 09:56:47 +08:00
|
|
|
assert.Equal(t, defaultLowWaterLevel, qc.DataNodeMemoryLowWaterLevel)
|
|
|
|
assert.Equal(t, defaultHighWaterLevel, qc.DataNodeMemoryHighWaterLevel)
|
|
|
|
assert.Equal(t, defaultLowWaterLevel, qc.QueryNodeMemoryLowWaterLevel)
|
|
|
|
assert.Equal(t, defaultHighWaterLevel, qc.QueryNodeMemoryHighWaterLevel)
|
2022-10-12 10:03:22 +08:00
|
|
|
assert.Equal(t, true, qc.DiskProtectionEnabled)
|
|
|
|
assert.Equal(t, defaultMax, qc.DiskQuota)
|
2022-09-16 09:56:47 +08:00
|
|
|
})
|
|
|
|
|
2022-09-26 16:48:53 +08:00
|
|
|
t.Run("test limit reading", func(t *testing.T) {
|
2022-09-16 09:56:47 +08:00
|
|
|
assert.False(t, qc.ForceDenyReading)
|
2022-09-26 16:48:53 +08:00
|
|
|
assert.Equal(t, false, qc.QueueProtectionEnabled)
|
2022-10-14 14:27:25 +08:00
|
|
|
assert.Equal(t, int64(math.MaxInt64), qc.NQInQueueThreshold)
|
|
|
|
assert.Equal(t, defaultMax, qc.QueueLatencyThreshold)
|
2022-10-13 14:57:24 +08:00
|
|
|
assert.Equal(t, false, qc.ResultProtectionEnabled)
|
|
|
|
assert.Equal(t, defaultMax, qc.MaxReadResultRate)
|
2022-09-16 09:56:47 +08:00
|
|
|
assert.Equal(t, 0.9, qc.CoolOffSpeed)
|
|
|
|
})
|
|
|
|
}
|