Search in sources :

Example 1 with RetryBackoffSpec

use of reactor.util.retry.RetryBackoffSpec in project reactor-core by reactor.

the class FluxRetryWhenTest method fluxRetryRandomBackoffNoArithmeticException.

@Test
public void fluxRetryRandomBackoffNoArithmeticException() {
    final Duration EXPLICIT_MAX = Duration.ofSeconds(100_000);
    final Duration INIT = Duration.ofSeconds(10);
    StepVerifier.withVirtualTime(() -> {
        RetryBackoffSpec retryBuilder = Retry.backoff(80, INIT).maxBackoff(EXPLICIT_MAX).jitter(0d);
        return Flux.error(new IllegalStateException("boom")).retryWhen(retryBuilder);
    }).expectSubscription().thenAwait(Duration.ofNanos(Long.MAX_VALUE)).expectErrorSatisfies(e -> assertThat(e).hasMessage("Retries exhausted: 80/80").isInstanceOf(IllegalStateException.class).hasCause(new IllegalStateException("boom"))).verify();
}
Also used : StepVerifier(reactor.test.StepVerifier) Retry(reactor.util.retry.Retry) Scannable(reactor.core.Scannable) ContextView(reactor.util.context.ContextView) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Tuple2(reactor.util.function.Tuple2) Percentage(org.assertj.core.data.Percentage) RetryBackoffSpec(reactor.util.retry.RetryBackoffSpec) Scheduler(reactor.core.scheduler.Scheduler) Function(java.util.function.Function) ArrayList(java.util.ArrayList) CoreSubscriber(reactor.core.CoreSubscriber) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) Assertions(org.assertj.core.api.Assertions) Schedulers(reactor.core.scheduler.Schedulers) LongAssert(org.assertj.core.api.LongAssert) VirtualTimeScheduler(reactor.test.scheduler.VirtualTimeScheduler) Context(reactor.util.context.Context) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) Subscription(org.reactivestreams.Subscription) AssertSubscriber(reactor.test.subscriber.AssertSubscriber) Exceptions(reactor.core.Exceptions) Collections(java.util.Collections) RetryBackoffSpec(reactor.util.retry.RetryBackoffSpec) Duration(java.time.Duration) Test(org.junit.jupiter.api.Test)

Aggregations

IOException (java.io.IOException)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 Assertions (org.assertj.core.api.Assertions)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)1 LongAssert (org.assertj.core.api.LongAssert)1 Percentage (org.assertj.core.data.Percentage)1 Test (org.junit.jupiter.api.Test)1 Subscription (org.reactivestreams.Subscription)1 CoreSubscriber (reactor.core.CoreSubscriber)1 Exceptions (reactor.core.Exceptions)1 Scannable (reactor.core.Scannable)1