Search in sources :

Example 21 with Completable

use of io.servicetalk.concurrent.api.Completable in project servicetalk by apple.

the class RetryingHttpRequesterFilterAutoRetryStrategiesTest method disableWaitForLb.

@ParameterizedTest
@ValueSource(booleans = { false, true })
void disableWaitForLb(boolean offloading) {
    final ContextAwareRetryingHttpClientFilter filter = newFilter(new RetryingHttpRequesterFilter.Builder().waitForLoadBalancer(false), offloading);
    Completable retry = applyRetry(filter, 1, NO_AVAILABLE_HOST);
    toSource(retry).subscribe(retrySubscriber);
    verifyRetryResultCompleted();
}
Also used : Completable(io.servicetalk.concurrent.api.Completable) TestCompletable(io.servicetalk.concurrent.api.TestCompletable) ContextAwareRetryingHttpClientFilter(io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 22 with Completable

use of io.servicetalk.concurrent.api.Completable in project servicetalk by apple.

the class RetryingHttpRequesterFilterAutoRetryStrategiesTest method defaultForNoAvailableHostWhenServiceDiscovererTerminated.

@ParameterizedTest
@ValueSource(booleans = { false, true })
void defaultForNoAvailableHostWhenServiceDiscovererTerminated(boolean offloading) {
    final ContextAwareRetryingHttpClientFilter filter = newFilter(new RetryingHttpRequesterFilter.Builder(), offloading);
    Completable retry = applyRetry(filter, 1, NO_AVAILABLE_HOST);
    toSource(retry).subscribe(retrySubscriber);
    assertThat(retrySubscriber.pollTerminal(10, MILLISECONDS), is(nullValue()));
    sdStatus.onComplete();
    verifyRetryResultCompleted();
}
Also used : Completable(io.servicetalk.concurrent.api.Completable) TestCompletable(io.servicetalk.concurrent.api.TestCompletable) ContextAwareRetryingHttpClientFilter(io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 23 with Completable

use of io.servicetalk.concurrent.api.Completable in project servicetalk by apple.

the class RetryingHttpRequesterFilterAutoRetryStrategiesTest method maxRetriesAreHonored.

@ParameterizedTest
@ValueSource(booleans = { false, true })
void maxRetriesAreHonored(boolean offloading) {
    final ContextAwareRetryingHttpClientFilter filter = newFilter(new RetryingHttpRequesterFilter.Builder().maxTotalRetries(1), offloading);
    Completable retry = applyRetry(filter, 2, RETRYABLE_EXCEPTION);
    toSource(retry).subscribe(retrySubscriber);
    verifyRetryResultError(RETRYABLE_EXCEPTION);
}
Also used : Completable(io.servicetalk.concurrent.api.Completable) TestCompletable(io.servicetalk.concurrent.api.TestCompletable) ContextAwareRetryingHttpClientFilter(io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 24 with Completable

use of io.servicetalk.concurrent.api.Completable in project servicetalk by apple.

the class RetryingHttpRequesterFilterAutoRetryStrategiesTest method defaultForNonRetryableEx.

@ParameterizedTest
@ValueSource(booleans = { false, true })
void defaultForNonRetryableEx(boolean offloading) {
    final ContextAwareRetryingHttpClientFilter filter = newFilter(new RetryingHttpRequesterFilter.Builder(), offloading);
    Completable retry = applyRetry(filter, 1, DELIBERATE_EXCEPTION);
    toSource(retry).subscribe(retrySubscriber);
    verifyRetryResultError(DELIBERATE_EXCEPTION);
}
Also used : Completable(io.servicetalk.concurrent.api.Completable) TestCompletable(io.servicetalk.concurrent.api.TestCompletable) ContextAwareRetryingHttpClientFilter(io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 25 with Completable

use of io.servicetalk.concurrent.api.Completable in project servicetalk by apple.

the class RetryingHttpRequesterFilterAutoRetryStrategiesTest method ignoreSdErrorsForNoAvailableHost.

@ParameterizedTest
@ValueSource(booleans = { false, true })
void ignoreSdErrorsForNoAvailableHost(boolean offloading) {
    final ContextAwareRetryingHttpClientFilter filter = newFilter(new RetryingHttpRequesterFilter.Builder().ignoreServiceDiscovererErrors(true), offloading);
    Completable retry = applyRetry(filter, 1, NO_AVAILABLE_HOST);
    toSource(retry).subscribe(retrySubscriber);
    assertThat("Unexpected subscribe for SD errors.", sdStatus.isSubscribed(), is(false));
    assertThat(retrySubscriber.pollTerminal(10, MILLISECONDS), is(nullValue()));
    lbEvents.onNext(LOAD_BALANCER_READY_EVENT);
    verifyRetryResultCompleted();
}
Also used : Completable(io.servicetalk.concurrent.api.Completable) TestCompletable(io.servicetalk.concurrent.api.TestCompletable) ContextAwareRetryingHttpClientFilter(io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Completable (io.servicetalk.concurrent.api.Completable)73 Test (org.junit.jupiter.api.Test)46 TestCompletable (io.servicetalk.concurrent.api.TestCompletable)31 ContextAwareRetryingHttpClientFilter (io.servicetalk.http.netty.RetryingHttpRequesterFilter.ContextAwareRetryingHttpClientFilter)28 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 TestCompletableSubscriber (io.servicetalk.concurrent.test.internal.TestCompletableSubscriber)19 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)17 Matchers.is (org.hamcrest.Matchers.is)16 ValueSource (org.junit.jupiter.params.provider.ValueSource)16 SourceAdapters.toSource (io.servicetalk.concurrent.api.SourceAdapters.toSource)15 DELIBERATE_EXCEPTION (io.servicetalk.concurrent.internal.DeliberateException.DELIBERATE_EXCEPTION)14 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)13 Mockito.mock (org.mockito.Mockito.mock)13 DEFAULT_ALLOCATOR (io.servicetalk.buffer.netty.BufferAllocators.DEFAULT_ALLOCATOR)12 Answer (org.mockito.stubbing.Answer)12 Executors.immediate (io.servicetalk.concurrent.api.Executors.immediate)11 Single (io.servicetalk.concurrent.api.Single)11 TestPublisher (io.servicetalk.concurrent.api.TestPublisher)11 Mockito.when (org.mockito.Mockito.when)11 AtomicReference (java.util.concurrent.atomic.AtomicReference)10