use of io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter in project servicetalk by apple.
the class RetryingHttpRequesterFilterAutoRetryStrategiesTest method defaultForNoAvailableHostWhenServiceDiscovererTerminated.
@Test
void defaultForNoAvailableHostWhenServiceDiscovererTerminated() {
final ContextAwareRetryingHttpClientFilter filter = newFilter(new RetryingHttpRequesterFilter.Builder());
Completable retry = applyRetry(filter, 1, NO_AVAILABLE_HOST);
toSource(retry).subscribe(retrySubscriber);
assertThat(retrySubscriber.pollTerminal(10, MILLISECONDS), is(nullValue()));
sdStatus.onComplete();
verifyRetryResultCompleted();
}
use of io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter in project servicetalk by apple.
the class RetryingHttpRequesterFilterAutoRetryStrategiesTest method defaultForNoAvailableHostOnUnknownHostException.
@Test
void defaultForNoAvailableHostOnUnknownHostException() {
final ContextAwareRetryingHttpClientFilter filter = newFilter(new RetryingHttpRequesterFilter.Builder());
Completable retry = applyRetry(filter, 1, NO_AVAILABLE_HOST);
toSource(retry).subscribe(retrySubscriber);
assertThat(retrySubscriber.pollTerminal(10, MILLISECONDS), is(nullValue()));
sdStatus.onError(UNKNOWN_HOST_EXCEPTION);
verifyRetryResultError(UNKNOWN_HOST_EXCEPTION);
}
use of io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter in project servicetalk by apple.
the class RetryingHttpRequesterFilterAutoRetryStrategiesTest method defaultForNoAvailableHostMaxRetries.
@Test
void defaultForNoAvailableHostMaxRetries() {
final ContextAwareRetryingHttpClientFilter filter = newFilter(new RetryingHttpRequesterFilter.Builder().ignoreServiceDiscovererErrors(true));
lbEvents.onComplete();
for (int i = 1; i <= 5; i++) {
Completable retry = applyRetry(filter, i, NO_AVAILABLE_HOST);
TestCompletableSubscriber subscriber = new TestCompletableSubscriber();
toSource(retry).subscribe(subscriber);
if (i < 5) {
assertThat(subscriber.awaitOnError(), instanceOf(IllegalStateException.class));
} else {
// ambWith operator could return either error back.
assertThat(subscriber.awaitOnError(), anyOf(instanceOf(NoAvailableHostException.class), instanceOf(IllegalStateException.class)));
}
}
}
use of io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter in project servicetalk by apple.
the class RetryingHttpRequesterFilterAutoRetryStrategiesTest method defaultForNoAvailableHostOnServiceDiscovererError.
@Test
void defaultForNoAvailableHostOnServiceDiscovererError() {
final ContextAwareRetryingHttpClientFilter filter = newFilter(new RetryingHttpRequesterFilter.Builder());
Completable retry = applyRetry(filter, 1, NO_AVAILABLE_HOST);
toSource(retry).subscribe(retrySubscriber);
assertThat(retrySubscriber.pollTerminal(10, MILLISECONDS), is(nullValue()));
sdStatus.onError(DELIBERATE_EXCEPTION);
verifyRetryResultError(DELIBERATE_EXCEPTION);
}
use of io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter in project servicetalk by apple.
the class RetryingHttpRequesterFilterAutoRetryStrategiesTest method newFilter.
private ContextAwareRetryingHttpClientFilter newFilter(final RetryingHttpRequesterFilter filter) {
final FilterableStreamingHttpClient client = mock(FilterableStreamingHttpClient.class);
final HttpExecutionContext executionContext = mock(HttpExecutionContext.class);
when(executionContext.executor()).then((Answer<Executor>) invocation -> immediate());
when(client.executionContext()).then(__ -> executionContext);
final ContextAwareRetryingHttpClientFilter f = (ContextAwareRetryingHttpClientFilter) filter.create(client);
f.inject(lbEvents, sdStatus);
return f;
}
Aggregations