Remove default netty allocator empty assertions (#48356)

This commit removes a problematic assertion that the netty default
allocator is not used. This assertion is problematic because any other
test can cause this task to fail by touching the default allocator. We
assert that we are using heap buffers in the channel.
This commit is contained in:
Tim Brooks 2019-10-22 19:50:31 -06:00
parent e45b0cd7e3
commit c1f6aff5bb
No known key found for this signature in database
GPG Key ID: C2AA3BB91A889E77
3 changed files with 6 additions and 18 deletions

View File

@ -18,7 +18,6 @@
*/
package org.elasticsearch;
import io.netty.buffer.PooledByteBufAllocator;
import org.elasticsearch.common.network.NetworkModule;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.plugins.Plugin;
@ -65,16 +64,8 @@ public abstract class ESNetty4IntegTestCase extends ESIntegTestCase {
return Collections.singletonList(Netty4Plugin.class);
}
@Override
public void tearDown() throws Exception {
super.tearDown();
assertEquals(0, PooledByteBufAllocator.DEFAULT.metric().usedHeapMemory());
assertEquals(0, PooledByteBufAllocator.DEFAULT.metric().usedDirectMemory());
}
@Override
protected Collection<Class<? extends Plugin>> transportClientPlugins() {
return Collections.singletonList(Netty4Plugin.class);
}
}

View File

@ -25,6 +25,7 @@ import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
@ -61,6 +62,7 @@ import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.threadpool.TestThreadPool;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.transport.NettyAllocator;
import org.junit.After;
import org.junit.Before;
@ -348,7 +350,10 @@ public class Netty4HttpServerTransportTests extends ESTestCase {
CountDownLatch channelClosedLatch = new CountDownLatch(1);
Bootstrap clientBootstrap = new Bootstrap().channel(NioSocketChannel.class).handler(new ChannelInitializer<SocketChannel>() {
Bootstrap clientBootstrap = new Bootstrap()
.option(ChannelOption.ALLOCATOR, NettyAllocator.getAllocator())
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(SocketChannel ch) {

View File

@ -19,7 +19,6 @@
package org.elasticsearch.transport.netty4;
import io.netty.buffer.PooledByteBufAllocator;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.cluster.node.DiscoveryNode;
@ -46,13 +45,6 @@ import static org.hamcrest.Matchers.containsString;
public class SimpleNetty4TransportTests extends AbstractSimpleTransportTestCase {
@Override
public void tearDown() throws Exception {
super.tearDown();
assertEquals(0, PooledByteBufAllocator.DEFAULT.metric().usedHeapMemory());
assertEquals(0, PooledByteBufAllocator.DEFAULT.metric().usedDirectMemory());
}
@Override
protected Transport build(Settings settings, final Version version, ClusterSettings clusterSettings, boolean doHandshake) {
NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());