Skip to content

Commit

Permalink
[regression-test](framework) support Non concurrent mode apache#26487 (
Browse files Browse the repository at this point in the history
  • Loading branch information
shuke987 authored and gnehil committed Dec 4, 2023
1 parent 005d02d commit aafd1ca
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ class RegressionTest {
static GroovyShell shell
static ExecutorService scriptExecutors
static ExecutorService suiteExecutors
static ExecutorService singleSuiteExecutors
static ExecutorService actionExecutors
static ThreadLocal<Integer> threadLoadedClassNum = new ThreadLocal<>()
static final int cleanLoadedClassesThreshold = 20
static String nonConcurrentTestGroup = "nonConcurrent"

static void main(String[] args) {
CommandLine cmd = ConfigOptions.initCommands(args)
Expand All @@ -70,6 +72,7 @@ class RegressionTest {
}
actionExecutors.shutdown()
suiteExecutors.shutdown()
singleSuiteExecutors.shutdown()
scriptExecutors.shutdown()
log.info("Test finished")
if (!success) {
Expand All @@ -96,6 +99,12 @@ class RegressionTest {
.build();
suiteExecutors = Executors.newFixedThreadPool(config.suiteParallel, suiteFactory)

BasicThreadFactory singleSuiteFactory = new BasicThreadFactory.Builder()
.namingPattern("non-concurrent-thread-%d")
.priority(Thread.MAX_PRIORITY)
.build();
singleSuiteExecutors = Executors.newFixedThreadPool(1, singleSuiteFactory)

BasicThreadFactory actionFactory = new BasicThreadFactory.Builder()
.namingPattern("action-thread-%d")
.priority(Thread.MAX_PRIORITY)
Expand Down Expand Up @@ -131,9 +140,9 @@ class RegressionTest {
return sources
}

static void runScript(Config config, ScriptSource source, Recorder recorder) {
static void runScript(Config config, ScriptSource source, Recorder recorder, boolean isSingleThreadScript) {
def suiteFilter = { String suiteName, String groupName ->
canRun(config, suiteName, groupName)
canRun(config, suiteName, groupName, isSingleThreadScript)
}
def file = source.getFile()
int failureLimit = Integer.valueOf(config.otherConfigs.getOrDefault("max_failure_num", "-1").toString());
Expand All @@ -144,7 +153,14 @@ class RegressionTest {
return;
}
def eventListeners = getEventListeners(config, recorder)
new ScriptContext(file, suiteExecutors, actionExecutors,
ExecutorService executors = null
if (isSingleThreadScript) {
executors = singleSuiteExecutors
} else {
executors = suiteExecutors
}

new ScriptContext(file, executors, actionExecutors,
config, eventListeners, suiteFilter).start { scriptContext ->
try {
SuiteScript suiteScript = source.toScript(scriptContext, shell)
Expand All @@ -168,7 +184,26 @@ class RegressionTest {
scriptSources.eachWithIndex { source, i ->
// log.info("Prepare scripts [${i + 1}/${totalFile}]".toString())
def future = scriptExecutors.submit {
runScript(config, source, recorder)
runScript(config, source, recorder, false)
}
futures.add(future)
}

// wait all scripts
for (Future future : futures) {
try {
future.get()
} catch (Throwable t) {
// do nothing, because already save to Recorder
}
}

log.info('Start to run single scripts')
futures.clear()
scriptSources.eachWithIndex { source, i ->
// log.info("Prepare scripts [${i + 1}/${totalFile}]".toString())
def future = scriptExecutors.submit {
runScript(config, source, recorder, true)
}
futures.add(future)
}
Expand All @@ -192,8 +227,9 @@ class RegressionTest {
{ fileName -> fileName.substring(0, fileName.lastIndexOf(".")) == "load" })
}
log.info('Start to run scripts')
runScripts(config, recorder, directoryFilter,
runScripts(config, recorder, directoryFilter,
{ fileName -> fileName.substring(0, fileName.lastIndexOf(".")) != "load" })

return recorder
}

Expand Down Expand Up @@ -228,7 +264,18 @@ class RegressionTest {
return true
}

static boolean canRun(Config config, String suiteName, String group) {
static boolean canRun(Config config, String suiteName, String group, boolean isSingleThreadScript) {
Set<String> suiteGroups = group.split(',').collect { g -> g.trim() }.toSet();
if (isSingleThreadScript) {
if (!suiteGroups.contains(nonConcurrentTestGroup)) {
return false
}
} else {
if (suiteGroups.contains(nonConcurrentTestGroup)) {
return false
}
}

return filterGroups(config, group) && filterSuites(config, suiteName)
}

Expand Down
2 changes: 1 addition & 1 deletion regression-test/pipeline/p0/conf/regression-conf.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ testDirectories = ""
// this groups will not be executed
excludeGroups = ""
// this suites will not be executed
excludeSuites = "test_sql_block_rule,test_outfile_exception,test_digest,test_aggregate_all_functions2,test_cast_with_scale_type,test_hive_read_orc_complex_type,test_with_and_two_phase_agg,explode,test_cast_function,test_profile,test_broker_load_p2,test_spark_load,test_analyze_stats_p1,test_refresh_mtmv,test_bitmap_filter,test_export_parquet,test_doris_jdbc_catalog"
excludeSuites = "test_outfile_exception,test_digest,test_aggregate_all_functions2,test_cast_with_scale_type,test_hive_read_orc_complex_type,test_with_and_two_phase_agg,explode,test_cast_function,test_profile,test_broker_load_p2,test_spark_load,test_analyze_stats_p1,test_refresh_mtmv,test_bitmap_filter,test_export_parquet,test_doris_jdbc_catalog"

// this directories will not be executed
excludeDirectories = "nereids_tpcds_shape_sf100_p0,nereids_tpch_shape_sf1000_p0,nereids_tpch_shape_sf500_p0,workload_manager_p1,fault_injection_p0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

suite("test_sql_block_rule") {
suite("test_sql_block_rule", "nonConcurrent") {

sql """
DROP SQL_BLOCK_RULE if exists test_rule_partition
Expand Down

0 comments on commit aafd1ca

Please sign in to comment.