From 88843cf835a7bd502d0140a55daed30a77d7218f Mon Sep 17 00:00:00 2001 From: Michal Rehak Date: Wed, 29 Oct 2014 18:36:17 +0100 Subject: [PATCH] BUG-837: IT unstable 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 --- .../openflow/md/it/OFPluginToLibraryTest.java | 23 ++++++++++++------- .../openflow/md/it/ScenarioFactory.java | 13 ----------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/OFPluginToLibraryTest.java b/openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/OFPluginToLibraryTest.java index e29b6eaf39..061f996d4d 100644 --- a/openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/OFPluginToLibraryTest.java +++ b/openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/OFPluginToLibraryTest.java @@ -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 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); } /** diff --git a/openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/ScenarioFactory.java b/openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/ScenarioFactory.java index a13236552e..72fc428b6a 100644 --- a/openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/ScenarioFactory.java +++ b/openflowplugin-it/src/test/java/org/opendaylight/openflowplugin/openflow/md/it/ScenarioFactory.java @@ -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)); -- 2.36.6