Skip to content

Commit 8b454bb

Browse files
authored
[test] Extend HttpClient/HttpServer combinations used for HttpMetricsHandlerTests (#2668)
1 parent 7ad753f commit 8b454bb

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

reactor-netty-http/src/test/java/reactor/netty/http/HttpMetricsHandlerTests.java

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ void testExistingEndpoint(HttpProtocol[] serverProtocols, HttpProtocol[] clientP
257257
int[] numWrites = new int[]{14, 25};
258258
int[] bytesWrite = new int[]{160, 243};
259259
int connIndex = 1;
260-
if (clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11) {
260+
if ((serverProtocols.length == 1 && serverProtocols[0] == HttpProtocol.HTTP11) ||
261+
(clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11)) {
261262
numWrites = new int[]{14, 28};
262263
bytesWrite = new int[]{151, 310};
263264
connIndex = 2;
@@ -388,7 +389,8 @@ void testNonExistingEndpoint(HttpProtocol[] serverProtocols, HttpProtocol[] clie
388389
int[] bytesWrite = new int[]{106, 122};
389390
int[] bytesRead = new int[]{37, 48};
390391
int connIndex = 1;
391-
if (clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11) {
392+
if ((serverProtocols.length == 1 && serverProtocols[0] == HttpProtocol.HTTP11) ||
393+
(clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11)) {
392394
numWrites = new int[]{1, 2};
393395
bytesWrite = new int[]{123, 246};
394396
bytesRead = new int[]{64, 128};
@@ -466,7 +468,8 @@ void testUriTagValueFunction(HttpProtocol[] serverProtocols, HttpProtocol[] clie
466468

467469
int numWrites = 14;
468470
int bytesWrite = 160;
469-
if (clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11) {
471+
if ((serverProtocols.length == 1 && serverProtocols[0] == HttpProtocol.HTTP11) ||
472+
(clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11)) {
470473
bytesWrite = 151;
471474
}
472475
else if (clientProtocols.length == 2 &&
@@ -529,7 +532,8 @@ void testUriTagValueFunctionNotSharedForClient(HttpProtocol[] serverProtocols, H
529532

530533
int[] numWrites = new int[]{14, 28};
531534
int[] bytesWrite = new int[]{160, 320};
532-
if (clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11) {
535+
if ((serverProtocols.length == 1 && serverProtocols[0] == HttpProtocol.HTTP11) ||
536+
(clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11)) {
533537
bytesWrite = new int[]{151, 302};
534538
}
535539
else if (clientProtocols.length == 2 &&
@@ -626,7 +630,8 @@ void testContextAwareRecorderOnServer(HttpProtocol[] serverProtocols, HttpProtoc
626630
void testServerConnectionsMicrometer(HttpProtocol[] serverProtocols, HttpProtocol[] clientProtocols,
627631
@Nullable ProtocolSslContextSpec serverCtx, @Nullable ProtocolSslContextSpec clientCtx) throws Exception {
628632
CountDownLatch responseSent = new CountDownLatch(1); // response fully sent by the server
629-
boolean isHttp11 = clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11;
633+
boolean isHttp11 = (serverProtocols.length == 1 && serverProtocols[0] == HttpProtocol.HTTP11) ||
634+
(clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11);
630635
HttpServer server = customizeServerOptions(httpServer, serverCtx, serverProtocols)
631636
.metrics(true, Function.identity())
632637
.doOnConnection(cnx -> {
@@ -682,7 +687,8 @@ void testServerConnectionsMicrometer(HttpProtocol[] serverProtocols, HttpProtoco
682687
@MethodSource("httpCompatibleProtocols")
683688
void testServerConnectionsMicrometerConnectionClose(HttpProtocol[] serverProtocols, HttpProtocol[] clientProtocols,
684689
@Nullable ProtocolSslContextSpec serverCtx, @Nullable ProtocolSslContextSpec clientCtx) throws Exception {
685-
boolean isHttp11 = clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11;
690+
boolean isHttp11 = (serverProtocols.length == 1 && serverProtocols[0] == HttpProtocol.HTTP11) ||
691+
(clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11);
686692

687693
disposableServer = customizeServerOptions(httpServer, serverCtx, serverProtocols)
688694
.metrics(true, Function.identity())
@@ -727,7 +733,8 @@ void testServerConnectionsRecorder(HttpProtocol[] serverProtocols, HttpProtocol[
727733
// Invoke ServerRecorder.INSTANCE.reset() here as disposableServer.dispose (AfterEach) might be invoked after
728734
// ServerRecorder.INSTANCE.reset() (AfterEach) and thus leave ServerRecorder.INSTANCE in a bad state
729735
ServerRecorder.INSTANCE.reset();
730-
boolean isHttp11 = clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11;
736+
boolean isHttp11 = (serverProtocols.length == 1 && serverProtocols[0] == HttpProtocol.HTTP11) ||
737+
(clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11);
731738

732739
disposableServer = customizeServerOptions(httpServer, serverCtx, serverProtocols)
733740
.doOnConnection(cnx -> ServerCloseHandler.INSTANCE.register(cnx.channel()))
@@ -773,7 +780,8 @@ void testServerConnectionsRecorderConnectionClose(HttpProtocol[] serverProtocols
773780
// Invoke ServerRecorder.INSTANCE.reset() here as disposableServer.dispose (AfterEach) might be invoked after
774781
// ServerRecorder.INSTANCE.reset() (AfterEach) and thus leave ServerRecorder.INSTANCE in a bad state
775782
ServerRecorder.INSTANCE.reset();
776-
boolean isHttp11 = clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11;
783+
boolean isHttp11 = (serverProtocols.length == 1 && serverProtocols[0] == HttpProtocol.HTTP11) ||
784+
(clientProtocols.length == 1 && clientProtocols[0] == HttpProtocol.HTTP11);
777785

778786
disposableServer = customizeServerOptions(httpServer, serverCtx, serverProtocols)
779787
.metrics(true, ServerRecorder.supplier(), Function.identity())
@@ -1064,8 +1072,11 @@ static Stream<Arguments> http11CompatibleProtocols() {
10641072
static Stream<Arguments> httpCompatibleProtocols() {
10651073
return Stream.of(
10661074
Arguments.of(new HttpProtocol[]{HttpProtocol.HTTP11}, new HttpProtocol[]{HttpProtocol.HTTP11}, null, null),
1075+
Arguments.of(new HttpProtocol[]{HttpProtocol.HTTP11}, new HttpProtocol[]{HttpProtocol.H2C, HttpProtocol.HTTP11}, null, null),
10671076
Arguments.of(new HttpProtocol[]{HttpProtocol.HTTP11}, new HttpProtocol[]{HttpProtocol.HTTP11},
10681077
Named.of("Http11SslContextSpec", serverCtx11), Named.of("Http11SslContextSpec", clientCtx11)),
1078+
Arguments.of(new HttpProtocol[]{HttpProtocol.HTTP11}, new HttpProtocol[]{HttpProtocol.H2, HttpProtocol.HTTP11},
1079+
Named.of("Http11SslContextSpec", serverCtx11), Named.of("Http11SslContextSpec", clientCtx11)),
10691080
Arguments.of(new HttpProtocol[]{HttpProtocol.H2}, new HttpProtocol[]{HttpProtocol.H2},
10701081
Named.of("Http2SslContextSpec", serverCtx2), Named.of("Http2SslContextSpec", clientCtx2)),
10711082
Arguments.of(new HttpProtocol[]{HttpProtocol.H2}, new HttpProtocol[]{HttpProtocol.H2, HttpProtocol.HTTP11},

0 commit comments

Comments
 (0)