Skip to content

Commit

Permalink
Enable UDP_SEGMENT when supported during testing (java-native-access#515
Browse files Browse the repository at this point in the history
)

Motivation:

We should enable UDP_SEGMENT on the client side as well when its
supported during testing.

Modifications:

Add utility method that enables UDP_SEGMENT for the client side when
testing

Result:

Better test coverage
  • Loading branch information
normanmaurer authored May 24, 2023
1 parent 02c9dd7 commit c05a671
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void testQLog(Executor executor, Path path, Consumer<Path> consumer) thr
InetSocketAddress address = (InetSocketAddress) server.localAddress();
Channel channel = QuicTestUtils.newClient(executor);
try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientValidationHandler)
.option(QuicChannelOption.QLOG,
new QLogConfiguration(path.toString(), "testTitle", "test"))
Expand Down Expand Up @@ -199,7 +199,7 @@ private static void testKeylog(Executor sslTaskExecutor, Object keylog) throws T
Channel channel = QuicTestUtils.newClient(QuicTestUtils.newQuicClientBuilder(sslTaskExecutor, context));

try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientValidationHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -228,7 +228,7 @@ public void testAddressValidation(Executor executor) throws Throwable {
.localConnectionIdLength(10));
try {
ChannelStateVerifyHandler verifyHandler = new ChannelStateVerifyHandler();
Future<QuicChannel> future = QuicChannel.newBootstrap(channel)
Future<QuicChannel> future = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(verifyHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(socket.getLocalSocketAddress())
Expand Down Expand Up @@ -269,7 +269,7 @@ private static void testConnectWithCustomIdLength(Executor executor, int idLengt
.localConnectionIdLength(idLength));
try {
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -336,7 +336,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
Channel channel = QuicTestUtils.newClient(QuicTestUtils.newQuicClientBuilder(executor));
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.remoteAddress(address)
.connect()
Expand Down Expand Up @@ -396,7 +396,7 @@ public void testConnectTimeout(Executor executor) throws Throwable {
Channel channel = QuicTestUtils.newClient(executor);
try {
ChannelStateVerifyHandler verifyHandler = new ChannelStateVerifyHandler();
Future<QuicChannel> future = QuicChannel.newBootstrap(channel)
Future<QuicChannel> future = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(verifyHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10)
Expand Down Expand Up @@ -425,7 +425,7 @@ public void testConnectAlreadyConnected(Executor executor) throws Throwable {
Channel channel = QuicTestUtils.newClient(executor);
try {
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -466,7 +466,7 @@ public void testConnectWithoutTokenValidation(Executor executor) throws Throwabl
Channel channel = QuicTestUtils.newClient(executor);
try {
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -537,7 +537,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
InetSocketAddress address = (InetSocketAddress) server.localAddress();
Channel channel = QuicTestUtils.newClient(executor);
try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(new ChannelInboundHandlerAdapter())
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -584,7 +584,7 @@ public void testConnectAndStreamPriority(Executor executor) throws Throwable {
Channel channel = QuicTestUtils.newClient(executor);
try {
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -658,7 +658,7 @@ public void checkServerTrusted(X509Certificate[] chain, String authType)
.trustManager(new TrustManagerFactoryWrapper(trustManager))
.applicationProtocols(QuicTestUtils.PROTOS).build()));
try {
Throwable cause = QuicChannel.newBootstrap(channel)
Throwable cause = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(new ChannelInboundHandlerAdapter())
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -714,7 +714,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
.trustManager(InsecureTrustManagerFactory.INSTANCE).applicationProtocols("protocol").build()));
AtomicReference<QuicConnectionCloseEvent> closeEventRef = new AtomicReference<>();
try {
Throwable cause = QuicChannel.newBootstrap(channel)
Throwable cause = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(new ChannelInboundHandlerAdapter() {
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
Expand Down Expand Up @@ -765,7 +765,7 @@ InsecureQuicTokenHandler.INSTANCE, new ChannelInboundHandlerAdapter(),
.applicationProtocols(QuicTestUtils.PROTOS).build()));
try {
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -805,7 +805,7 @@ InsecureQuicTokenHandler.INSTANCE, new ChannelInboundHandlerAdapter(),
.applicationProtocols(QuicTestUtils.PROTOS).build()));
try {
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -841,7 +841,7 @@ InsecureQuicTokenHandler.INSTANCE, new ChannelInboundHandlerAdapter(),
.trustManager(InsecureTrustManagerFactory.INSTANCE)
.applicationProtocols(QuicTestUtils.PROTOS).build()));
try {
Throwable cause = QuicChannel.newBootstrap(channel)
Throwable cause = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(new ChannelInboundHandlerAdapter())
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -904,7 +904,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
.sslEngineProvider(c -> clientSslContext.newEngine(c.alloc(), hostname, 8080)));
try {
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -972,7 +972,7 @@ InsecureQuicTokenHandler.INSTANCE, new ChannelInboundHandlerAdapter(),
}));
try {
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -1066,7 +1066,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
.applicationProtocols(QuicTestUtils.PROTOS).build()));
try {
ChannelActiveVerifyHandler clientQuicChannelHandler = new ChannelActiveVerifyHandler();
Future<QuicChannel> connectFuture = QuicChannel.newBootstrap(channel)
Future<QuicChannel> connectFuture = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientQuicChannelHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -1135,7 +1135,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
try {
CountDownLatch clientSslCompletionEventLatch = new CountDownLatch(2);

QuicChannelBootstrap bootstrap = QuicChannel.newBootstrap(channel)
QuicChannelBootstrap bootstrap = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(new ChannelInboundHandlerAdapter() {
@Override
public boolean isSharable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
};

try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.remoteAddress(address)
.connect()
Expand Down Expand Up @@ -268,7 +268,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
}
};
try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.remoteAddress(address)
.connect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void channelReadComplete(ChannelHandlerContext ctx) {
Channel channel = QuicTestUtils.newClient(ImmediateExecutor.INSTANCE);
QuicChannel quicChannel = null;
try {
quicChannel = QuicChannel.newBootstrap(channel)
quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(new ChannelInboundHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
Expand Down Expand Up @@ -257,7 +257,7 @@ public void channelReadComplete(ChannelHandlerContext ctx) {
}
}
};
quicChannel = QuicChannel.newBootstrap(channel)
quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(ch)
// Use the same allocator for the streams.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public boolean isSharable() {
});
channel = QuicTestUtils.newClient(executor);

QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(server.localAddress())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public boolean isSharable() {
QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler();
ByteBuf data = Unpooled.directBuffer().writeLong(8);
try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(server.localAddress())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static void testCloseFromServerWhileInActive(Executor executor, QuicStre

QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler();

QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new StreamHandler())
.remoteAddress(server.localAddress())
Expand Down Expand Up @@ -132,7 +132,7 @@ private static void testCloseFromClientWhileInActive(Executor executor, QuicStre
channel = QuicTestUtils.newClient(executor);

StreamCreationHandler creationHandler = new StreamCreationHandler(type, halfClose, streamPromise);
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(creationHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(server.localAddress())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void testCreateStream(Executor executor) throws Throwable {
QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler();

try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -88,7 +88,7 @@ public void testCreateStreamViaBootstrap(Executor executor) throws Throwable {
QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler();

try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static void testCloseHalfClosure(Executor executor, QuicStreamType type)
StreamHandler handler = new StreamHandler();
server = QuicTestUtils.newServer(executor, serverHandler, handler);
channel = QuicTestUtils.newClient(executor);
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(server.localAddress())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static void testCloseHalfClosure(Executor executor, QuicStreamType type)
StreamHandler handler = new StreamHandler();
server = QuicTestUtils.newServer(executor, serverHandler, handler);
channel = QuicTestUtils.newClient(executor);
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(server.localAddress())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exc
}
};
try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down Expand Up @@ -170,7 +170,7 @@ public boolean isSharable() {

QuicChannelValidationHandler clientHandler = new QuicChannelValidationHandler();
try {
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
});

channel = QuicTestUtils.newClient(executor);
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter())
.remoteAddress(server.localAddress())
Expand Down Expand Up @@ -116,7 +116,7 @@ public void channelActive(ChannelHandlerContext ctx) {
server = QuicTestUtils.newServer(executor, serverHandler, new ChannelInboundHandlerAdapter());

channel = QuicTestUtils.newClient(executor);
QuicChannel quicChannel = QuicChannel.newBootstrap(channel)
QuicChannel quicChannel = QuicTestUtils.newQuicChannelBootstrap(channel)
.handler(clientHandler)
.streamHandler(new ChannelInboundHandlerAdapter() {
@Override
Expand Down
Loading

0 comments on commit c05a671

Please sign in to comment.