HTTP/2 Allow more time for EventLoopGroup to shutdown in test that use LocalChannel
Motivation: The CI servers have reported leaks while building the HTTP/2 unit tests. The unit tests attempt to wait for the channels to be closed before exiting the test, but we should wait in case there are any tasks pending on the EventLoopGroup's task queues. Modifications: - Change the Future.sync() operations to Future.syncUninterruptibly() - HTTP/2 unit tests which use local channel should wait for 5 seconds before shutting down the EventLoopGroups Result: More likely that any cleanup related tasks will execute before the unit tests are shutdown.
This commit is contained in:
parent
c37267d682
commit
1bc5bc69e3
@ -36,9 +36,9 @@ import org.junit.BeforeClass;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import static io.netty.handler.codec.http2.Http2CodecUtil.isStreamIdValid;
|
import static io.netty.handler.codec.http2.Http2CodecUtil.isStreamIdValid;
|
||||||
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static junit.framework.TestCase.assertFalse;
|
import static junit.framework.TestCase.assertFalse;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
@ -83,27 +83,27 @@ public class Http2CodecTest {
|
|||||||
.group(group)
|
.group(group)
|
||||||
.handler(new Http2Codec(false, new TestChannelInitializer()));
|
.handler(new Http2Codec(false, new TestChannelInitializer()));
|
||||||
clientChannel = cb.connect(serverAddress).sync().channel();
|
clientChannel = cb.connect(serverAddress).sync().channel();
|
||||||
assertTrue(serverChannelLatch.await(5, TimeUnit.SECONDS));
|
assertTrue(serverChannelLatch.await(5, SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void shutdown() {
|
public static void shutdown() {
|
||||||
group.shutdownGracefully();
|
group.shutdownGracefully(0, 5, SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@After
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
if (clientChannel != null) {
|
if (clientChannel != null) {
|
||||||
clientChannel.close().sync();
|
clientChannel.close().syncUninterruptibly();
|
||||||
clientChannel = null;
|
clientChannel = null;
|
||||||
}
|
}
|
||||||
if (serverChannel != null) {
|
if (serverChannel != null) {
|
||||||
serverChannel.close().sync();
|
serverChannel.close().syncUninterruptibly();
|
||||||
serverChannel = null;
|
serverChannel = null;
|
||||||
}
|
}
|
||||||
final Channel serverConnectedChannel = this.serverConnectedChannel;
|
final Channel serverConnectedChannel = this.serverConnectedChannel;
|
||||||
if (serverConnectedChannel != null) {
|
if (serverConnectedChannel != null) {
|
||||||
serverConnectedChannel.close().sync();
|
serverConnectedChannel.close().syncUninterruptibly();
|
||||||
this.serverConnectedChannel = null;
|
this.serverConnectedChannel = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,24 +111,24 @@ public class Http2ConnectionRoundtripTest {
|
|||||||
@After
|
@After
|
||||||
public void teardown() throws Exception {
|
public void teardown() throws Exception {
|
||||||
if (clientChannel != null) {
|
if (clientChannel != null) {
|
||||||
clientChannel.close().sync();
|
clientChannel.close().syncUninterruptibly();
|
||||||
clientChannel = null;
|
clientChannel = null;
|
||||||
}
|
}
|
||||||
if (serverChannel != null) {
|
if (serverChannel != null) {
|
||||||
serverChannel.close().sync();
|
serverChannel.close().syncUninterruptibly();
|
||||||
serverChannel = null;
|
serverChannel = null;
|
||||||
}
|
}
|
||||||
final Channel serverConnectedChannel = this.serverConnectedChannel;
|
final Channel serverConnectedChannel = this.serverConnectedChannel;
|
||||||
if (serverConnectedChannel != null) {
|
if (serverConnectedChannel != null) {
|
||||||
serverConnectedChannel.close().sync();
|
serverConnectedChannel.close().syncUninterruptibly();
|
||||||
this.serverConnectedChannel = null;
|
this.serverConnectedChannel = null;
|
||||||
}
|
}
|
||||||
Future<?> serverGroup = sb.config().group().shutdownGracefully(0, 0, MILLISECONDS);
|
Future<?> serverGroup = sb.config().group().shutdownGracefully(0, 5, SECONDS);
|
||||||
Future<?> serverChildGroup = sb.config().childGroup().shutdownGracefully(0, 0, MILLISECONDS);
|
Future<?> serverChildGroup = sb.config().childGroup().shutdownGracefully(0, 5, SECONDS);
|
||||||
Future<?> clientGroup = cb.config().group().shutdownGracefully(0, 0, MILLISECONDS);
|
Future<?> clientGroup = cb.config().group().shutdownGracefully(0, 5, SECONDS);
|
||||||
serverGroup.sync();
|
serverGroup.syncUninterruptibly();
|
||||||
serverChildGroup.sync();
|
serverChildGroup.syncUninterruptibly();
|
||||||
clientGroup.sync();
|
clientGroup.syncUninterruptibly();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -105,24 +105,24 @@ public class HttpToHttp2ConnectionHandlerTest {
|
|||||||
@After
|
@After
|
||||||
public void teardown() throws Exception {
|
public void teardown() throws Exception {
|
||||||
if (clientChannel != null) {
|
if (clientChannel != null) {
|
||||||
clientChannel.close().sync();
|
clientChannel.close().syncUninterruptibly();
|
||||||
clientChannel = null;
|
clientChannel = null;
|
||||||
}
|
}
|
||||||
if (serverChannel != null) {
|
if (serverChannel != null) {
|
||||||
serverChannel.close().sync();
|
serverChannel.close().syncUninterruptibly();
|
||||||
serverChannel = null;
|
serverChannel = null;
|
||||||
}
|
}
|
||||||
final Channel serverConnectedChannel = this.serverConnectedChannel;
|
final Channel serverConnectedChannel = this.serverConnectedChannel;
|
||||||
if (serverConnectedChannel != null) {
|
if (serverConnectedChannel != null) {
|
||||||
serverConnectedChannel.close().sync();
|
serverConnectedChannel.close().syncUninterruptibly();
|
||||||
this.serverConnectedChannel = null;
|
this.serverConnectedChannel = null;
|
||||||
}
|
}
|
||||||
Future<?> serverGroup = sb.config().group().shutdownGracefully(0, 0, MILLISECONDS);
|
Future<?> serverGroup = sb.config().group().shutdownGracefully(0, 5, SECONDS);
|
||||||
Future<?> serverChildGroup = sb.config().childGroup().shutdownGracefully(0, 0, MILLISECONDS);
|
Future<?> serverChildGroup = sb.config().childGroup().shutdownGracefully(0, 5, SECONDS);
|
||||||
Future<?> clientGroup = cb.config().group().shutdownGracefully(0, 0, MILLISECONDS);
|
Future<?> clientGroup = cb.config().group().shutdownGracefully(0, 5, SECONDS);
|
||||||
serverGroup.sync();
|
serverGroup.syncUninterruptibly();
|
||||||
serverChildGroup.sync();
|
serverChildGroup.syncUninterruptibly();
|
||||||
clientGroup.sync();
|
clientGroup.syncUninterruptibly();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -112,24 +112,24 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
cleanupCapturedRequests();
|
cleanupCapturedRequests();
|
||||||
cleanupCapturedResponses();
|
cleanupCapturedResponses();
|
||||||
if (clientChannel != null) {
|
if (clientChannel != null) {
|
||||||
clientChannel.close().sync();
|
clientChannel.close().syncUninterruptibly();
|
||||||
clientChannel = null;
|
clientChannel = null;
|
||||||
}
|
}
|
||||||
if (serverChannel != null) {
|
if (serverChannel != null) {
|
||||||
serverChannel.close().sync();
|
serverChannel.close().syncUninterruptibly();
|
||||||
serverChannel = null;
|
serverChannel = null;
|
||||||
}
|
}
|
||||||
final Channel serverConnectedChannel = this.serverConnectedChannel;
|
final Channel serverConnectedChannel = this.serverConnectedChannel;
|
||||||
if (serverConnectedChannel != null) {
|
if (serverConnectedChannel != null) {
|
||||||
serverConnectedChannel.close().sync();
|
serverConnectedChannel.close().syncUninterruptibly();
|
||||||
this.serverConnectedChannel = null;
|
this.serverConnectedChannel = null;
|
||||||
}
|
}
|
||||||
Future<?> serverGroup = sb.config().group().shutdownGracefully(0, 0, MILLISECONDS);
|
Future<?> serverGroup = sb.config().group().shutdownGracefully(0, 5, SECONDS);
|
||||||
Future<?> serverChildGroup = sb.config().childGroup().shutdownGracefully(0, 0, MILLISECONDS);
|
Future<?> serverChildGroup = sb.config().childGroup().shutdownGracefully(0, 5, SECONDS);
|
||||||
Future<?> clientGroup = cb.config().group().shutdownGracefully(0, 0, MILLISECONDS);
|
Future<?> clientGroup = cb.config().group().shutdownGracefully(0, 5, SECONDS);
|
||||||
serverGroup.sync();
|
serverGroup.syncUninterruptibly();
|
||||||
serverChildGroup.sync();
|
serverChildGroup.syncUninterruptibly();
|
||||||
clientGroup.sync();
|
clientGroup.syncUninterruptibly();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user