Skip to content

Commit

Permalink
Enable SocketHalfClosedTest for epoll (#13025)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chrisvest committed Nov 29, 2022
1 parent 91527ff commit 1baf9ef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
Expand Up @@ -363,7 +363,7 @@ private static void testAutoCloseFalseDoesShutdownOutput(boolean allowHalfClosed
Bootstrap cb) throws InterruptedException {
final int expectedBytes = 100;
final CountDownLatch serverReadExpectedLatch = new CountDownLatch(1);
final CountDownLatch doneLatch = new CountDownLatch(1);
final CountDownLatch doneLatch = new CountDownLatch(2);
final AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
Channel serverChannel = null;
Channel clientChannel = null;
Expand All @@ -375,9 +375,9 @@ private static void testAutoCloseFalseDoesShutdownOutput(boolean allowHalfClosed
.childOption(ChannelOption.AUTO_CLOSE, false)
.childOption(ChannelOption.SO_LINGER, 0);

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

doneLatch.await();
assertNull(causeRef.get());
assertTrue(leaderHandler.seenOutputShutdown);
} finally {
if (clientChannel != null) {
clientChannel.close().sync();
Expand Down Expand Up @@ -479,7 +480,7 @@ private static final class AutoCloseFalseLeader extends SimpleChannelInboundHand
private final CountDownLatch doneLatch;
private final AtomicReference<Throwable> causeRef;
private int bytesRead;
private boolean seenOutputShutdown;
boolean seenOutputShutdown;

AutoCloseFalseLeader(int expectedBytes, CountDownLatch followerCloseLatch, CountDownLatch doneLatch,
AtomicReference<Throwable> causeRef) {
Expand Down Expand Up @@ -515,10 +516,6 @@ public void operationComplete(ChannelFuture future) throws Exception {
protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Exception {
bytesRead += msg.readableBytes();
if (bytesRead >= expectedBytes) {
if (!seenOutputShutdown) {
causeRef.set(new IllegalStateException(
ChannelOutputShutdownEvent.class.getSimpleName() + " event was not seen"));
}
doneLatch.countDown();
}
}
Expand All @@ -527,6 +524,7 @@ protected void channelRead0(ChannelHandlerContext ctx, ByteBuf msg) throws Excep
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) {
if (evt instanceof ChannelOutputShutdownEvent) {
seenOutputShutdown = true;
doneLatch.countDown();
}
}

Expand Down
Expand Up @@ -23,12 +23,7 @@

import java.util.List;

public class EpollETSocketHalfClosed extends SocketHalfClosedTest {
@Override
public int maxReadCompleteWithNoDataAfterInputShutdown() {
return 1;
}

public class EpollETSocketHalfClosedTest extends SocketHalfClosedTest {
@Override
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
return EpollSocketTestPermutation.INSTANCE.socketWithoutFastOpen();
Expand Down
Expand Up @@ -23,12 +23,7 @@

import java.util.List;

public class EpollLTSocketHalfClosed extends SocketHalfClosedTest {
@Override
public int maxReadCompleteWithNoDataAfterInputShutdown() {
return 1;
}

public class EpollLTSocketHalfClosedTest extends SocketHalfClosedTest {
@Override
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
return EpollSocketTestPermutation.INSTANCE.socketWithoutFastOpen();
Expand Down
Expand Up @@ -23,11 +23,6 @@
import java.util.List;

public class KQueueETSocketHalfClosedTest extends SocketHalfClosedTest {
@Override
public int maxReadCompleteWithNoDataAfterInputShutdown() {
return 1;
}

@Override
protected List<TestsuitePermutation.BootstrapComboFactory<ServerBootstrap, Bootstrap>> newFactories() {
return KQueueSocketTestPermutation.INSTANCE.socket();
Expand Down

0 comments on commit 1baf9ef

Please sign in to comment.