From 2de65e25e90dec5c0a28b2d57e6c6d15d5a49087 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Mon, 17 Mar 2014 09:30:58 +0900 Subject: [PATCH] Set timeout for SocketSslEchoTest Motivation: We are seeing EpollSocketSslEchoTest does not finish itself while its I/O thread is busy. Jenkins should have terminated them when the global build timeout reaches, but Jenkins seems to fail to do so. What's more interesting is that Jenkins will start another job before the EpollSocketSslEchoTest is terminated, and Linux starts to oom-kill them, impacting the uptime of the CI service. Modifications: - Set timeout for all test cases in SocketSslEchoTest so that all SSL tests terminate themselves when they take too long. - Fix a bug where the epoll testsuite uses non-daemon threads which can potentially prevent JVM from quitting. - (Cleanup) Separate boss group and worker group just like we do for NIO/OIO transport testsuite. Result: Potentially more stable CI machine. --- .../transport/socket/SocketSslEchoTest.java | 4 ++-- .../io/netty/channel/epoll/EpollTestUtils.java | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java index 1c3ebf5e7e..5ac6b3fbf9 100644 --- a/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java +++ b/testsuite/src/test/java/io/netty/testsuite/transport/socket/SocketSslEchoTest.java @@ -85,7 +85,7 @@ public class SocketSslEchoTest extends AbstractSocketTest { this.useCompositeByteBuf = useCompositeByteBuf; } - @Test + @Test(timeout = 30000) public void testSslEcho() throws Throwable { run(); } @@ -94,7 +94,7 @@ public class SocketSslEchoTest extends AbstractSocketTest { testSslEcho(sb, cb, true); } - @Test + @Test(timeout = 30000) public void testSslEchoNotAutoRead() throws Throwable { run(); } diff --git a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollTestUtils.java b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollTestUtils.java index e2ba895693..6d09d425df 100644 --- a/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollTestUtils.java +++ b/transport-native-epoll/src/test/java/io/netty/channel/epoll/EpollTestUtils.java @@ -18,24 +18,35 @@ package io.netty.channel.epoll; import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; import io.netty.testsuite.transport.TestsuitePermutation; +import io.netty.util.concurrent.DefaultThreadFactory; import java.util.Collections; import java.util.List; final class EpollTestUtils { - private static final EventLoopGroup GROUP = new EpollEventLoopGroup(); + + private static final int BOSSES = 2; + private static final int WORKERS = 3; + + private static final EventLoopGroup epollBossGroup = + new NioEventLoopGroup(BOSSES, new DefaultThreadFactory("testsuite-epoll-boss", true)); + private static final EventLoopGroup epollWorkerGroup = + new NioEventLoopGroup(WORKERS, new DefaultThreadFactory("testsuite-epoll-worker", true)); + static List> newFactories() { return Collections.>singletonList( new TestsuitePermutation.BootstrapComboFactory() { @Override public ServerBootstrap newServerInstance() { - return new ServerBootstrap().group(GROUP).channel(EpollServerSocketChannel.class); + return new ServerBootstrap().group( + epollBossGroup, epollWorkerGroup).channel(EpollServerSocketChannel.class); } @Override public Bootstrap newClientInstance() { - return new Bootstrap().group(GROUP).channel(EpollSocketChannel.class); + return new Bootstrap().group(epollWorkerGroup).channel(EpollSocketChannel.class); } }); }