HTTP/2 Unit Tests EventLoopGroup cleanup
Motivation: The HTTP/2 unit tests are suffering from OOME on the master branch. These unit tests allocating a large number of threads (~706 peak live) which may be related to this memory pressure. Modifications: Each EventLoopGroup shutdown operation will have a `sync()` call. Result: Lower peek live thread count and less associated memory pressure.
This commit is contained in:
parent
c6b2c5a320
commit
e3925be907
@ -43,10 +43,12 @@ import io.netty.handler.codec.compression.ZlibWrapper;
|
|||||||
import io.netty.handler.codec.http.HttpHeaders;
|
import io.netty.handler.codec.http.HttpHeaders;
|
||||||
import io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable;
|
import io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable;
|
||||||
import io.netty.util.NetUtil;
|
import io.netty.util.NetUtil;
|
||||||
|
import io.netty.util.concurrent.Future;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -134,9 +136,12 @@ public class DataCompressionHttp2Test {
|
|||||||
dataCapture = null;
|
dataCapture = null;
|
||||||
}
|
}
|
||||||
serverChannel.close().sync();
|
serverChannel.close().sync();
|
||||||
sb.group().shutdownGracefully();
|
Future<?> serverGroup = sb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
sb.childGroup().shutdownGracefully();
|
Future<?> serverChildGroup = sb.childGroup().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
cb.group().shutdownGracefully();
|
Future<?> clientGroup = cb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
|
serverGroup.sync();
|
||||||
|
serverChildGroup.sync();
|
||||||
|
clientGroup.sync();
|
||||||
serverAdapter = null;
|
serverAdapter = null;
|
||||||
clientAdapter = null;
|
clientAdapter = null;
|
||||||
serverConnection = null;
|
serverConnection = null;
|
||||||
|
@ -47,10 +47,12 @@ import io.netty.handler.codec.http.FullHttpRequest;
|
|||||||
import io.netty.handler.codec.http.HttpHeaders;
|
import io.netty.handler.codec.http.HttpHeaders;
|
||||||
import io.netty.handler.codec.http.HttpRequest;
|
import io.netty.handler.codec.http.HttpRequest;
|
||||||
import io.netty.util.NetUtil;
|
import io.netty.util.NetUtil;
|
||||||
|
import io.netty.util.concurrent.Future;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -129,9 +131,12 @@ public class DelegatingHttp2HttpConnectionHandlerTest {
|
|||||||
capturedData = null;
|
capturedData = null;
|
||||||
}
|
}
|
||||||
serverChannel.close().sync();
|
serverChannel.close().sync();
|
||||||
sb.group().shutdownGracefully();
|
Future<?> serverGroup = sb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
sb.childGroup().shutdownGracefully();
|
Future<?> serverChildGroup = sb.childGroup().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
cb.group().shutdownGracefully();
|
Future<?> clientGroup = cb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
|
serverGroup.sync();
|
||||||
|
serverChildGroup.sync();
|
||||||
|
clientGroup.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -41,6 +41,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
|
|||||||
import io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable;
|
import io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable;
|
||||||
import io.netty.util.CharsetUtil;
|
import io.netty.util.CharsetUtil;
|
||||||
import io.netty.util.NetUtil;
|
import io.netty.util.NetUtil;
|
||||||
|
import io.netty.util.concurrent.Future;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -122,9 +123,12 @@ public class Http2ConnectionRoundtripTest {
|
|||||||
@After
|
@After
|
||||||
public void teardown() throws Exception {
|
public void teardown() throws Exception {
|
||||||
serverChannel.close().sync();
|
serverChannel.close().sync();
|
||||||
sb.group().shutdownGracefully();
|
Future<?> serverGroup = sb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
sb.childGroup().shutdownGracefully();
|
Future<?> serverChildGroup = sb.childGroup().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
cb.group().shutdownGracefully();
|
Future<?> clientGroup = cb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
|
serverGroup.sync();
|
||||||
|
serverChildGroup.sync();
|
||||||
|
clientGroup.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -40,10 +40,12 @@ import io.netty.channel.socket.nio.NioServerSocketChannel;
|
|||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
import io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable;
|
import io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable;
|
||||||
import io.netty.util.NetUtil;
|
import io.netty.util.NetUtil;
|
||||||
|
import io.netty.util.concurrent.Future;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -118,9 +120,12 @@ public class Http2FrameRoundtripTest {
|
|||||||
capturedData.get(i).release();
|
capturedData.get(i).release();
|
||||||
}
|
}
|
||||||
serverChannel.close().sync();
|
serverChannel.close().sync();
|
||||||
sb.group().shutdownGracefully();
|
Future<?> serverGroup = sb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
sb.childGroup().shutdownGracefully();
|
Future<?> serverChildGroup = sb.childGroup().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
cb.group().shutdownGracefully();
|
Future<?> clientGroup = cb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
|
serverGroup.sync();
|
||||||
|
serverChildGroup.sync();
|
||||||
|
clientGroup.sync();
|
||||||
serverAdapter = null;
|
serverAdapter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,10 +46,12 @@ import io.netty.handler.codec.http.HttpResponseStatus;
|
|||||||
import io.netty.handler.codec.http.HttpVersion;
|
import io.netty.handler.codec.http.HttpVersion;
|
||||||
import io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable;
|
import io.netty.handler.codec.http2.Http2TestUtil.Http2Runnable;
|
||||||
import io.netty.util.NetUtil;
|
import io.netty.util.NetUtil;
|
||||||
|
import io.netty.util.concurrent.Future;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -145,9 +147,12 @@ public class InboundHttp2ToHttpAdapterTest {
|
|||||||
cleanupCapturedRequests();
|
cleanupCapturedRequests();
|
||||||
cleanupCapturedResponses();
|
cleanupCapturedResponses();
|
||||||
serverChannel.close().sync();
|
serverChannel.close().sync();
|
||||||
sb.group().shutdownGracefully();
|
Future<?> serverGroup = sb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
sb.childGroup().shutdownGracefully();
|
Future<?> serverChildGroup = sb.childGroup().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
cb.group().shutdownGracefully();
|
Future<?> clientGroup = cb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
|
serverGroup.sync();
|
||||||
|
serverChildGroup.sync();
|
||||||
|
clientGroup.sync();
|
||||||
clientDelegator = null;
|
clientDelegator = null;
|
||||||
serverDelegator = null;
|
serverDelegator = null;
|
||||||
clientChannel = null;
|
clientChannel = null;
|
||||||
|
@ -19,6 +19,7 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assume.assumeNoException;
|
import static org.junit.Assume.assumeNoException;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
import io.netty.bootstrap.Bootstrap;
|
import io.netty.bootstrap.Bootstrap;
|
||||||
import io.netty.bootstrap.ServerBootstrap;
|
import io.netty.bootstrap.ServerBootstrap;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
@ -35,6 +36,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
|
|||||||
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||||
import io.netty.handler.ssl.util.SelfSignedCertificate;
|
import io.netty.handler.ssl.util.SelfSignedCertificate;
|
||||||
import io.netty.util.NetUtil;
|
import io.netty.util.NetUtil;
|
||||||
|
import io.netty.util.concurrent.Future;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
@ -51,7 +53,6 @@ import org.junit.Test;
|
|||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
|
|
||||||
public class JettySslEngineTest {
|
public class JettySslEngineTest {
|
||||||
private static final String APPLICATION_LEVEL_PROTOCOL = "my-protocol";
|
private static final String APPLICATION_LEVEL_PROTOCOL = "my-protocol";
|
||||||
@ -102,9 +103,12 @@ public class JettySslEngineTest {
|
|||||||
public void tearDown() throws InterruptedException {
|
public void tearDown() throws InterruptedException {
|
||||||
if (serverChannel != null) {
|
if (serverChannel != null) {
|
||||||
serverChannel.close().sync();
|
serverChannel.close().sync();
|
||||||
sb.group().shutdownGracefully();
|
Future<?> serverGroup = sb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
sb.childGroup().shutdownGracefully();
|
Future<?> serverChildGroup = sb.childGroup().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
cb.group().shutdownGracefully();
|
Future<?> clientGroup = cb.group().shutdownGracefully(0, 0, TimeUnit.MILLISECONDS);
|
||||||
|
serverGroup.sync();
|
||||||
|
serverChildGroup.sync();
|
||||||
|
clientGroup.sync();
|
||||||
}
|
}
|
||||||
clientChannel = null;
|
clientChannel = null;
|
||||||
serverChannel = null;
|
serverChannel = null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user