diff --git a/README.md b/README.md index 07153fb202669..baaf12ca4a9b7 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,13 @@ Change the log4j setting in either `clients/src/test/resources/log4j.properties` ./gradlew clients:test --tests RequestResponseTest +### Specifying test retries ### +By default, each failed test is retried once up to a maximum of five retries per test run. Tests are retried at the end of the test task. Adjust these parameters in the following way: + + ./gradlew test -PmaxTestRetries=1 -PmaxTestRetryFailures=5 + +See [Test Retry Gradle Plugin](https://github.com/gradle/test-retry-gradle-plugin) for more details. + ### Generating test coverage reports ### Generate coverage reports for the whole project: @@ -191,6 +198,8 @@ The following options should be set with a `-P` switch, for example `./gradlew - * `skipSigning`: skips signing of artifacts. * `testLoggingEvents`: unit test events to be logged, separated by comma. For example `./gradlew -PtestLoggingEvents=started,passed,skipped,failed test`. * `xmlSpotBugsReport`: enable XML reports for spotBugs. This also disables HTML reports as only one can be enabled at a time. +* `maxTestRetries`: the maximum number of retries for a failing test case. +* `maxTestRetryFailures`: maximum number of test failures before retrying is disabled for subsequent tests. ### Dependency Analysis ### diff --git a/build.gradle b/build.gradle index 1ed38fe3342ff..658821d1154b7 100644 --- a/build.gradle +++ b/build.gradle @@ -37,6 +37,7 @@ buildscript { classpath "org.owasp:dependency-check-gradle:$versions.owaspDepCheckPlugin" classpath "com.diffplug.spotless:spotless-plugin-gradle:$versions.spotlessPlugin" classpath "com.github.spotbugs:spotbugs-gradle-plugin:$versions.spotbugsPlugin" + classpath "org.gradle:test-retry-gradle-plugin:$versions.testRetryPlugin" } } @@ -97,6 +98,9 @@ ext { userMaxForks = project.hasProperty('maxParallelForks') ? maxParallelForks.toInteger() : null + userMaxTestRetries = project.hasProperty('maxTestRetries') ? maxTestRetries.toInteger() : 0 + userMaxTestRetryFailures = project.hasProperty('maxTestRetryFailures') ? maxTestRetryFailures.toInteger() : 0 + skipSigning = project.hasProperty('skipSigning') && skipSigning.toBoolean() shouldSign = !skipSigning && !version.endsWith("SNAPSHOT") && project.gradle.startParameter.taskNames.any { it.contains("upload") } @@ -163,6 +167,7 @@ subprojects { apply plugin: 'signing' apply plugin: 'checkstyle' apply plugin: "com.github.spotbugs" + apply plugin: 'org.gradle.test-retry' sourceCompatibility = minJavaVersion targetCompatibility = minJavaVersion @@ -289,6 +294,11 @@ subprojects { exceptionFormat = testExceptionFormat } logTestStdout.rehydrate(delegate, owner, this)() + + retry { + maxRetries = userMaxTestRetries + maxFailures = userMaxTestRetryFailures + } } task integrationTest(type: Test, dependsOn: compileJava) { diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index f5673de4c8de6..0c2116cab7c9c 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -112,6 +112,7 @@ versions += [ spotbugs: "3.1.12", spotbugsPlugin: "3.0.0", spotlessPlugin: "3.27.1", + testRetryPlugin: "1.1.0", zookeeper: "3.5.6", zstd: "1.4.4-7" ]