@ParameterizedTest
    @EnumSource(TestMode.class)
    void test(TestMode mode) {
        server.start();
        final List<Integer> expectedPorts = server.server().activePorts().keySet().stream()
                                                  .map(InetSocketAddress::getPort)
                                                  .collect(toImmutableList());

        final EndpointGroup group = EndpointGroup.of(EndpointSelectionStrategy.roundRobin(),
                                                     expectedPorts.stream()
                                                                  .map(port -> Endpoint.of("127.0.0.1", port))
                                                                  .collect(toImmutableList()));

        final RetryRule retryRule = (ctx, cause) -> {
            // Get the response status.
            final HttpStatus status;
            if (ctx.log().isAvailable(RequestLogProperty.RESPONSE_HEADERS)) {
                status = ctx.log().partial().responseHeaders().status();
            } else {
                status = null;
            }

            // Retry only once on failure.
            if (!HttpStatus.OK.equals(status) && AbstractRetryingClient.getTotalAttempts(ctx) <= 1) {
                return UnmodifiableFuture.completedFuture(RetryDecision.retry(Backoff.withoutDelay()));
            } else {
                return UnmodifiableFuture.completedFuture(RetryDecision.noRetry());
            }
        };
        final WebClient c = WebClient.builder(SessionProtocol.H2C, group)
                                     .decorator(RetryingClient.builder(retryRule)
                                                              .newDecorator())
                                     .build();

        for (int i = 0; i < NUM_PORTS; i++) {
            c.get(mode.path).aggregate().join();
        }

        switch (mode) {
            case SUCCESS:
                assertThat(accessedPorts).isEqualTo(expectedPorts);
                break;
            case FAILURE:
                final List<Integer> expectedPortsWhenRetried =
                        ImmutableList.<Integer>builder()
                                .addAll(expectedPorts)
                                .addAll(expectedPorts)
                                .build();
                assertThat(accessedPorts).isEqualTo(expectedPortsWhenRetried);
                break;
        }
    }
Makes sure that {@link RetryingClient} respects the {@link Endpoint} selection order.
core/src/test/java/com/linecorp/armeria/client/retry/RetryingClientLoadBalancingTest.java