Skip to content

Commit

Permalink
[LI-CHERRY-PICK] [987f0ee] KAFKA-8164: Add support for retrying failed (
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlw committed Jan 27, 2022
1 parent 9bd81c1 commit 77737fb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
- name: Run tests
env:
SCALA_VERSION: ${{ matrix.scalaVersion }}
run: ./gradlew -PscalaVersion="$SCALA_VERSION" cleanTest clients:integrationTest --no-daemon -PtestLoggingEvents=started,passed,skipped,failed
run: ./gradlew -PmaxTestRetries=3 -PscalaVersion="$SCALA_VERSION" cleanTest clients:integrationTest --no-daemon -PtestLoggingEvents=started,passed,skipped,failed
int-test-core:
# Name the Job
name: core:integrationTest_${{ matrix.scalaVersion }} (${{ matrix.prefix }})
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
# Use set -f to disable shell expansion on *
run: >
set -f
&& ./gradlew -PscalaVersion="$SCALA_VERSION" -PtestLoggingEvents=started,passed,skipped,failed --no-daemon cleanTest core:integrationTest `for i in $PREFIX; do printf ' --tests %s*' $i; done`
&& ./gradlew -PmaxTestRetries=3 -PscalaVersion="$SCALA_VERSION" -PtestLoggingEvents=started,passed,skipped,failed --no-daemon cleanTest core:integrationTest `for i in $PREFIX; do printf ' --tests %s*' $i; done`
&& set +f
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/int-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Run tests
env:
SCALA_VERSION: ${{ matrix.scalaVersion }}
run: ./gradlew -Pversion=${{ env.RELEASE_VERSION }} cleanTest clients:integrationTest --no-daemon -PtestLoggingEvents=started,passed,skipped,failed
run: ./gradlew -PmaxTestRetries=3 -Pversion=${{ env.RELEASE_VERSION }} cleanTest clients:integrationTest --no-daemon -PtestLoggingEvents=started,passed,skipped,failed
core:
# Name the Job
name: core_${{ matrix.scalaVersion }} (${{ matrix.prefix }})
Expand Down Expand Up @@ -89,6 +89,6 @@ jobs:
# Use set -f to disable shell expansion on *
run: >
set -f
&& ./gradlew -PscalaVersion="$SCALA_VERSION" -PtestLoggingEvents=started,passed,skipped,failed --no-daemon cleanTest core:integrationTest `for i in $PREFIX; do printf ' --tests %s*' $i; done`
&& ./gradlew -PmaxTestRetries=3 -PscalaVersion="$SCALA_VERSION" -PtestLoggingEvents=started,passed,skipped,failed --no-daemon cleanTest core:integrationTest `for i in $PREFIX; do printf ' --tests %s*' $i; done`
&& set +f
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,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:

Expand Down
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ buildscript {
classpath "org.owasp:dependency-check-gradle:$versions.owaspDepCheckPlugin"
classpath "com.diffplug.spotless:spotless-plugin-gradle:$versions.spotlessPlugin"
classpath "gradle.plugin.com.github.spotbugs:spotbugs-gradle-plugin:$versions.spotbugsPlugin"
classpath "org.gradle:test-retry-gradle-plugin:$versions.testRetryPlugin"
classpath libs.jaxbApi
}
}
Expand Down Expand Up @@ -99,6 +100,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") }

Expand Down Expand Up @@ -168,6 +172,7 @@ subprojects {
apply plugin: 'signing'
apply plugin: 'checkstyle'
apply plugin: "com.github.spotbugs"
apply plugin: 'org.gradle.test-retry'

sourceCompatibility = minJavaVersion
targetCompatibility = minJavaVersion
Expand Down Expand Up @@ -300,6 +305,11 @@ subprojects {
exceptionFormat = testExceptionFormat
}
logTestStdout.rehydrate(delegate, owner, this)()

retry {
maxRetries = userMaxTestRetries
maxFailures = userMaxTestRetryFailures
}
}

task integrationTest(type: Test, dependsOn: compileJava) {
Expand Down
1 change: 1 addition & 0 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ versions += [
spotbugs: "3.1.12",
spotbugsPlugin: "1.6.9",
spotlessPlugin: "3.23.1",
testRetryPlugin: "1.3.1",
zookeeper: "3.5.8",
zstd: "1.4.3-1",
conscrypt: "2.1.0",
Expand Down

0 comments on commit 77737fb

Please sign in to comment.