Search in sources :

Example 71 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class ConnectionManagerImplTest method testOnSwitchConnected1.

/**
 * Test method for
 * {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
 * org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
 * invoking onConnectionReady first, scenario:
 * <ol>
 * <li>send hello to device (rpc with void output)</li>
 * <li>receive hello from device (notification)</li>
 * <li>send getFeature to device (rpc with getFeatureOutput)</li>
 * <li>wait for rpc to finish with getFeatureOutput</li>
 * </ol>
 *
 * @throws InterruptedException - interrupted exception
 */
@Test
public void testOnSwitchConnected1() throws Exception {
    connectionManagerImpl.onSwitchConnected(connection);
    Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture());
    Mockito.verify(connection).setMessageListener(ofpListenerAC.capture());
    // prepare void reply (hello rpc output)
    final SettableFuture<RpcResult<Void>> voidResponseFx = SettableFuture.<RpcResult<Void>>create();
    Mockito.when(connection.hello(Matchers.any(HelloInput.class))).thenReturn(voidResponseFx);
    // prepare getFeature reply (getFeture rpc output)
    final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.<RpcResult<GetFeaturesOutput>>create();
    Mockito.when(connection.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
    // fire handshake
    connectionReadyListenerAC.getValue().onConnectionReady();
    // deliver hello send output (void)
    Thread.sleep(100L);
    final RpcResult<Void> helloResponse = RpcResultBuilder.success((Void) null).build();
    voidResponseFx.set(helloResponse);
    // send hello reply
    final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build();
    ofpListenerAC.getValue().onHelloMessage(hello);
    // deliver getFeature output
    Thread.sleep(100L);
    final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder().setDatapathId(BigInteger.TEN).setVersion(OFConstants.OFP_VERSION_1_3).setXid(2L).setTables((short) 15).build();
    final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
    featureResponseFx.set(rpcFeaturesOutput);
    Mockito.verify(deviceConnectedHandler, Mockito.timeout(500)).deviceConnected(Matchers.any(ConnectionContext.class));
}
Also used : GetFeaturesOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder) GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext) Test(org.junit.Test)

Example 72 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class ConnectionManagerImplTest method testOnSwitchConnected2.

/**
 * Test method for
 * {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
 * org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
 * invoking onHelloMessage, scenario:
 * <ol>
 * <li>receive hello from device (notification)</li>
 * <li>send hello to device (rpc with void output)</li>
 * <li>send getFeature to device (rpc with getFeatureOutput)</li>
 * <li>wait for rpc to finish with getFeatureOutput</li>
 * </ol>
 *
 * @throws InterruptedException - interrupted exception
 */
@Test
public void testOnSwitchConnected2() throws Exception {
    connectionManagerImpl.onSwitchConnected(connection);
    Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture());
    Mockito.verify(connection).setMessageListener(ofpListenerAC.capture());
    // prepare void reply (hello rpc output)
    final SettableFuture<RpcResult<Void>> voidResponseFx = SettableFuture.<RpcResult<Void>>create();
    Mockito.when(connection.hello(Matchers.any(HelloInput.class))).thenReturn(voidResponseFx);
    // prepare getFeature reply (getFeture rpc output)
    final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.<RpcResult<GetFeaturesOutput>>create();
    Mockito.when(connection.getFeatures(Matchers.any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
    // fire handshake - send hello reply
    final HelloMessage hello = new HelloMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(1L).build();
    ofpListenerAC.getValue().onHelloMessage(hello);
    // notify about connection ready
    connectionReadyListenerAC.getValue().onConnectionReady();
    // deliver hello send output (void)
    Thread.sleep(100L);
    final RpcResult<Void> helloResponse = RpcResultBuilder.success((Void) null).build();
    voidResponseFx.set(helloResponse);
    // deliver getFeature output
    Thread.sleep(100L);
    final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder().setDatapathId(BigInteger.TEN).setVersion(OFConstants.OFP_VERSION_1_3).setXid(2L).setTables((short) 15).build();
    final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
    featureResponseFx.set(rpcFeaturesOutput);
    Mockito.verify(deviceConnectedHandler, Mockito.timeout(FINAL_STEP_TIMEOUT)).deviceConnected(Matchers.any(ConnectionContext.class));
}
Also used : GetFeaturesOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder) GetFeaturesInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput) HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext) Test(org.junit.Test)

Example 73 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class StatisticsManagerImplTest method testChangeStatisticsWorkMode2.

/**
 * Switching to {@link StatisticsWorkMode#FULLYDISABLED}; with pollTimeout and lifecycleRegistry.
 */
@Test
public void testChangeStatisticsWorkMode2() throws Exception {
    final StatisticsContext statisticContext = Mockito.mock(StatisticsContext.class);
    getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
    final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld = new ChangeStatisticsWorkModeInputBuilder().setMode(StatisticsWorkMode.FULLYDISABLED);
    Future<RpcResult<Void>> workMode = statisticsManager.changeStatisticsWorkMode(changeStatisticsWorkModeInputBld.build());
    checkWorkModeChangeOutcome(workMode);
    verify(statisticContext).disableGathering();
}
Also used : ChangeStatisticsWorkModeInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.ChangeStatisticsWorkModeInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) StatisticsContext(org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext) Test(org.junit.Test)

Example 74 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class StatisticsManagerImplTest method testChangeStatisticsWorkMode3.

/**
 * Tests switching to {@link StatisticsWorkMode#FULLYDISABLED} and back
 * to {@link StatisticsWorkMode#COLLECTALL}; with lifecycleRegistry and pollTimeout.
 */
@Test
public void testChangeStatisticsWorkMode3() throws Exception {
    final StatisticsContext statisticContext = Mockito.mock(StatisticsContext.class);
    getContextsMap(statisticsManager).put(deviceInfo, statisticContext);
    final ChangeStatisticsWorkModeInputBuilder changeStatisticsWorkModeInputBld = new ChangeStatisticsWorkModeInputBuilder().setMode(StatisticsWorkMode.FULLYDISABLED);
    Future<RpcResult<Void>> workMode;
    workMode = statisticsManager.changeStatisticsWorkMode(changeStatisticsWorkModeInputBld.build());
    checkWorkModeChangeOutcome(workMode);
    verify(statisticContext).disableGathering();
    changeStatisticsWorkModeInputBld.setMode(StatisticsWorkMode.COLLECTALL);
    workMode = statisticsManager.changeStatisticsWorkMode(changeStatisticsWorkModeInputBld.build());
    checkWorkModeChangeOutcome(workMode);
    verify(statisticContext).enableGathering();
}
Also used : ChangeStatisticsWorkModeInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.sm.control.rev150812.ChangeStatisticsWorkModeInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) StatisticsContext(org.opendaylight.openflowplugin.api.openflow.statistics.StatisticsContext) Test(org.junit.Test)

Example 75 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class NodeConnectorRefToPortTranslator method toNodeConnectorRef.

/**
 * Converts {@link PacketIn} to {@link NodeConnectorRef}.
 * @param packetIn Packet input
 * @param dataPathId Data path id
 * @return packet input converted to node connector reference
 */
@Nullable
public static NodeConnectorRef toNodeConnectorRef(@Nonnull PacketIn packetIn, BigInteger dataPathId) {
    Preconditions.checkNotNull(packetIn);
    NodeConnectorRef ref = null;
    Long port = getPortNoFromPacketIn(packetIn);
    if (port != null) {
        OpenflowVersion version = OpenflowVersion.get(packetIn.getVersion());
        ref = InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(dataPathId, port, version);
    }
    return ref;
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) Nullable(javax.annotation.Nullable)

Aggregations

Test (org.junit.Test)454 ByteBuf (io.netty.buffer.ByteBuf)138 ArrayList (java.util.ArrayList)71 BigInteger (java.math.BigInteger)58 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)54 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)51 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)45 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)38 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)37 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)35 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)35 InetAddress (java.net.InetAddress)33 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)33 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)32 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)28 Inet4Address (java.net.Inet4Address)27 Inet6Address (java.net.Inet6Address)27 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)27 LispAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress)26 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)26