Sitelet https://github.com/netty/netty/commit/1baf9ef2f1f9da2b6965fb76e0562f344f895d6e
Skip to content

Commit 1baf9ef

Browse files
authored
Enable SocketHalfClosedTest for epoll (#13025)
Motivation: These tests were not being run for epoll because the classes did not have the Test suffix. We also aren't regularly running these tests for kqueue because we don't have a MacOS CI build. It turns out that all transports now behave consistently with regards to read-completes after input shutdown, so the tests don't need to change their assertions for epoll/kqueue vs. NIO. Modification: Enable the SocketHalfClosedTest for epoll, both edge and level triggered. Remove test parameter adjustments for epoll and kqueue. Result: SocketHalfClosedTest tests now run, and pass, for epoll.
1 parent 91527ff commit 1baf9ef

4 files changed

Lines changed: 8 additions & 25 deletions

File tree

‎testsuite/src/main/java/io/netty/testsuite/transport/socket/SocketHalfClosedTest.java‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ private static void testAutoCloseFalseDoesShutdownOutput(boolean allowHalfClosed
363363
Bootstrap cb) throws InterruptedException {
364364
final int expectedBytes = 100;
365365
final CountDownLatch serverReadExpectedLatch = new CountDownLatch(1);
366-
final CountDownLatch doneLatch = new CountDownLatch(1);
366+
final CountDownLatch doneLatch = new CountDownLatch(2);
367367
final AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
368368
Channel serverChannel = null;
369369
Channel clientChannel = null;
@@ -375,9 +375,9 @@ private static void testAutoCloseFalseDoesShutdownOutput(boolean allowHalfClosed
375375
.childOption(ChannelOption.AUTO_CLOSE, false)
376376
.childOption(ChannelOption.SO_LINGER, 0);
377377

378-
final SimpleChannelInboundHandler<ByteBuf> leaderHandler = new AutoCloseFalseLeader(expectedBytes,
378+
final AutoCloseFalseLeader leaderHandler = new AutoCloseFalseLeader(expectedBytes,
379379
serverReadExpectedLatch, doneLatch, causeRef);
380-
final SimpleChannelInboundHandler<ByteBuf> followerHandler = new AutoCloseFalseFollower(expectedBytes,
380+
final AutoCloseFalseFollower followerHandler = new AutoCloseFalseFollower(expectedBytes,
381381
serverReadExpectedLatch, doneLatch, causeRef);
382382
sb.childHandler(new ChannelInitializer<Channel>() {
383383
@Override
@@ -398,6 +398,7 @@ protected void initChannel(Channel ch) throws Exception {
398398

399399
doneLatch.await();
400400
assertNull(causeRef.get());
401+
assertTrue(leaderHandler.seenOutputShutdown);
401402
} finally {
402403
if (clientChannel != null) {
403404
clientChannel.close().sync();
@@ -479,7 +480,7 @@ private static final class AutoCloseFalseLeader extends SimpleChannelInboundHand
479480
private final CountDownLatch doneLatch;
480481
private final AtomicReference<Throwable> causeRef;
481482
private int bytesRead;
482-
private boolean seenOutputShutdown;
483+
boolean seenOutputShutdown;
483484

484485
AutoCloseFalseLeader(int expectedBytes, CountDownLatch followerCloseLatch, CountDownLatch doneLatch,
485486
AtomicReference<Throwable> causeRef) {
@@ -515,10 +516,6 @@ public void operationComplete(ChannelFuture future) throws Exception {
515516
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
516517
bytesRead += msg.readableBytes();
517518
if (bytesRead >= expectedBytes) {
518-
if (!seenOutputShutdown) {
519-
causeRef.set(new IllegalStateException(
520-
ChannelOutputShutdownEvent.class.getSimpleName() + " event was not seen"));
521-
}
522519
doneLatch.countDown();
523520
}
524521
}
@@ -527,6 +524,7 @@ protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Excep
527524
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
528525
if (evt instanceof ChannelOutputShutdownEvent) {
529526
seenOutputShutdown = true;
527+
doneLatch.countDown();
530528
}
531529
}
532530

transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollETSocketHalfClosed.java renamed to transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollETSocketHalfClosedTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323

2424
import java.util.List;
2525

26-
public class EpollETSocketHalfClosed extends SocketHalfClosedTest {
27-
@Override
28-
public int maxReadCompleteWithNoDataAfterInputShutdown() {
29-
return 1;
30-
}
31-
26+
public class EpollETSocketHalfClosedTest extends SocketHalfClosedTest {
3227
@Override
3328
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
3429
return EpollSocketTestPermutation.INSTANCE.socketWithoutFastOpen();

transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollLTSocketHalfClosed.java renamed to transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollLTSocketHalfClosedTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323

2424
import java.util.List;
2525

26-
public class EpollLTSocketHalfClosed extends SocketHalfClosedTest {
27-
@Override
28-
public int maxReadCompleteWithNoDataAfterInputShutdown() {
29-
return 1;
30-
}
31-
26+
public class EpollLTSocketHalfClosedTest extends SocketHalfClosedTest {
3227
@Override
3328
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
3429
return EpollSocketTestPermutation.INSTANCE.socketWithoutFastOpen();

‎transport-native-kqueue/src/test/java/io/netty/channel/kqueue/KQueueETSocketHalfClosedTest.java‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323
import java.util.List;
2424

2525
public class KQueueETSocketHalfClosedTest extends SocketHalfClosedTest {
26-
@Override
27-
public int maxReadCompleteWithNoDataAfterInputShutdown() {
28-
return 1;
29-
}
30-
3126
@Override
3227
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
3328
return KQueueSocketTestPermutation.INSTANCE.socket();

0 commit comments

Comments
 (0)