Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce JUnit tag "flaky", to exclude tests from running. #5231

Merged
merged 4 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading