Skip to content

Commit 92be9aa

Browse files
committedFeb 11, 2025
Fix broken test
Signed-off-by: raccoonback <kosb15@naver.com>
1 parent ccb3a6b commit 92be9aa

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed
 

‎reactor-netty-http/src/test/java/reactor/netty/http/client/Http2ConnectionLivenessHandlerTest.java

+19-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import reactor.netty.BaseHttpTest;
3434
import reactor.netty.NettyPipeline;
3535
import reactor.netty.resources.ConnectionProvider;
36+
import reactor.util.Logger;
37+
import reactor.util.Loggers;
3638

3739
import javax.net.ssl.SSLException;
3840
import java.security.cert.CertificateException;
@@ -55,6 +57,8 @@
5557
*/
5658
class Http2ConnectionLivenessHandlerTest extends BaseHttpTest {
5759

60+
private static final Logger log = Loggers.getLogger(Http2ConnectionLivenessHandlerTest.class);
61+
5862
static SslContext sslServer;
5963
static SslContext sslClient;
6064

@@ -199,6 +203,7 @@ void closeConnectionInPoolIfPingFrameDelayed() {
199203
.bindNow();
200204

201205
ConnectionProvider pool = ConnectionProvider.create("closeConnectionInPoolIfPingFrameDelayed", 1);
206+
202207
Channel channel = createClient(pool, disposableServer::address)
203208
.protocol(H2)
204209
.keepAlive(true)
@@ -217,6 +222,8 @@ void closeConnectionInPoolIfPingFrameDelayed() {
217222

218223
assertThat(handler.getReceivedPingTimes()).hasSize(1);
219224
assertThat(channel.parent().isOpen()).isFalse();
225+
226+
pool.dispose();
220227
}
221228

222229
@Test
@@ -255,8 +262,8 @@ void ackPingFrameWithinInterval() {
255262
Mono.delay(Duration.ofSeconds(10))
256263
.block();
257264

258-
assertThat(handler.getReceivedPingTimes()).hasSizeGreaterThanOrEqualTo(2);
259265
assertThat(channel.parent().isOpen()).isTrue();
266+
assertThat(handler.getReceivedPingTimes()).hasSizeGreaterThanOrEqualTo(2);
260267
}
261268

262269
@Test
@@ -279,7 +286,11 @@ void connectionRetentionInPoolOnPingFrameAck() {
279286
.handle((req, resp) -> resp.sendString(Mono.just("Test")))
280287
.bindNow();
281288

282-
ConnectionProvider pool = ConnectionProvider.create("connectionRetentionInPoolOnPingFrameAck", 1);
289+
ConnectionProvider pool = ConnectionProvider.builder("connectionRetentionInPoolOnPingFrameAck")
290+
.maxConnections(10)
291+
.maxIdleTime(Duration.ofSeconds(10))
292+
.maxLifeTime(Duration.ofSeconds(10))
293+
.build();
283294
Channel channel = createClient(pool, disposableServer::address)
284295
.protocol(H2)
285296
.keepAlive(true)
@@ -296,8 +307,10 @@ void connectionRetentionInPoolOnPingFrameAck() {
296307
Mono.delay(Duration.ofSeconds(10))
297308
.block();
298309

299-
assertThat(handler.getReceivedPingTimes()).hasSizeGreaterThanOrEqualTo(2);
300310
assertThat(channel.parent().isOpen()).isTrue();
311+
assertThat(handler.getReceivedPingTimes()).hasSizeGreaterThanOrEqualTo(2);
312+
313+
pool.dispose();
301314
}
302315

303316
private static final class Http2PingFrameHandler extends SimpleChannelInboundHandler<Http2PingFrame> {
@@ -309,7 +322,9 @@ private static final class Http2PingFrameHandler extends SimpleChannelInboundHan
309322
private Http2PingFrameHandler() {
310323
this.consumer = (ctx, frame) ->
311324
ctx.writeAndFlush(new DefaultHttp2PingFrame(frame.content(), true))
312-
.addListener(ChannelFutureListener.CLOSE_ON_FAILURE);
325+
.addListener((listener) -> {
326+
log.info("Wrote ping ack. data: {}, result: {}", frame.content(), listener.isSuccess());
327+
});
313328
}
314329

315330
private Http2PingFrameHandler(BiConsumer<ChannelHandlerContext, Http2PingFrame> consumer) {

0 commit comments

Comments
 (0)