Make EpollSocketChannelConfigTest tollerant of fd reuse race (#11552)

Motivation:
We cannot control when "the system" reuses file descriptors.
This makes any test that assert on the behaviour of closed file descriptors inherently racy.

Modification:
Allow the EpollSocketChannelConfigTest socketoption tests a few tries to get the correct assertion on the behaviour of closed socket file descriptors.

Result:
The EpollSocketChannelConfigTest should now be much less flaky.
This commit is contained in:
Chris Vest 2021-08-06 08:45:24 +02:00 committed by GitHub
parent 6e387e2f5d
commit 45c97fbdfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View File

@ -868,6 +868,12 @@
<version>1.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.artsok</groupId>
<artifactId>rerunner-jupiter</artifactId>
<version>2.1.6</version>
<scope>test</scope>
</dependency>
<!-- Test dependencies for jboss marshalling encoder/decoder -->
<dependency>

View File

@ -401,6 +401,11 @@
<classifier>${tcnative.classifier}</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.artsok</groupId>
<artifactId>rerunner-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -15,6 +15,7 @@
*/
package io.netty.channel.epoll;
import io.github.artsok.RepeatedIfExceptionsTest;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelException;
import io.netty.channel.ChannelInboundHandlerAdapter;
@ -136,7 +137,10 @@ public class EpollSocketChannelConfigTest {
assertTrue(ch.config().isTcpQuickAck());
}
@Test
// For this test to pass, we are relying on the sockets file descriptor not being reused after the socket is closed.
// This is inherently racy, so we allow getSoLinger to throw ChannelException a few of times, but eventually we do
// want to see a ClosedChannelException for the test to pass.
@RepeatedIfExceptionsTest(repeats = 4, exceptions = ChannelException.class)
public void testSetOptionWhenClosed() {
ch.close().syncUninterruptibly();
try {
@ -147,7 +151,10 @@ public class EpollSocketChannelConfigTest {
}
}
@Test
// For this test to pass, we are relying on the sockets file descriptor not being reused after the socket is closed.
// This is inherently racy, so we allow getSoLinger to throw ChannelException a few of times, but eventually we do
// want to see a ClosedChannelException for the test to pass.
@RepeatedIfExceptionsTest(repeats = 4, exceptions = ChannelException.class)
public void testGetOptionWhenClosed() {
ch.close().syncUninterruptibly();
try {