mirror of
https://github.com/kestra-io/kestra.git
synced 2025-12-25 02:14:38 -05:00
feat(tests): add flaky tests handling
This commit is contained in:
62
build.gradle
62
build.gradle
@@ -205,23 +205,59 @@ subprojects {
|
|||||||
testImplementation 'org.assertj:assertj-core'
|
testImplementation 'org.assertj:assertj-core'
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
def commonTestConfig = { Test t ->
|
||||||
useJUnitPlatform()
|
|
||||||
|
|
||||||
// set Xmx for test workers
|
// set Xmx for test workers
|
||||||
maxHeapSize = '4g'
|
t.maxHeapSize = '4g'
|
||||||
|
|
||||||
// configure en_US default locale for tests
|
// configure en_US default locale for tests
|
||||||
systemProperty 'user.language', 'en'
|
t.systemProperty 'user.language', 'en'
|
||||||
systemProperty 'user.country', 'US'
|
t.systemProperty 'user.country', 'US'
|
||||||
|
|
||||||
environment 'SECRET_MY_SECRET', "{\"secretKey\":\"secretValue\"}".bytes.encodeBase64().toString()
|
t.environment 'SECRET_MY_SECRET', "{\"secretKey\":\"secretValue\"}".bytes.encodeBase64().toString()
|
||||||
environment 'SECRET_NEW_LINE', "cGFzc3dvcmR2ZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2ZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2\nZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2ZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2ZXJ5dmVyeXZl\neXJsb25n"
|
t.environment 'SECRET_NEW_LINE', "cGFzc3dvcmR2ZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2ZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2\nZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2ZXJ5dmVyeXZleXJsb25ncGFzc3dvcmR2ZXJ5dmVyeXZl\neXJsb25n"
|
||||||
environment 'SECRET_WEBHOOK_KEY', "secretKey".bytes.encodeBase64().toString()
|
t.environment 'SECRET_WEBHOOK_KEY', "secretKey".bytes.encodeBase64().toString()
|
||||||
environment 'SECRET_NON_B64_SECRET', "some secret value"
|
t.environment 'SECRET_NON_B64_SECRET', "some secret value"
|
||||||
environment 'SECRET_PASSWORD', "cGFzc3dvcmQ="
|
t.environment 'SECRET_PASSWORD', "cGFzc3dvcmQ="
|
||||||
environment 'ENV_TEST1', "true"
|
t.environment 'ENV_TEST1', "true"
|
||||||
environment 'ENV_TEST2', "Pass by env"
|
t.environment 'ENV_TEST2', "Pass by env"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register('flakyTest', Test) { Test t ->
|
||||||
|
group = 'verification'
|
||||||
|
description = 'Runs tests tagged @Flaky but does not fail the build.'
|
||||||
|
|
||||||
|
useJUnitPlatform {
|
||||||
|
includeTags 'flaky'
|
||||||
|
}
|
||||||
|
ignoreFailures = true
|
||||||
|
|
||||||
|
reports {
|
||||||
|
junitXml.required = true
|
||||||
|
junitXml.outputPerTestCase = true
|
||||||
|
junitXml.mergeReruns = true
|
||||||
|
junitXml.includeSystemErrLog = true
|
||||||
|
junitXml.outputLocation = layout.buildDirectory.dir("test-results/flakyTest")
|
||||||
|
}
|
||||||
|
commonTestConfig(t)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform {
|
||||||
|
excludeTags 'flaky'
|
||||||
|
}
|
||||||
|
reports {
|
||||||
|
junitXml.required = true
|
||||||
|
junitXml.outputPerTestCase = true
|
||||||
|
junitXml.mergeReruns = true
|
||||||
|
junitXml.includeSystemErrLog = true
|
||||||
|
junitXml.outputLocation = layout.buildDirectory.dir("test-results/test")
|
||||||
|
}
|
||||||
|
commonTestConfig(it)
|
||||||
|
|
||||||
|
|
||||||
|
finalizedBy(tasks.named('flakyTest'))
|
||||||
}
|
}
|
||||||
|
|
||||||
testlogger {
|
testlogger {
|
||||||
|
|||||||
@@ -4,11 +4,18 @@ import java.lang.annotation.ElementType;
|
|||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
import org.junit.jupiter.api.Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* used to document that a test is flaky and needs to be reworked
|
* used to document that a test is flaky and needs to be reworked
|
||||||
*/
|
*/
|
||||||
@Target(ElementType.METHOD)
|
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Tag("flaky")
|
||||||
public @interface FlakyTest {
|
public @interface FlakyTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use to explain why the test is flaky
|
||||||
|
*/
|
||||||
|
String description() default "";
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user