Skip to content

Commit

Permalink
[test] Fix flaky test (#2892)
Browse files Browse the repository at this point in the history
From time to time HttpServerTests#testSniSupportHandshakeTimeout fails on CI with

HttpServerTests > testSniSupportHandshakeTimeout() FAILED
    java.lang.AssertionError:
    Expecting actual not to be null
        at reactor.netty.http.server.HttpServerTests.testSniSupportHandshakeTimeout(HttpServerTests.java:2259)
  • Loading branch information
violetagg authored Sep 2, 2023
1 parent ae45166 commit d9b397c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.publisher.SignalType;
import reactor.core.publisher.Sinks;
import reactor.netty.BaseHttpTest;
import reactor.netty.ByteBufFlux;
import reactor.netty.ChannelBindException;
Expand Down Expand Up @@ -2220,7 +2221,7 @@ void testSniSupportHandshakeTimeout() {
Http11SslContextSpec.forClient()
.configure(builder -> builder.trustManager(InsecureTrustManagerFactory.INSTANCE));

AtomicReference<Throwable> error = new AtomicReference<>();
Sinks.One<Throwable> error = Sinks.one();
disposableServer =
createServer()
.childOption(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(64))
Expand All @@ -2234,7 +2235,7 @@ void testSniSupportHandshakeTimeout() {
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
if (evt instanceof SniCompletionEvent) {
error.set(((SniCompletionEvent) evt).cause());
error.tryEmitValue(((SniCompletionEvent) evt).cause());
}
ctx.fireUserEventTriggered(evt);
}
Expand All @@ -2253,7 +2254,10 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
.expectError()
.verify(Duration.ofSeconds(5));

assertThat(error.get()).isNotNull().isInstanceOf(SslHandshakeTimeoutException.class);
StepVerifier.create(error.asMono())
.expectNextMatches(t -> t instanceof SslHandshakeTimeoutException)
.expectComplete()
.verify(Duration.ofSeconds(10));
}

@Test
Expand Down

0 comments on commit d9b397c

Please sign in to comment.