From a8eddbe8439e8d37a9562fef33276a7d62ccd7db Mon Sep 17 00:00:00 2001 From: Juan Date: Mon, 2 Oct 2023 06:55:12 -0700 Subject: [PATCH] Pivotal ID # 186157290: Re execute test flaky itest (#753) https://www.pivotaltracker.com/story/show/186157290 --- buildSrc/src/main/kotlin/Plugins.kt | 2 + gradle/itest.gradle.kts | 37 --------------- submission/submission-webapp/build.gradle.kts | 45 +++++++++++++++++-- 3 files changed, 43 insertions(+), 41 deletions(-) delete mode 100644 gradle/itest.gradle.kts diff --git a/buildSrc/src/main/kotlin/Plugins.kt b/buildSrc/src/main/kotlin/Plugins.kt index d5b9bcc50..09cdc1976 100644 --- a/buildSrc/src/main/kotlin/Plugins.kt +++ b/buildSrc/src/main/kotlin/Plugins.kt @@ -9,6 +9,7 @@ object PluginVersions { const val SshVersion = "2.10.1" const val SpringBootPluginVersion = "2.7.1" const val SpringDependencyManagementPluginVersion = "1.0.12.RELEASE" + const val GradleRetryVersion = "1.5.5" } object Plugins { @@ -25,4 +26,5 @@ object Plugins { const val SshPlugin = "org.hidetake.ssh" const val SpringBootPlugin = "org.springframework.boot" const val SpringDependencyManagementPlugin = "io.spring.dependency-management" + const val GradleRetry = "org.gradle.test-retry" } diff --git a/gradle/itest.gradle.kts b/gradle/itest.gradle.kts deleted file mode 100644 index e17d2c9ad..000000000 --- a/gradle/itest.gradle.kts +++ /dev/null @@ -1,37 +0,0 @@ -import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL - -val sourceSets = the() - -sourceSets { - create("itest") { - java.srcDir(file("src/itest/java")) - resources.srcDir(file("src/itest/resources")) - compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"] - runtimeClasspath += output + sourceSets["main"].output + compileClasspath - } -} - -val copySqlSchema = tasks.create("copySqlSchema") { - from("$rootDir/infrastructure/src/main/resources/setup/mysql/Schema.sql") - into("$buildDir/resources/itest") -} - -val itest = tasks.create("itest") { - dependsOn(copySqlSchema) - testClassesDirs = sourceSets["itest"].output.classesDirs - classpath = sourceSets["itest"].runtimeClasspath - - val enableFire = project.property("enableFire") - println("##### Running integration tests with fireEnable=$enableFire #######") - systemProperty("enableFire", enableFire) - - useJUnitPlatform() - testLogging.exceptionFormat = FULL - testLogging.showStandardStreams = true - extensions.configure(JacocoTaskExtension::class) { - setDestinationFile(file("$buildDir/jacoco/jacocoITest.exec")) - classDumpDir = file("$buildDir/jacoco/classpathdumps") - } -} - -tasks.getByName("jacocoTestCoverageVerification") { dependsOn(itest) } diff --git a/submission/submission-webapp/build.gradle.kts b/submission/submission-webapp/build.gradle.kts index df1bf881c..b776a639a 100644 --- a/submission/submission-webapp/build.gradle.kts +++ b/submission/submission-webapp/build.gradle.kts @@ -54,6 +54,7 @@ import TestDependencies.XmlUnitMatchers import TestDependencies.rabitMqMock import TestDependencies.slf4jApi import TestDependencies.slf4jImp +import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.springframework.boot.gradle.tasks.bundling.BootJar buildscript { @@ -71,6 +72,7 @@ plugins { id(Plugins.KotlinAllOpenPlugin) version PluginVersions.KotlinPluginVersion id(Plugins.SpringBootPlugin) version PluginVersions.SpringBootPluginVersion id(Plugins.SpringDependencyManagementPlugin) version PluginVersions.SpringDependencyManagementPluginVersion + id(Plugins.GradleRetry) version PluginVersions.GradleRetryVersion } allOpen { @@ -148,14 +150,49 @@ dependencies { testImplementation(KotlinCoroutinesTest) } -apply(from = "$rootDir/gradle/itest.gradle.kts") - tasks.named("bootJar") { archiveBaseName.set("submission-webapp") archiveVersion.set("1.0.0") dependsOn("generateGitProperties") } -tasks.named("processItestResources") { - duplicatesStrategy = DuplicatesStrategy.WARN +sourceSets { + create("itest") { + java.srcDir(file("src/itest/java")) + resources.srcDir(file("src/itest/resources")) + compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"] + runtimeClasspath += output + sourceSets["main"].output + compileClasspath + } +} + +val copySqlSchema = tasks.create("copySqlSchema") { + from("$rootDir/infrastructure/src/main/resources/setup/mysql/Schema.sql") + into("$buildDir/resources/itest") +} + +val itest = tasks.create("itest") { + dependsOn(copySqlSchema) + testClassesDirs = sourceSets["itest"].output.classesDirs + classpath = sourceSets["itest"].runtimeClasspath + + val enableFire = project.property("enableFire")!! + println("##### Running integration tests with fireEnable=$enableFire #######") + systemProperty("enableFire", enableFire) + + useJUnitPlatform() + testLogging.exceptionFormat = TestExceptionFormat.FULL + testLogging.showStandardStreams = true + extensions.configure(JacocoTaskExtension::class) { + setDestinationFile(file("$buildDir/jacoco/jacocoITest.exec")) + classDumpDir = file("$buildDir/jacoco/classpathdumps") + } + + retry { + maxRetries.set(3) + maxFailures.set(10) + failOnPassedAfterRetry.set(false) + } } + +tasks.getByName("jacocoTestCoverageVerification") { dependsOn(itest) } +tasks.named("processItestResources") { duplicatesStrategy = DuplicatesStrategy.WARN }