Search in sources :

Example 6 with ScenarioHandler

use of org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler in project openflowplugin by opendaylight.

the class IntegrationTest method testTlsHandshakeAndEcho.

/**
 * Library integration and secured communication test with handshake + echo exchange.
 */
@Test
public void testTlsHandshakeAndEcho() throws Exception {
    setUp(TransportProtocol.TLS);
    final int amountOfCLients = 1;
    final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
    scenario.addFirst(new SleepEvent(1000));
    scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04")));
    scenario.addFirst(new SleepEvent(1000));
    scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
    final ScenarioHandler handler = new ScenarioHandler(scenario);
    final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE);
    final OFClient firstClient = clients.get(0);
    firstClient.getScenarioDone().get();
    LOGGER.debug("testTlsHandshakeAndEcho() Finished");
}
Also used : ScenarioHandler(org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler) OFClient(org.opendaylight.openflowjava.protocol.impl.clients.OFClient) WaitForMessageEvent(org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent) ClientEvent(org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent) SendEvent(org.opendaylight.openflowjava.protocol.impl.clients.SendEvent) SleepEvent(org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent) Test(org.junit.Test)

Example 7 with ScenarioHandler

use of org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler in project openflowplugin by opendaylight.

the class SalIntegrationTest method handshakeAndNodeUpdate.

/**
 * test basic integration with OFLib running the handshake
 *
 * @throws Exception
 */
@Test
public void handshakeAndNodeUpdate() throws Exception {
    final TestInventoryListener listener = new TestInventoryListener();
    BindingAwareConsumer openflowConsumer = new BindingAwareConsumer() {

        @Override
        public void onSessionInitialized(ConsumerContext session) {
            session.getSALService(NotificationService.class).registerNotificationListener(listener);
        }
    };
    ConsumerContext consumerReg = broker.registerConsumer(openflowConsumer, ctx);
    assertNotNull(consumerReg);
    LOG.debug("handshake integration test");
    LOG.debug("openflowPluginProvider: " + openflowPluginProvider);
    switchSim.setSecuredClient(false);
    ScenarioHandler scenario = new ScenarioHandler(ScenarioFactory.createHandshakeScenarioVBM(ScenarioFactory.VERSION_BITMAP_13, (short) 0, ScenarioFactory.VERSION_BITMAP_10_13, true));
    switchSim.setScenarioHandler(scenario);
    scenarioPool.execute(switchSim);
    finalCheck = new Runnable() {

        @Override
        public void run() {
            // FIXME: Enable the test -- It's requires EntityOnwershipService hook to the test
            // assertEquals(1, listener.nodeUpdated.size());
            assertEquals(0, listener.nodeUpdated.size());
        // assertNotNull(listener.nodeUpdated.get(0));
        }
    };
}
Also used : ConsumerContext(org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext) ScenarioHandler(org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler) NotificationService(org.opendaylight.controller.sal.binding.api.NotificationService) BindingAwareConsumer(org.opendaylight.controller.sal.binding.api.BindingAwareConsumer) Test(org.junit.Test)

Example 8 with ScenarioHandler

use of org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler in project openflowplugin by opendaylight.

the class IntegrationTest method testUdpHandshakeAndEcho.

/**
 * Library udp integration and communication test with handshake + echo exchange.
 */
@Test
public void testUdpHandshakeAndEcho() throws Exception {
    setUp(TransportProtocol.UDP);
    final int amountOfCLients = 1;
    final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
    scenario.addFirst(new SleepEvent(1000));
    scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04")));
    scenario.addFirst(new SleepEvent(1000));
    scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
    final ScenarioHandler handler = new ScenarioHandler(scenario);
    final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.UDP, ClientType.SIMPLE);
    final OFClient firstClient = clients.get(0);
    firstClient.getScenarioDone().get();
    LOGGER.debug("testUdpHandshakeAndEcho() Finished");
}
Also used : ScenarioHandler(org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler) OFClient(org.opendaylight.openflowjava.protocol.impl.clients.OFClient) WaitForMessageEvent(org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent) ClientEvent(org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent) SendEvent(org.opendaylight.openflowjava.protocol.impl.clients.SendEvent) SleepEvent(org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent) Test(org.junit.Test)

Example 9 with ScenarioHandler

use of org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler in project openflowplugin by opendaylight.

the class IntegrationTest method testHandshakeAndEcho.

/**
 * Library integration and communication test with handshake + echo exchange.
 */
@Test
public void testHandshakeAndEcho() throws Exception {
    setUp(TransportProtocol.TCP);
    final int amountOfCLients = 1;
    final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
    scenario.addFirst(new SleepEvent(1000));
    scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04")));
    scenario.addFirst(new SleepEvent(1000));
    scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
    final ScenarioHandler handler = new ScenarioHandler(scenario);
    final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP, ClientType.SIMPLE);
    final OFClient firstClient = clients.get(0);
    firstClient.getScenarioDone().get();
    LOGGER.debug("testHandshakeAndEcho() Finished");
}
Also used : ScenarioHandler(org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler) OFClient(org.opendaylight.openflowjava.protocol.impl.clients.OFClient) WaitForMessageEvent(org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent) ClientEvent(org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent) SendEvent(org.opendaylight.openflowjava.protocol.impl.clients.SendEvent) SleepEvent(org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent) Test(org.junit.Test)

Example 10 with ScenarioHandler

use of org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler in project openflowplugin by opendaylight.

the class IntegrationTest method testInitiateConnection.

@Test
public void testInitiateConnection() throws Exception {
    setUp(TransportProtocol.TCP);
    final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
    final ScenarioHandler handler = new ScenarioHandler(scenario);
    final List<OFClient> clients = createAndStartClient(1, handler, TransportProtocol.TCP, ClientType.LISTENING);
    final OFClient ofClient = clients.get(0);
    ofClient.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
    final int listeningClientPort = ((ListeningSimpleClient) ofClient).getPort();
    mockPlugin.initiateConnection(switchConnectionProvider, "localhost", listeningClientPort);
    ofClient.getScenarioDone().get();
    LOGGER.debug("testInitiateConnection() Finished");
}
Also used : ListeningSimpleClient(org.opendaylight.openflowjava.protocol.impl.clients.ListeningSimpleClient) ScenarioHandler(org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler) OFClient(org.opendaylight.openflowjava.protocol.impl.clients.OFClient) ClientEvent(org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)14 ScenarioHandler (org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler)14 ClientEvent (org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent)13 OFClient (org.opendaylight.openflowjava.protocol.impl.clients.OFClient)6 SleepEvent (org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent)5 WaitForMessageEvent (org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent)4 SendEvent (org.opendaylight.openflowjava.protocol.impl.clients.SendEvent)3 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)1 ConsumerContext (org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext)1 BindingAwareConsumer (org.opendaylight.controller.sal.binding.api.BindingAwareConsumer)1 NotificationService (org.opendaylight.controller.sal.binding.api.NotificationService)1 ListeningSimpleClient (org.opendaylight.openflowjava.protocol.impl.clients.ListeningSimpleClient)1 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)1