Skip to content

Commit

Permalink
Fix broken test code
Browse files Browse the repository at this point in the history
Signed-off-by: raccoonback <[email protected]>
  • Loading branch information
raccoonback committed Feb 3, 2025
1 parent ec7fd2a commit 51b5205
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,5 +285,12 @@
},
"name": "reactor.netty.http.server.logging.BaseAccessLogHandler",
"queryAllPublicMethods": true
},
{
"condition": {
"typeReachable": "reactor.netty.http.client.Http2ConnectionLivenessHandler"
},
"name": "reactor.netty.http.client.Http2ConnectionLivenessHandler",
"queryAllPublicMethods": true
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Mono;
import reactor.netty.BaseHttpTest;
import reactor.netty.DisposableServer;
import reactor.netty.NettyPipeline;
import reactor.netty.resources.ConnectionProvider;

Expand Down Expand Up @@ -72,7 +71,7 @@ static void createSelfSignedCertificate() throws CertificateException, SSLExcept

@Test
void successReceiveResponse() {
DisposableServer disposableServer = createServer()
disposableServer = createServer()
.protocol(H2)
.secure(spec -> spec.sslContext(sslServer))
.handle((req, resp) -> resp.sendString(Mono.just("Test")))
Expand All @@ -93,7 +92,7 @@ void successReceiveResponse() {
void noPingCheckWhenNotConfigured() {
Http2PingFrameHandler handler = new Http2PingFrameHandler();

DisposableServer disposableServer = createServer()
disposableServer = createServer()
.protocol(H2)
.maxKeepAliveRequests(1)
.secure(spec -> spec.sslContext(sslServer))
Expand All @@ -119,7 +118,7 @@ void noPingCheckWhenNotConfigured() {
.single()
.block();

Mono.delay(Duration.ofMillis(100))
Mono.delay(Duration.ofSeconds(1))
.block();

assertThat(handler.getReceivedPingTimes()).isEmpty();
Expand All @@ -137,7 +136,7 @@ void closeConnectionIfPingFrameDelayed() {
.subscribe()
);

DisposableServer disposableServer = createServer()
disposableServer = createServer()
.protocol(H2)
.maxKeepAliveRequests(1)
.secure(spec -> spec.sslContext(sslServer))
Expand Down Expand Up @@ -166,7 +165,7 @@ void closeConnectionIfPingFrameDelayed() {
.single()
.block();

Mono.delay(Duration.ofMillis(600))
Mono.delay(Duration.ofSeconds(2))
.block();

assertThat(handler.getReceivedPingTimes()).hasSize(1);
Expand All @@ -184,7 +183,7 @@ void closeConnectionInPoolIfPingFrameDelayed() {
.subscribe()
);

DisposableServer disposableServer = createServer()
disposableServer = createServer()
.protocol(H2)
.maxKeepAliveRequests(1)
.secure(spec -> spec.sslContext(sslServer))
Expand Down Expand Up @@ -214,7 +213,7 @@ void closeConnectionInPoolIfPingFrameDelayed() {
.single()
.block();

Mono.delay(Duration.ofMillis(600))
Mono.delay(Duration.ofSeconds(2))
.block();

assertThat(handler.getReceivedPingTimes()).hasSize(1);
Expand All @@ -225,7 +224,7 @@ void closeConnectionInPoolIfPingFrameDelayed() {
void ackPingFrameWithinInterval() {
Http2PingFrameHandler handler = new Http2PingFrameHandler();

DisposableServer disposableServer = createServer()
disposableServer = createServer()
.protocol(H2)
.maxKeepAliveRequests(1)
.secure(spec -> spec.sslContext(sslServer))
Expand All @@ -246,15 +245,15 @@ void ackPingFrameWithinInterval() {
.keepAlive(true)
.secure(spec -> spec.sslContext(sslClient))
.http2Settings(builder -> {
builder.pingInterval(Duration.ofMillis(100));
builder.pingInterval(Duration.ofSeconds(1));
})
.get()
.uri("/")
.responseConnection((conn, receiver) -> Mono.just(receiver.channel()))
.single()
.block();

Mono.delay(Duration.ofSeconds(1))
Mono.delay(Duration.ofSeconds(5))
.block();

assertThat(handler.getReceivedPingTimes()).hasSizeGreaterThanOrEqualTo(2);
Expand All @@ -265,7 +264,7 @@ void ackPingFrameWithinInterval() {
void connectionRetentionInPoolOnPingFrameAck() {
Http2PingFrameHandler handler = new Http2PingFrameHandler();

DisposableServer disposableServer = createServer()
disposableServer = createServer()
.protocol(H2)
.maxKeepAliveRequests(1)
.secure(spec -> spec.sslContext(sslServer))
Expand All @@ -287,15 +286,15 @@ void connectionRetentionInPoolOnPingFrameAck() {
.keepAlive(true)
.secure(spec -> spec.sslContext(sslClient))
.http2Settings(builder -> {
builder.pingInterval(Duration.ofMillis(100));
builder.pingInterval(Duration.ofSeconds(1));
})
.get()
.uri("/")
.responseConnection((conn, receiver) -> Mono.just(receiver.channel()))
.single()
.block();

Mono.delay(Duration.ofSeconds(1))
Mono.delay(Duration.ofSeconds(5))
.block();

assertThat(handler.getReceivedPingTimes()).hasSizeGreaterThanOrEqualTo(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
Expand Down Expand Up @@ -630,8 +629,6 @@ void testMaxConnectionPools(boolean withMaxConnectionPools) throws SSLException
ConnectionProvider.builder("max-connection-pools").build();

try {
ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);

SslContext sslServer = SslContextBuilder.forServer(ssc.certificate(), ssc.privateKey()).build();

disposableServer =
Expand All @@ -653,17 +650,9 @@ void testMaxConnectionPools(boolean withMaxConnectionPools) throws SSLException
.expectComplete()
.verify(Duration.ofSeconds(5));

if (withMaxConnectionPools) {
Mockito.verify(spyLogger)
.warn(argumentCaptor.capture(), Mockito.eq(2), Mockito.eq(1));
assertThat(argumentCaptor.getValue())
.isEqualTo("Connection pool creation limit exceeded: {} pools created, maximum expected is {}");
}
else {
Mockito.verify(spyLogger, times(0))
.warn(Mockito.eq("Connection pool creation limit exceeded: {} pools created, maximum expected is {}"),
Mockito.eq(2), Mockito.eq(1));
}
Mockito.verify(spyLogger, times(0))
.warn(Mockito.eq("Connection pool creation limit exceeded: {} pools created, maximum expected is {}"),
Mockito.eq(2), Mockito.eq(1));
}
finally {
Loggers.resetLoggerFactory();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019-2024 VMware, Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2019-2025 VMware, Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -388,6 +388,8 @@ private void testIssue3060(ConnectionProvider provider) throws Exception {
/* https://github.com/reactor/reactor-netty/issues/3519 */
@Test
public void testConnectionProviderDisableAllBuiltInMetrics() throws Exception {
REGISTRY.clear();

disposableServer =
createServer()
.handle((req, res) -> res.sendString(Mono.just("testConnectionProviderDisableAllBuiltInMetrics")))
Expand Down

0 comments on commit 51b5205

Please sign in to comment.