X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fopenflow%2Fmd%2Fit%2FOFPluginToLibraryTest.java;h=a565e7a4fc8e9622721d8c4edd65a5ef490b45a8;hb=8b4d47df9e5ece7069ff6195cc4bd2d833c4b438;hp=b40877aa38eecc471da581f2fecacdd20aace374;hpb=f2eb38ff9595bd07e00cdfb90498687784c27c6a;p=openflowplugin.git 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 b40877aa38..a565e7a4fc 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 @@ -7,19 +7,17 @@ */ package org.opendaylight.openflowplugin.openflow.md.it; -import static org.ops4j.pax.exam.CoreOptions.junitBundles; -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; import static org.ops4j.pax.exam.CoreOptions.options; import static org.ops4j.pax.exam.CoreOptions.systemProperty; -import java.util.Stack; +import java.util.Deque; +import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.TimeUnit; import javax.inject.Inject; -import junit.framework.Assert; - import org.junit.After; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.opendaylight.controller.test.sal.binding.it.TestHelper; @@ -27,56 +25,57 @@ 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.openflowjava.protocol.spi.connection.SwitchConnectionProvider; +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; import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; +import org.ops4j.pax.exam.util.Filter; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +/** + * covers basic handshake scenarios + */ @RunWith(PaxExam.class) +@ExamReactorStrategy(PerClass.class) public class OFPluginToLibraryTest { private static final Logger LOG = LoggerFactory .getLogger(OFPluginToLibraryTest.class); - /** base controller package */ - public static final String ODL = "org.opendaylight.controller"; - /** controller.model package */ - public static final String ODL_MODEL = "org.opendaylight.controller.model"; - /** yangtools package */ - public static final String YANG = "org.opendaylight.yangtools"; - /** yangtools.model package */ - public static final String YANG_MODEL = "org.opendaylight.yangtools.model"; - /** OFPlugin package */ - public static final String OFPLUGIN = "org.opendaylight.openflowplugin"; - /** OFLibrary package */ - public static final String OFLIBRARY = "org.opendaylight.openflowjava"; - /** netty.io package */ - public static final String NETTY = "io.netty"; - - @Inject - SwitchConnectionProvider switchConnectionProvider; - - @Inject + private final ArrayBlockingQueue SCENARIO_POOL_QUEUE = new ArrayBlockingQueue<>(1); + + @Inject @Filter(timeout=60000) + OpenflowPluginProvider openflowPluginProvider; + + @Inject @Filter(timeout=60000) BundleContext ctx; private SimpleClient switchSim; + private ThreadPoolLoggingExecutor scenarioPool; + + /** + * test setup + * @throws InterruptedException + */ + @Before + public void setUp() throws InterruptedException { + LOG.debug("openflowPluginProvider: "+openflowPluginProvider); + switchSim = createSimpleClient(); + scenarioPool = new ThreadPoolLoggingExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, SCENARIO_POOL_QUEUE, "scenario"); + } /** * test tear down */ @After public void tearDown() { - try { - LOG.debug("tearing down simulator"); - switchSim.getScenarioDone().get(getFailSafeTimeout(), TimeUnit.MILLISECONDS); - } catch (Exception e) { - String msg = "waiting for scenario to finish failed: "+e.getMessage(); - LOG.error(msg, e); - Assert.fail(msg); - } + SimulatorAssistant.waitForSwitchSimulatorOn(switchSim); + SimulatorAssistant.tearDownSwitchSimulatorAfterScenario(switchSim, scenarioPool, getFailSafeTimeout()); } /** @@ -85,25 +84,15 @@ public class OFPluginToLibraryTest { */ @Test public void handshakeOk1() throws Exception { - LOG.debug("handshake integration test"); - LOG.debug("switchConnectionProvider: "+switchConnectionProvider); + LOG.debug("handshakeOk1 integration test"); - switchSim = new SimpleClient("localhost", 6653); switchSim.setSecuredClient(false); - Stack handshakeScenario = ScenarioFactory.createHandshakeScenarioVBM( - ScenarioFactory.VERSION_BITMAP_13, (short) 0, ScenarioFactory.VERSION_BITMAP_10_13); + Deque handshakeScenario = ScenarioFactory.createHandshakeScenarioVBM( + ScenarioFactory.VERSION_BITMAP_13, (short) 0, ScenarioFactory.VERSION_BITMAP_10_13, true); ScenarioHandler scenario = new ScenarioHandler(handshakeScenario); switchSim.setScenarioHandler(scenario); - switchSim.start(); - try { - switchSim.getScenarioDone().get(getFailSafeTimeout(), TimeUnit.MILLISECONDS); - } catch (Exception e) { - String msg = "waiting for scenario to finish failed: "+e.getMessage(); - LOG.error(msg, e); - Assert.fail(msg); - } - //TODO: dump errors of plugin + scenarioPool.execute(switchSim); } /** @@ -112,74 +101,111 @@ public class OFPluginToLibraryTest { */ @Test public void handshakeOk2() throws Exception { - LOG.debug("handshake integration test"); - LOG.debug("switchConnectionProvider: "+switchConnectionProvider); + LOG.debug("handshakeOk2 integration test"); - switchSim = new SimpleClient("localhost", 6653); + switchSim = createSimpleClient(); switchSim.setSecuredClient(false); - Stack handshakeScenario = ScenarioFactory.createHandshakeScenario( + Deque handshakeScenario = ScenarioFactory.createHandshakeScenario( (short) 0, ScenarioFactory.VERSION_BITMAP_10_13); ScenarioHandler scenario = new ScenarioHandler(handshakeScenario); switchSim.setScenarioHandler(scenario); - switchSim.start(); - try { - switchSim.getScenarioDone().get(getFailSafeTimeout(), TimeUnit.MILLISECONDS); - } catch (Exception e) { - String msg = "waiting for scenario to finish failed: "+e.getMessage(); - LOG.error(msg, e); - Assert.fail(msg); - } - //TODO: dump errors of plugin + scenarioPool.execute(switchSim); } /** - * test basic integration with OFLib running the handshake + * test basic integration with OFLib running the handshake: + * creating auxiliary connection without primary connection -- FAIL * @throws Exception */ @Test public void handshakeFail1() throws Exception { - LOG.debug("handshake integration test"); - LOG.debug("switchConnectionProvider: "+switchConnectionProvider); + LOG.debug("handshakeFail1 integration test"); - switchSim = new SimpleClient("localhost", 6653); + switchSim = createSimpleClient(); switchSim.setSecuredClient(false); - Stack handshakeScenario = ScenarioFactory.createHandshakeScenario((short) 1, + Deque handshakeScenario = ScenarioFactory.createHandshakeScenario((short) 1, ScenarioFactory.VERSION_BITMAP_10_13); ScenarioHandler scenario = new ScenarioHandler(handshakeScenario); switchSim.setScenarioHandler(scenario); - switchSim.start(); - try { - switchSim.getScenarioDone().get(getFailSafeTimeout(), TimeUnit.MILLISECONDS); - } catch (Exception e) { - String msg = "waiting for scenario to finish failed: "+e.getMessage(); - LOG.error(msg, e); - Assert.fail(msg); - } - //TODO: dump errors of plugin + scenarioPool.execute(switchSim); } /** * test basic integration with OFLib running the handshake + * adding 5s wait as first event of switch -- FAIL * @throws Exception */ @Test public void handshakeFail2() throws Exception { - LOG.debug("handshake integration test"); - LOG.debug("switchConnectionProvider: "+switchConnectionProvider); + LOG.debug("handshakeFail2 integration test"); + LOG.debug("openflowPluginProvider: "+openflowPluginProvider); - switchSim = new SimpleClient("localhost", 6653); + switchSim = createSimpleClient(); switchSim.setSecuredClient(false); - Stack handshakeScenario = ScenarioFactory.createHandshakeScenario((short) 1, + Deque handshakeScenario = ScenarioFactory.createHandshakeScenario((short) 0, ScenarioFactory.VERSION_BITMAP_10_13); - handshakeScenario.setElementAt(new SleepEvent(5000), 0); + handshakeScenario.addFirst(new SleepEvent(5000)); + ScenarioHandler scenario = new ScenarioHandler(handshakeScenario); + switchSim.setScenarioHandler(scenario); + scenarioPool.execute(switchSim); + } + + /** + * test with MLX running OF10 and OFP running OF13/OF10 + * + * MLX issues an OFPT_ERROR on the version compatability MLX issues a second + * HELLO after the second OFP HELLO + * + * @throws Exception + */ + @Test + public void handshakeOkNoVBM_OF10_TwoHello() throws Exception { + LOG.debug("handshakeOkMLX10 integration test"); + LOG.debug("openflowPluginProvider: " + openflowPluginProvider); + + switchSim = createSimpleClient(); + switchSim.setSecuredClient(false); + Deque handshakeScenario = ScenarioFactory + .createHandshakeScenarioNoVBM_OF10_TwoHello(); + // handshakeScenario.setElementAt(new SleepEvent(5000), + // handshakeScenario + // .size()); ScenarioHandler scenario = new ScenarioHandler(handshakeScenario); switchSim.setScenarioHandler(scenario); - switchSim.start(); - tearDown(); - //TODO: dump errors of plugin + scenarioPool.execute(switchSim); + } + + /** + * test with Mininet running OF10 and OFP running OF13/OF10 + * + * Mininet issues an OFPT_ERROR on the version compatability Mininet doesn't + * issue a second HELLO + * + * @throws Exception + */ + @Test + public void handshakeOkNoVBM_OF10_SingleHello() throws Exception { + LOG.debug("handshakeOkMLX10 integration test"); + LOG.debug("openflowPluginProvider: " + openflowPluginProvider); + + switchSim = createSimpleClient(); + switchSim.setSecuredClient(false); + Deque handshakeScenario = ScenarioFactory + .createHandshakeScenarioNOVBM_OF10_OneHello(); + + ScenarioHandler scenario = new ScenarioHandler(handshakeScenario); + switchSim.setScenarioHandler(scenario); + scenarioPool.execute(switchSim); + } + + /** + * @return + */ + private static SimpleClient createSimpleClient() { + return new SimpleClient("localhost", 6653); } /** @@ -195,36 +221,21 @@ public class OFPluginToLibraryTest { */ @Configuration public Option[] config() { + LOG.info("configuring..."); return options( systemProperty("osgi.console").value("2401"), - mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), - mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), - mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), - mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), - mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").versionAsInProject(), - TestHelper.mdSalCoreBundles(), TestHelper.bindingAwareSalBundles(), - TestHelper.flowCapableModelBundles(), TestHelper.baseModelBundles(), - - - mavenBundle(ODL, "sal").versionAsInProject(), - mavenBundle(ODL, "sal.connection").versionAsInProject(), - mavenBundle(ODL, "sal-common").versionAsInProject(), - - mavenBundle(ODL_MODEL, "model-flow-statistics").versionAsInProject(), - - mavenBundle(OFLIBRARY, "openflow-protocol-impl").versionAsInProject(), - mavenBundle(OFLIBRARY, "openflow-protocol-api").versionAsInProject(), - mavenBundle(OFLIBRARY, "openflow-protocol-spi").versionAsInProject(), - - mavenBundle(NETTY, "netty-handler").versionAsInProject(), - mavenBundle(NETTY, "netty-buffer").versionAsInProject(), - mavenBundle(NETTY, "netty-common").versionAsInProject(), - mavenBundle(NETTY, "netty-transport").versionAsInProject(), - mavenBundle(NETTY, "netty-codec").versionAsInProject(), - - mavenBundle(OFLIBRARY, "simple-client").versionAsInProject().start(), - mavenBundle(OFPLUGIN, "openflowplugin").versionAsInProject(), - junitBundles()); + systemProperty("osgi.bundles.defaultStartLevel").value("4"), + systemProperty("pax.exam.osgi.unresolved.fail").value("true"), + + OFPaxOptionsAssistant.osgiConsoleBundles(), + OFPaxOptionsAssistant.loggingBudles(), + + TestHelper.junitAndMockitoBundles(), + TestHelper.mdSalCoreBundles(), + TestHelper.configMinumumBundles(), + TestHelper.baseModelBundles(), + + OFPaxOptionsAssistant.ofPluginBundles()); } }