Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regressiont-test](framework) support run cases multiple times in regression-test #26871

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.apache.doris.regression.suite.event.StackEventListeners
import org.apache.doris.regression.suite.SuiteScript
import org.apache.doris.regression.suite.event.TeamcityEventListener
import org.apache.doris.regression.util.Recorder
import org.apache.doris.regression.util.TeamcityUtils
import groovy.util.logging.Slf4j
import org.apache.commons.cli.*
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
Expand Down Expand Up @@ -65,10 +66,28 @@ class RegressionTest {
Config config = Config.fromCommandLine(cmd)
initGroovyEnv(config)
boolean success = true
Integer totalFailure = 0
Integer failureLimit = Integer.valueOf(config.otherConfigs.getOrDefault("max_failure_num", "-1").toString())
if (failureLimit <= 0) {
failureLimit = Integer.MAX_VALUE
}

for (int i = 0; i < config.times; i++) {
log.info("=== run ${i} time ===")
if (config.times > 1) {
TeamcityUtils.postfix = i.toString()
}

Recorder recorder = runScripts(config)
success = printResult(config, recorder)
success = (success && printResult(config, recorder))

if (recorder.getFatalNum() > 0) {
break
}
totalFailure += recorder.getFailureOrFatalNum()
if (totalFailure > failureLimit) {
break
}
}
actionExecutors.shutdown()
suiteExecutors.shutdown()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class Recorder {
return failureCounter.get()
}

public int getFatalNum() {
return fatalScriptList.size()
}

void onSuccess(SuiteInfo suiteInfo) {
successList.add(suiteInfo)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,49 @@ import org.apache.tools.ant.util.DateUtils

@CompileStatic
class TeamcityUtils {
static String postfix = ""

static String getSuiteName(String name) {
if (postfix == "") {
return name
} else {
return name+"-"+postfix
}
}

static String formatNow() {
return DateUtils.format(System.currentTimeMillis(), "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
}

static String formatStdOut(SuiteContext suiteContext, String msg) {
String timestamp = formatNow()
return "##teamcity[testStdOut name='${suiteContext.flowName}' out='${escape(msg)}' flowId='${suiteContext.flowId}' timestamp='${timestamp}']"
String name = getSuiteName(suiteContext.flowName)
return "##teamcity[testStdOut name='${name}' out='${escape(msg)}' flowId='${suiteContext.flowId}' timestamp='${timestamp}']"
}

static String formatStdErr(SuiteContext suiteContext, String msg) {
String timestamp = formatNow()
return "##teamcity[testStdErr name='${suiteContext.flowName}' out='${escape(msg)}' flowId='${suiteContext.flowId}' timestamp='${timestamp}']"
String name = getSuiteName(suiteContext.flowName)
return "##teamcity[testStdErr name='${name}' out='${escape(msg)}' flowId='${suiteContext.flowId}' timestamp='${timestamp}']"
}

static void testStarted(SuiteContext suiteContext) {
String timestamp = formatNow()
String name = getSuiteName(suiteContext.flowName)
println("##teamcity[flowStarted flowId='${suiteContext.flowId}' timestamp='${timestamp}']")
println("##teamcity[testStarted name='${suiteContext.flowName}' flowId='${suiteContext.flowId}' timestamp='${timestamp}']")
println("##teamcity[testStarted name='${name}' flowId='${suiteContext.flowId}' timestamp='${timestamp}']")
}

static void testFailed(SuiteContext suiteContext, String msg, String details) {
String timestamp = formatNow()
println("##teamcity[testFailed name='${suiteContext.flowName}' message='${escape(msg)}' flowId='${suiteContext.flowId}' details='${escape(details)}' timestamp='${timestamp}']")
String name = getSuiteName(suiteContext.flowName)
println("##teamcity[testFailed name='${name}' message='${escape(msg)}' flowId='${suiteContext.flowId}' details='${escape(details)}' timestamp='${timestamp}']")
}

static void testFinished(SuiteContext suiteContext, long elapsed) {
String timestamp = formatNow()
println("##teamcity[testFinished name='${suiteContext.flowName}' flowId='${suiteContext.flowId}' duration='${elapsed}' timestamp='${timestamp}']")
String name = getSuiteName(suiteContext.flowName)
println("##teamcity[testFinished name='${name}' flowId='${suiteContext.flowId}' duration='${elapsed}' timestamp='${timestamp}']")
println("##teamcity[flowFinished flowId='${suiteContext.flowId}' timestamp='${timestamp}']")
}

Expand Down