DBZ-6324 Add retry for flaking tests
This commit is contained in:
parent
f64c35de29
commit
ab66f038e4
@ -26,7 +26,7 @@ public class ConditionalFail extends AnnotationBasedTestRule {
|
|||||||
|
|
||||||
private static final Logger FLAKY_LOGGER = LoggerFactory.getLogger(Flaky.class);
|
private static final Logger FLAKY_LOGGER = LoggerFactory.getLogger(Flaky.class);
|
||||||
|
|
||||||
private static final String JIRA_BASE_URL = "https://issues.jboss.org/browse/";
|
private static final String JIRA_BASE_URL = "https://issues.redhat.com/browse/";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Statement apply(final Statement base, final Description description) {
|
public Statement apply(final Statement base, final Description description) {
|
||||||
@ -80,19 +80,25 @@ private Statement ignoreFlakyFailure(final Statement base, final Description des
|
|||||||
if (flakyFailuresProperty == null || !Boolean.valueOf(flakyFailuresProperty)) {
|
if (flakyFailuresProperty == null || !Boolean.valueOf(flakyFailuresProperty)) {
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
final String flakyAttemptsProperty = System.getProperty(Flaky.FLAKY_ATTEMPTS_FAILURES_PROPERTY, "1");
|
||||||
|
final int attempts = Integer.parseInt(flakyAttemptsProperty);
|
||||||
|
|
||||||
return new Statement() {
|
return new Statement() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate() throws Throwable {
|
public void evaluate() throws Throwable {
|
||||||
|
for (int i = 0; i < attempts; i++) {
|
||||||
try {
|
try {
|
||||||
base.evaluate();
|
base.evaluate();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
catch (final Throwable t) {
|
catch (final Throwable t) {
|
||||||
FLAKY_LOGGER.error("Ignored failure for {}, tracked with {}", description, issueUrl(flakyClass.value()), t);
|
FLAKY_LOGGER.error("Ignored failure for {}, tracked with {}", description, issueUrl(flakyClass.value()), t);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Marks test as skipped
|
// Marks test as skipped
|
||||||
Assume.assumeTrue(String.format("Flaky test %s#%s failed", description.getTestClass().getSimpleName(), description.getMethodName()), false);
|
Assume.assumeTrue(String.format("Flaky test %s#%s failed", description.getTestClass().getSimpleName(), description.getMethodName()), false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
public @interface Flaky {
|
public @interface Flaky {
|
||||||
|
|
||||||
String IGNORE_FLAKY_FAILURES_PROPERTY = "ignoreFlakyFailures";
|
String IGNORE_FLAKY_FAILURES_PROPERTY = "ignoreFlakyFailures";
|
||||||
|
String FLAKY_ATTEMPTS_FAILURES_PROPERTY = "flaky.attempts";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Jira id of the issue tracking the failing test
|
* The Jira id of the issue tracking the failing test
|
||||||
|
Loading…
Reference in New Issue
Block a user