Skip to content

Commit

Permalink
introduce JUnit tag "flaky", to exclude tests from running. (#5231)
Browse files Browse the repository at this point in the history
introduce JUnit tag "flaky", to exclude tests from running.

ExampleTest.testClientCreation fails without real reason, mark it flaky
at the moment. permit this tag in engine-tests/build.gadle.kts to
separate test runs for normal integration tests, and ones which are
not stable on github, for currently unknown reasons. normally of course
it would be better to fix these tests - but accepting pull requests
is coupled on tests running through. now two commands instead of one
run all integration tests:

    gradle integrationTest
    gradle integrationTestFlaky

please do not lightheartedly mark tests as flaky.

ci: split integration test stage into non-flaky and flaky, flaky integration
test stage is non-blocking.  the result of flaky test will be displayed 
also github, result of failing normal test is viewed in jenkins.

---------

Co-authored-by: Josephine Rueckert <jd.rueckert@googlemail.com>
Co-authored-by: BenjaminAmos <24301287+BenjaminAmos@users.noreply.github.com>
  • Loading branch information
3 people authored Apr 5, 2024
1 parent 1b48033 commit d0c6e86
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
23 changes: 22 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pipeline {
}
}

stage('Integration Tests') {
stage('Integration Tests (without flaky tests)') {
steps {
sh './gradlew --console=plain integrationTest'
}
Expand All @@ -176,5 +176,26 @@ pipeline {
}
}
}

stage('Integration Tests (flaky tests only)') {
steps {
warnError("Integration Tests Failed") { // if this errs, mark the build unstable, not failed.
sh './gradlew --console=plain integrationTestFlaky'
}
}
post {
always {
// Gradle generates both a HTML report of the unit tests to `build/reports/tests/*`
// and XML reports to `build/test-results/*`.
// We need to upload the XML reports for visualization in Jenkins.
//
// See https://docs.gradle.org/current/userguide/java_testing.html#test_reporting
junit testResults: '**/build/test-results/integrationTestFlaky/*.xml', allowEmptyResults: true
// Jenkins truncates large test outputs, so archive it as well.
tar file: 'build/integrationTestFlaky-results.tgz', archive: true, compress: true, overwrite: true,
glob: '**/build/test-results/integrationTestFlaky/*.xml'
}
}
}
}
}
25 changes: 22 additions & 3 deletions engine-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
// SPDX-License-Identifier: Apache-2.0

// Engine tests are split out due to otherwise quirky project dependency issues with module tests extending engine tests
// while locally all tests should be run, when building via github, tests can be run separated in the github pipeline
// file. For integration tests, a tag "flaky" was introduced to mark tests which frequently fail pipelines
// gradle test
// gradle --console=plain unitTest
// gradle --console=plain integrationTest
// gradle --console=plain integrationTestFlaky

plugins {
id("java-library")
id("org.jetbrains.gradle.plugin.idea-ext")
Expand Down Expand Up @@ -105,18 +112,30 @@ tasks.register<Test>("unitTest") {
group = "Verification"
description = "Runs unit tests (fast)"
useJUnitPlatform {
excludeTags = setOf("MteTest", "TteTest")
excludeTags("MteTest", "TteTest")
}
systemProperty("junit.jupiter.execution.timeout.default", "1m")
}

tasks.register<Test>("integrationTest") {
dependsOn(tasks.getByPath(":extractNatives"))
group = "Verification"
description = "Runs integration tests (slow) tagged with 'MteTest' or 'TteTest'"
description = "Runs integration tests (slow) tagged with 'MteTest' or 'TteTest', exclude tests tagged 'flaky'."

useJUnitPlatform {
excludeTags("flaky")
includeTags("MteTest", "TteTest")
}
systemProperty("junit.jupiter.execution.timeout.default", "5m")
}

tasks.register<Test>("integrationTestFlaky") {
dependsOn(tasks.getByPath(":extractNatives"))
group = "Verification"
description = "Runs integration tests tagged with 'flaky' and either 'MteTest' or 'TteTest'."

useJUnitPlatform {
includeTags = setOf("MteTest", "TteTest")
includeTags("MteTest & flaky", "TteTest & flaky")
}
systemProperty("junit.jupiter.execution.timeout.default", "5m")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.common.collect.Lists;
import org.joml.Vector3i;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -38,13 +39,15 @@ public class ExampleTest {
private ModuleTestingHelper helper;

@Test
@Tag("flaky")
public void testClientCreation() {
logger.info("Starting test 'testClientCreation'");
Assertions.assertDoesNotThrow(helper::createClient);
logger.info("Done with test 'testClientCreation'");
}

@Test
@Tag("flaky")
public void testClientConnection() throws IOException {
int currentClients = Lists.newArrayList(entityManager.getEntitiesWith(ClientComponent.class)).size();

Expand Down

0 comments on commit d0c6e86

Please sign in to comment.