Add timeout to netconf IT test 79/13679/4
authorMaros Marsalek <mmarsale@cisco.com>
Tue, 16 Dec 2014 12:40:56 +0000 (13:40 +0100)
committerMaros Marsalek <mmarsale@cisco.com>
Thu, 18 Dec 2014 12:18:53 +0000 (13:18 +0100)
Also remove blocking call from celanup.

Change-Id: I9663ae8fd8afb605a6713232c518782ec15d431e
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/AbstractNetconfConfigTest.java
opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java

index 65810a6bdab8d840919e9f25b1d0961b499d0566..fd362f83e7d793f0accff7a25aa3d9d5207f6d0e 100644 (file)
@@ -34,6 +34,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import org.apache.commons.io.IOUtils;
 import org.junit.After;
 import org.junit.Before;
@@ -77,6 +78,7 @@ public abstract class AbstractNetconfConfigTest extends AbstractConfigTest {
 
     public static final String LOOPBACK_ADDRESS = "127.0.0.1";
     public static final int SERVER_CONNECTION_TIMEOUT_MILLIS = 5000;
+    private static final int RESOURCE_TIMEOUT_MINUTES = 2;
 
     static ModuleFactory[] FACTORIES = {new TestImplModuleFactory(),
                                         new DepTestImplModuleFactory(),
@@ -145,7 +147,7 @@ public abstract class AbstractNetconfConfigTest extends AbstractConfigTest {
         } else {
             s = dispatch.createServer(((InetSocketAddress) getTcpServerAddress()));
         }
-        s.await();
+        s.await(RESOURCE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
         return s.channel();
     }
 
@@ -230,9 +232,9 @@ public abstract class AbstractNetconfConfigTest extends AbstractConfigTest {
      */
     @After
     public void cleanUpNetconf() throws Exception {
-        serverTcpChannel.close().await();
+        serverTcpChannel.close().await(RESOURCE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
         hashedWheelTimer.stop();
-        nettyThreadgroup.shutdownGracefully().await();
+        nettyThreadgroup.shutdownGracefully().await(RESOURCE_TIMEOUT_MINUTES, TimeUnit.MINUTES);
     }
 
     public NetconfClientConfiguration getClientConfiguration(final InetSocketAddress tcpAddress, final int timeout) {
index 5f316d11c1cc6e28210d3382d0a78ca23aa01dd6..31986b8afe522be41e1844714cd895d819b259ed 100644 (file)
@@ -108,12 +108,12 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest {
     @After
     public void tearDown() throws Exception {
         sshProxyServer.close();
-        clientGroup.shutdownGracefully().await();
+        clientGroup.shutdownGracefully();
         minaTimerEx.shutdownNow();
         nioExec.shutdownNow();
     }
 
-    @Test
+    @Test(timeout = 2*60*1000)
     public void testSecure() throws Exception {
         final NetconfClientDispatcher dispatch = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer());
         try (TestingNetconfClient netconfClient = new TestingNetconfClient("testing-ssh-client", dispatch, getClientConfiguration(new SimpleNetconfClientSessionListener()))) {