Commit 4194d400 by Jamie Madill Committed by Angle LUCI CQ

Test Runner: Add maximum failure count.

This will make the test runner early exit after a certain count of failures. This will prevent the bots from running tens of thousands of tests when the whole test run is corrupt. Bug: angleproject:6075 Change-Id: I8f5c19ea694a5ad3a5d5df1429d2ba4b1fe868e3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2976179 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 3f99e4d3
...@@ -27,6 +27,7 @@ following additional command-line arguments: ...@@ -27,6 +27,7 @@ following additional command-line arguments:
* `--flaky-retries` allows for tests to fail a fixed number of times and still pass * `--flaky-retries` allows for tests to fail a fixed number of times and still pass
* `--disable-crash-handler` forces off OS-level crash handling * `--disable-crash-handler` forces off OS-level crash handling
* `--isolated-outdir` specifies a test artifacts directory * `--isolated-outdir` specifies a test artifacts directory
* `--max-failures` specifies a count of failures after which the harness early exits.
`--isolated-script-test-output` and `--isolated-script-perf-test-output` mirror `--results-file` `--isolated-script-test-output` and `--isolated-script-perf-test-output` mirror `--results-file`
and `--histogram-json-file` respectively. and `--histogram-json-file` respectively.
......
...@@ -47,6 +47,7 @@ constexpr char kResultFileArg[] = "--results-file="; ...@@ -47,6 +47,7 @@ constexpr char kResultFileArg[] = "--results-file=";
constexpr char kTestTimeoutArg[] = "--test-timeout="; constexpr char kTestTimeoutArg[] = "--test-timeout=";
constexpr char kDisableCrashHandler[] = "--disable-crash-handler"; constexpr char kDisableCrashHandler[] = "--disable-crash-handler";
constexpr char kIsolatedOutDir[] = "--isolated-outdir="; constexpr char kIsolatedOutDir[] = "--isolated-outdir=";
constexpr char kMaxFailures[] = "--max-failures=";
constexpr char kStartedTestString[] = "[ RUN ] "; constexpr char kStartedTestString[] = "[ RUN ] ";
constexpr char kPassedTestString[] = "[ OK ] "; constexpr char kPassedTestString[] = "[ OK ] ";
...@@ -68,6 +69,7 @@ constexpr int kDefaultBatchTimeout = 600; ...@@ -68,6 +69,7 @@ constexpr int kDefaultBatchTimeout = 600;
constexpr int kDefaultBatchSize = 256; constexpr int kDefaultBatchSize = 256;
constexpr double kIdleMessageTimeout = 15.0; constexpr double kIdleMessageTimeout = 15.0;
constexpr int kDefaultMaxProcesses = 16; constexpr int kDefaultMaxProcesses = 16;
constexpr int kDefaultMaxFailures = 100;
const char *ParseFlagValue(const char *flag, const char *argument) const char *ParseFlagValue(const char *flag, const char *argument)
{ {
...@@ -1056,7 +1058,9 @@ TestSuite::TestSuite(int *argc, char **argv) ...@@ -1056,7 +1058,9 @@ TestSuite::TestSuite(int *argc, char **argv)
mTestTimeout(kDefaultTestTimeout), mTestTimeout(kDefaultTestTimeout),
mBatchTimeout(kDefaultBatchTimeout), mBatchTimeout(kDefaultBatchTimeout),
mBatchId(-1), mBatchId(-1),
mFlakyRetries(0) mFlakyRetries(0),
mMaxFailures(kDefaultMaxFailures),
mFailureCount(0)
{ {
ASSERT(mInstance == nullptr); ASSERT(mInstance == nullptr);
mInstance = this; mInstance = this;
...@@ -1308,6 +1312,7 @@ bool TestSuite::parseSingleArg(const char *argument) ...@@ -1308,6 +1312,7 @@ bool TestSuite::parseSingleArg(const char *argument)
ParseIntArg(kTestTimeoutArg, argument, &mTestTimeout) || ParseIntArg(kTestTimeoutArg, argument, &mTestTimeout) ||
ParseIntArg("--batch-timeout=", argument, &mBatchTimeout) || ParseIntArg("--batch-timeout=", argument, &mBatchTimeout) ||
ParseIntArg(kFlakyRetries, argument, &mFlakyRetries) || ParseIntArg(kFlakyRetries, argument, &mFlakyRetries) ||
ParseIntArg(kMaxFailures, argument, &mMaxFailures) ||
// Other test functions consume the batch ID, so keep it in the list. // Other test functions consume the batch ID, so keep it in the list.
ParseIntArgNoDelete(kBatchId, argument, &mBatchId) || ParseIntArgNoDelete(kBatchId, argument, &mBatchId) ||
ParseStringArg("--results-directory=", argument, &mResultsDirectory) || ParseStringArg("--results-directory=", argument, &mResultsDirectory) ||
...@@ -1569,10 +1574,12 @@ bool TestSuite::finishProcess(ProcessInfo *processInfo) ...@@ -1569,10 +1574,12 @@ bool TestSuite::finishProcess(ProcessInfo *processInfo)
else if (result.type == TestResultType::Timeout) else if (result.type == TestResultType::Timeout)
{ {
printf(" (TIMEOUT in %0.1lf s)\n", result.elapsedTimeSeconds); printf(" (TIMEOUT in %0.1lf s)\n", result.elapsedTimeSeconds);
mFailureCount++;
} }
else else
{ {
printf(" (%s)\n", ResultTypeToString(result.type)); printf(" (%s)\n", ResultTypeToString(result.type));
mFailureCount++;
const std::string &batchStdout = processInfo->process->getStdout(); const std::string &batchStdout = processInfo->process->getStdout();
PrintTestOutputSnippet(id, result, batchStdout); PrintTestOutputSnippet(id, result, batchStdout);
...@@ -1702,6 +1709,7 @@ int TestSuite::run() ...@@ -1702,6 +1709,7 @@ int TestSuite::run()
{ {
// Because the whole batch failed we can't know how long each test took. // Because the whole batch failed we can't know how long each test took.
mTestResults.results[testIdentifier].type = TestResultType::Timeout; mTestResults.results[testIdentifier].type = TestResultType::Timeout;
mFailureCount++;
} }
processIter = mCurrentProcesses.erase(processIter); processIter = mCurrentProcesses.erase(processIter);
...@@ -1727,6 +1735,14 @@ int TestSuite::run() ...@@ -1727,6 +1735,14 @@ int TestSuite::run()
messageTimer.start(); messageTimer.start();
} }
// Early exit if we passed the maximum failure threshold. Still wait for current tests.
if (mFailureCount > mMaxFailures)
{
printf("Reached maximum failure count (%d), clearing test queue.\n", mMaxFailures);
TestQueue emptyTestQueue;
std::swap(mTestQueue, emptyTestQueue);
}
// Sleep briefly and continue. // Sleep briefly and continue.
angle::Sleep(100); angle::Sleep(100);
} }
......
...@@ -193,6 +193,8 @@ class TestSuite ...@@ -193,6 +193,8 @@ class TestSuite
int mBatchTimeout; int mBatchTimeout;
int mBatchId; int mBatchId;
int mFlakyRetries; int mFlakyRetries;
int mMaxFailures;
int mFailureCount;
std::vector<std::string> mChildProcessArgs; std::vector<std::string> mChildProcessArgs;
std::map<TestIdentifier, FileLine> mTestFileLines; std::map<TestIdentifier, FileLine> mTestFileLines;
std::vector<ProcessInfo> mCurrentProcesses; std::vector<ProcessInfo> mCurrentProcesses;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment