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 (
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestQuotaParam(t *testing.T) {
|
|
|
|
qc := quotaConfig{}
|
|
|
|
qc.init(&baseParams)
|
|
|
|
|
|
|
|
t.Run("test quota", func(t *testing.T) {
|
2022-09-26 16:48:53 +08:00
|
|
|
assert.False(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)
|
|
|
|
assert.Equal(t, defaultMax, qc.DDLIndexRate)
|
|
|
|
assert.Equal(t, defaultMax, qc.DDLFlushRate)
|
|
|
|
assert.Equal(t, defaultMax, qc.DDLCompactionRate)
|
|
|
|
})
|
|
|
|
|
|
|
|
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-09-26 16:48:53 +08:00
|
|
|
assert.Equal(t, true, qc.TtProtectionEnabled)
|
2022-09-16 09:56:47 +08:00
|
|
|
assert.Equal(t, 30*time.Second, qc.MaxTimeTickDelay)
|
|
|
|
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-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)
|
|
|
|
assert.Equal(t, int64(0), qc.NQInQueueThreshold)
|
|
|
|
assert.Equal(t, float64(0), qc.QueueLatencyThreshold)
|
2022-09-16 09:56:47 +08:00
|
|
|
assert.Equal(t, 0.9, qc.CoolOffSpeed)
|
|
|
|
})
|
|
|
|
}
|