Files
doris/regression-test/plugins/plugin_check_sql_single_value.groovy
ElvinWei a713c225a5 [regressiontest](statistics) Collate and supplement statistics regression test (#19901)
This pr is mainly supplement statistics regression test. include the following:

analyze stats p0 tests:

1. Universal analysis

analyze stats p1 tests:

1. Universal analysis
2. Sampled analysis
3. Incremental analysis
4. Automatic analysis
5. Periodic analysis

manage stats p0 tests:

1. Alter table stats
2. Show table stats
3. Alter column stats
4. Show column stats and histogram
5. Drop column stats
6. Drop expired stats

TODO:

1. Supplement related documents
2. Optimize for unstable cases encountered during testing
3. Add other cases

For pr related to statistics, should ensure that all of these cases pass!
2023-05-24 20:17:28 +08:00

81 lines
2.8 KiB
Groovy

// Licensed to the Apache Software Foundation (ASF) 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.
import org.apache.doris.regression.suite.Suite
// Check whether the sql result is equal to a certain value
// Usage: isSqlValueEqualToTarget(xxxSql, "", 10000, 30)
Suite.metaClass.isSqlValueEqualToTarget = {
String statement, String expectedValue, int durationInMs, int maxRetryCnt /* param */ ->
Suite suite = delegate as Suite
int waitCnt = 0
do {
def sqlRes = sql statement
suite.getLogger().info("sql res ${sqlRes}, expected value [[${expectedValue}]]"
.toString())
if (expectedValue.isEmpty() && sqlRes.size() == 0) {
return true
}
if (sqlRes.size() == 1 && sqlRes[0].size() == 1) {
if (sqlRes[0][0].toString() == expectedValue) {
return true
}
}
Thread.sleep(durationInMs)
waitCnt = waitCnt + 1
suite.getLogger().info("retried times: ${waitCnt}".toString())
} while (waitCnt < maxRetryCnt)
return false
}
logger.info("Added 'isSqlValueEqualToTarget' function to Suite")
// Check whether the sql result is greater than to a certain value
// Usage: isSqlValueGreaterThanTarget(xxxSql, 1, 10000, 30)
Suite.metaClass.isSqlValueGreaterThanTarget = {
String statement, int expectedValue, int durationInMs, int maxRetryCnt /* param */ ->
Suite suite = delegate as Suite
int waitCnt = 0
do {
def sqlRes = sql statement
suite.getLogger().info("sql res: ${sqlRes}, expected >= [[${expectedValue}]]"
.toString())
if (sqlRes.size() == 1 && sqlRes[0].size() == 1) {
if (sqlRes[0][0] >= expectedValue) {
return true
}
}
Thread.sleep(durationInMs)
waitCnt = waitCnt + 1
suite.getLogger().info("retried times: ${waitCnt}".toString())
} while (waitCnt < maxRetryCnt)
return false
}
logger.info("Added 'isSqlValueGreaterThanTarget' function to Suite")