BUG-837: IT unstable 26/12326/2
authorMichal Rehak <mirehak@cisco.com>
Wed, 29 Oct 2014 17:36:17 +0000 (18:36 +0100)
committermichal rehak <mirehak@cisco.com>
Wed, 29 Oct 2014 17:42:07 +0000 (17:42 +0000)
IT keep running forever because of change in OFJava + old change in OFPlugin-IT.

- fixed scenario for 2 hello handshake test (OFPluginToLibraryTest)
- fixed threading for scenario execution

Change-Id: I5af8248fd9c92f3bc2e02cac169c4f34599519d7
Signed-off-by: Michal Rehak <mirehak@cisco.com>
openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/OFPluginToLibraryTest.java
openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/ScenarioFactory.java

index e29b6eaf3985187a5caad7c4930f8371bab0aae7..061f996d4d88ea8c148b3fa06f5ff0491044bd97 100644 (file)
@@ -11,6 +11,7 @@ import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
 import java.util.Stack;
+import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.TimeUnit;
 
 import javax.inject.Inject;
@@ -25,6 +26,7 @@ import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;
 import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler;
 import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient;
 import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent;
+import org.opendaylight.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor;
 import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
@@ -46,6 +48,8 @@ public class OFPluginToLibraryTest {
     private static final Logger LOG = LoggerFactory
             .getLogger(OFPluginToLibraryTest.class);
 
+    private static final ArrayBlockingQueue<Runnable> SCENARIO_POOL_QUEUE = new ArrayBlockingQueue<>(1);
+
     @Inject @Filter(timeout=20000)
     OpenflowPluginProvider openflowPluginProvider;
 
@@ -53,6 +57,7 @@ public class OFPluginToLibraryTest {
     BundleContext ctx;
 
     private SimpleClient switchSim;
+    private ThreadPoolLoggingExecutor scenarioPool;
 
     /**
      * test setup
@@ -61,6 +66,7 @@ public class OFPluginToLibraryTest {
     @Before
     public void setUp() throws InterruptedException {
         LOG.debug("openflowPluginProvider: "+openflowPluginProvider);
+        scenarioPool = new ThreadPoolLoggingExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, SCENARIO_POOL_QUEUE, "scenario");
         //FIXME: plugin should provide service exposing startup result via future
         Thread.sleep(5000);
     }
@@ -77,10 +83,11 @@ public class OFPluginToLibraryTest {
             String msg = "waiting for scenario to finish failed: "+e.getMessage();
             LOG.error(msg, e);
             Assert.fail(msg);
+        } finally {
+            scenarioPool.shutdownNow();
+            SCENARIO_POOL_QUEUE.clear();
         }
 
-        //TODO: dump errors of plugin (by exploiting ErrorHandler)
-
         try {
             LOG.debug("checking if simulator succeeded to connect to controller");
             boolean simulatorWasOnline = switchSim.getIsOnlineFuture().get(100, TimeUnit.MILLISECONDS);
@@ -107,7 +114,7 @@ public class OFPluginToLibraryTest {
 
         ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
         switchSim.setScenarioHandler(scenario);
-        switchSim.run();
+        scenarioPool.execute(switchSim);
     }
 
     /**
@@ -125,7 +132,7 @@ public class OFPluginToLibraryTest {
 
         ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
         switchSim.setScenarioHandler(scenario);
-        switchSim.run();
+        scenarioPool.execute(switchSim);
     }
 
     /**
@@ -144,7 +151,7 @@ public class OFPluginToLibraryTest {
 
         ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
         switchSim.setScenarioHandler(scenario);
-        switchSim.run();
+        scenarioPool.execute(switchSim);
     }
 
     /**
@@ -165,7 +172,7 @@ public class OFPluginToLibraryTest {
 
         ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
         switchSim.setScenarioHandler(scenario);
-        switchSim.run();
+        scenarioPool.execute(switchSim);
     }
 
     /**
@@ -191,7 +198,7 @@ public class OFPluginToLibraryTest {
 
         ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
         switchSim.setScenarioHandler(scenario);
-        switchSim.run();
+        scenarioPool.execute(switchSim);
     }
 
     /**
@@ -214,7 +221,7 @@ public class OFPluginToLibraryTest {
 
         ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
         switchSim.setScenarioHandler(scenario);
-        switchSim.run();
+        scenarioPool.execute(switchSim);
     }
 
     /**
index a13236552ed4ad5470a9d477d4245a386a3b7205..72fc428b6a87d06875f225c3275d74e47a4a2090 100644 (file)
@@ -202,19 +202,6 @@ public abstract class ScenarioFactory {
                                 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
                                 + " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
                                 + " 00 00")));
-        stack.add(0, new WaitForMessageEvent(ByteBufUtils
-                .hexStringToBytes("01 05 00 08 00 00 01 69")));
-
-        stack.add(0, new SendEvent(
-                ByteBufUtils
-                        .hexStringToBytes("01 06 00 80 00 00 01 69 cc 4e 24 1c 4a 00 00 00"
-                                + " 00 00 01 00 01 00 00 00 00 00 00 07 00 00 01 0f"
-                                + " 00 61 cc 4e 24 1c 4a 60 65 74 68 33 2f 31 00 00"
-                                + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
-                                + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40"
-                                + " 00 62 cc 4e 24 1c 4a 61 65 74 68 33 2f 32 00 00"
-                                + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
-                                + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40")));
 
         stack.add(0, new SleepEvent(5000));