mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-07 23:49:08 +00:00
Make @Retryable and RetryTemplate timeout tests more robust
See gh-35963
This commit is contained in:
+7
-7
@@ -351,7 +351,7 @@ class ReactiveRetryInterceptorTests {
|
||||
.satisfies(isReactiveException())
|
||||
.havingCause()
|
||||
.isInstanceOf(TimeoutException.class)
|
||||
.withMessageContaining("within 5ms");
|
||||
.withMessageContaining("within 20ms");
|
||||
// 1 initial attempt + 0 retries
|
||||
assertThat(target.counter).hasValue(1);
|
||||
}
|
||||
@@ -363,7 +363,7 @@ class ReactiveRetryInterceptorTests {
|
||||
.satisfies(isReactiveException())
|
||||
.havingCause()
|
||||
.isInstanceOf(TimeoutException.class)
|
||||
.withMessageContaining("within 5ms");
|
||||
.withMessageContaining("within 20ms");
|
||||
// 1 initial attempt + 0 retries
|
||||
assertThat(target.counter).hasValue(1);
|
||||
}
|
||||
@@ -464,16 +464,16 @@ class ReactiveRetryInterceptorTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Retryable(timeout = 5, delay = 0)
|
||||
@Retryable(timeout = 20, delay = 0)
|
||||
public Mono<Object> retryOperationWithTimeoutExceededAfterInitialFailure() {
|
||||
return Mono.fromCallable(() -> {
|
||||
counter.incrementAndGet();
|
||||
Thread.sleep(20);
|
||||
Thread.sleep(100);
|
||||
throw new IOException(counter.toString());
|
||||
});
|
||||
}
|
||||
|
||||
@Retryable(timeout = 5, delay = 10)
|
||||
@Retryable(timeout = 20, delay = 100) // Delay > Timeout
|
||||
public Mono<Object> retryOperationWithTimeoutExceededAfterFirstDelayButBeforeFirstRetry() {
|
||||
return Mono.fromCallable(() -> {
|
||||
counter.incrementAndGet();
|
||||
@@ -486,7 +486,7 @@ class ReactiveRetryInterceptorTests {
|
||||
return Mono.fromCallable(() -> {
|
||||
counter.incrementAndGet();
|
||||
if (counter.get() == 2) {
|
||||
Thread.sleep(50);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
throw new IOException(counter.toString());
|
||||
});
|
||||
@@ -497,7 +497,7 @@ class ReactiveRetryInterceptorTests {
|
||||
return Mono.fromCallable(() -> {
|
||||
counter.incrementAndGet();
|
||||
if (counter.get() == 3) {
|
||||
Thread.sleep(50);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
throw new IOException(counter.toString());
|
||||
});
|
||||
|
||||
+5
-5
@@ -426,14 +426,14 @@ class RetryInterceptorTests {
|
||||
throw new IOException(Integer.toString(counter));
|
||||
}
|
||||
|
||||
@Retryable(timeout = 5, delay = 10)
|
||||
@Retryable(timeout = 20, delay = 0)
|
||||
public void retryOperationWithTimeoutExceededAfterInitialFailure() throws Exception {
|
||||
counter++;
|
||||
Thread.sleep(10);
|
||||
Thread.sleep(100);
|
||||
throw new IOException(Integer.toString(counter));
|
||||
}
|
||||
|
||||
@Retryable(timeout = 5, delay = 10)
|
||||
@Retryable(timeout = 20, delay = 100) // Delay > Timeout
|
||||
public void retryOperationWithTimeoutExceededAfterFirstDelayButBeforeFirstRetry() throws IOException {
|
||||
counter++;
|
||||
throw new IOException(Integer.toString(counter));
|
||||
@@ -443,7 +443,7 @@ class RetryInterceptorTests {
|
||||
public void retryOperationWithTimeoutExceededAfterFirstRetry() throws Exception {
|
||||
counter++;
|
||||
if (counter == 2) {
|
||||
Thread.sleep(50);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
throw new IOException(Integer.toString(counter));
|
||||
}
|
||||
@@ -452,7 +452,7 @@ class RetryInterceptorTests {
|
||||
public void retryOperationWithTimeoutExceededAfterSecondRetry() throws Exception {
|
||||
counter++;
|
||||
if (counter == 3) {
|
||||
Thread.sleep(50);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
throw new IOException(Integer.toString(counter));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user