Make RetryTemplate timeout tests more robust
See gh-35963
This commit is contained in:
parent
2137ec70d2
commit
38cf4ab3fc
|
|
@ -517,7 +517,7 @@ class RetryTemplateTests {
|
|||
@Test
|
||||
void retryWithTimeoutExceededAfterFirstRetry() throws Exception {
|
||||
RetryPolicy retryPolicy = RetryPolicy.builder()
|
||||
.timeout(Duration.ofMillis(5))
|
||||
.timeout(Duration.ofMillis(20))
|
||||
.delay(Duration.ZERO)
|
||||
.build();
|
||||
RetryTemplate retryTemplate = new RetryTemplate(retryPolicy);
|
||||
|
|
@ -527,7 +527,7 @@ class RetryTemplateTests {
|
|||
Retryable<String> retryable = () -> {
|
||||
int currentInvocation = invocationCount.incrementAndGet();
|
||||
if (currentInvocation == 2) {
|
||||
Thread.sleep(10);
|
||||
Thread.sleep(50);
|
||||
}
|
||||
throw new CustomException("Boom " + currentInvocation);
|
||||
};
|
||||
|
|
@ -535,7 +535,7 @@ class RetryTemplateTests {
|
|||
assertThat(invocationCount).hasValue(0);
|
||||
assertThatExceptionOfType(RetryException.class)
|
||||
.isThrownBy(() -> retryTemplate.execute(retryable))
|
||||
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(5 ms\\); aborting execution")
|
||||
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(20 ms\\); aborting execution")
|
||||
.withCause(new CustomException("Boom 2"))
|
||||
.satisfies(throwable -> {
|
||||
inOrder.verify(retryListener).beforeRetry(retryPolicy, retryable);
|
||||
|
|
@ -552,7 +552,7 @@ class RetryTemplateTests {
|
|||
@Test
|
||||
void retryWithTimeoutExceededAfterSecondRetry() throws Exception {
|
||||
RetryPolicy retryPolicy = RetryPolicy.builder()
|
||||
.timeout(Duration.ofMillis(5))
|
||||
.timeout(Duration.ofMillis(20))
|
||||
.delay(Duration.ZERO)
|
||||
.build();
|
||||
RetryTemplate retryTemplate = new RetryTemplate(retryPolicy);
|
||||
|
|
@ -562,7 +562,7 @@ class RetryTemplateTests {
|
|||
Retryable<String> retryable = () -> {
|
||||
int currentInvocation = invocationCount.incrementAndGet();
|
||||
if (currentInvocation == 3) {
|
||||
Thread.sleep(10);
|
||||
Thread.sleep(50);
|
||||
}
|
||||
throw new CustomException("Boom " + currentInvocation);
|
||||
};
|
||||
|
|
@ -570,7 +570,7 @@ class RetryTemplateTests {
|
|||
assertThat(invocationCount).hasValue(0);
|
||||
assertThatExceptionOfType(RetryException.class)
|
||||
.isThrownBy(() -> retryTemplate.execute(retryable))
|
||||
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(5 ms\\); aborting execution")
|
||||
.withMessageMatching("Retry policy for operation '.+?' exceeded timeout \\(20 ms\\); aborting execution")
|
||||
.withCause(new CustomException("Boom 3"))
|
||||
.satisfies(throwable -> {
|
||||
var counter = new AtomicInteger(1);
|
||||
|
|
|
|||
Loading…
Reference in New Issue