Search in sources :

Example 1 with FeaturesReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.

the class RpcManagerImplTest method setUp.

@Before
public void setUp() {
    final NodeKey nodeKey = new NodeKey(nodeId);
    rpcManager = new RpcManagerImpl(new OpenflowProviderConfigBuilder().setRpcRequestsQuota(new NonZeroUint16Type(QUOTA_VALUE)).setIsStatisticsRpcEnabled(false).build(), rpcProviderRegistry, extensionConverterProvider, convertorExecutor, notificationPublishService);
    FeaturesReply features = new GetFeaturesOutputBuilder().setVersion(OFConstants.OFP_VERSION_1_3).build();
    Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeKey.getId());
    Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
    Mockito.when(connectionContext.getFeatures()).thenReturn(features);
    Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
    Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
    Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
    Mockito.when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
    Mockito.when(rpcProviderRegistry.addRoutedRpcImplementation(Matchers.any(), Matchers.any(RpcService.class))).thenReturn(routedRpcRegistration);
    Mockito.when(contexts.remove(deviceInfo)).thenReturn(removedContexts);
}
Also used : NonZeroUint16Type(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint16Type) GetFeaturesOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder) OpenflowProviderConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder) FeaturesReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply) RpcService(org.opendaylight.yangtools.yang.binding.RpcService) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Before(org.junit.Before)

Example 2 with FeaturesReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.

the class DeviceContextImplTest method prepareConnectionContext.

private ConnectionContext prepareConnectionContext() {
    final ConnectionContext mockedConnectionContext = mock(ConnectionContext.class);
    final FeaturesReply mockedFeaturesReply = mock(FeaturesReply.class);
    when(mockedFeaturesReply.getAuxiliaryId()).thenReturn(DUMMY_AUXILIARY_ID);
    when(mockedConnectionContext.getFeatures()).thenReturn(mockedFeaturesReply);
    return mockedConnectionContext;
}
Also used : FeaturesReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply) ConnectionContext(org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)

Example 3 with FeaturesReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.

the class DeviceContextImplTest method setUp.

@Before
public void setUp() throws Exception {
    final CheckedFuture<Optional<Node>, ReadFailedException> noExistNodeFuture = Futures.immediateCheckedFuture(Optional.<Node>absent());
    Mockito.when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodeKeyIdent)).thenReturn(noExistNodeFuture);
    Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(readTx);
    Mockito.when(dataBroker.createTransactionChain(Mockito.any(TransactionChainManager.class))).thenReturn(txChainFactory);
    Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeKeyIdent);
    Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeId);
    Mockito.when(deviceInfo.getDatapathId()).thenReturn(BigInteger.ONE);
    final SettableFuture<RpcResult<GetAsyncReply>> settableFuture = SettableFuture.create();
    final SettableFuture<RpcResult<MultipartReply>> settableFutureMultiReply = SettableFuture.create();
    Mockito.when(requestContext.getFuture()).thenReturn(settableFuture);
    Mockito.doAnswer(invocation -> {
        settableFuture.set((RpcResult<GetAsyncReply>) invocation.getArguments()[0]);
        return null;
    }).when(requestContext).setResult(any(RpcResult.class));
    Mockito.when(requestContextMultiReply.getFuture()).thenReturn(settableFutureMultiReply);
    Mockito.doAnswer(invocation -> {
        settableFutureMultiReply.set((RpcResult<MultipartReply>) invocation.getArguments()[0]);
        return null;
    }).when(requestContextMultiReply).setResult(any(RpcResult.class));
    Mockito.when(txChainFactory.newReadWriteTransaction()).thenReturn(writeTx);
    Mockito.when(dataBroker.newReadOnlyTransaction()).thenReturn(readTx);
    Mockito.when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
    Mockito.when(connectionContext.getConnectionAdapter()).thenReturn(connectionAdapter);
    Mockito.when(connectionContext.getDeviceInfo()).thenReturn(deviceInfo);
    final FeaturesReply mockedFeaturesReply = mock(FeaturesReply.class);
    when(connectionContext.getFeatures()).thenReturn(mockedFeaturesReply);
    when(connectionContext.getFeatures().getCapabilities()).thenReturn(mock(Capabilities.class));
    Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    Mockito.when(featuresOutput.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
    Mockito.when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    Mockito.when(contextChainHolder.getContextChain(deviceInfo)).thenReturn(contextChain);
    Mockito.when(contextChain.isMastered(ContextChainMastershipState.CHECK, false)).thenReturn(true);
    final PacketReceived packetReceived = new PacketReceivedBuilder().setMatch(new org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.MatchBuilder().setInPort(new NodeConnectorId("openflow:1:LOCAL")).build()).build();
    Mockito.when(messageTranslatorPacketReceived.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(packetReceived);
    Mockito.when(messageTranslatorFlowCapableNodeConnector.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(mock(FlowCapableNodeConnector.class));
    Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3, PacketIn.class.getName())))).thenReturn(messageTranslatorPacketReceived);
    Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3, PortGrouping.class.getName())))).thenReturn(messageTranslatorFlowCapableNodeConnector);
    Mockito.when(translatorLibrary.lookupTranslator(eq(new TranslatorKey(OFConstants.OFP_VERSION_1_3, FlowRemoved.class.getName())))).thenReturn(messageTranslatorFlowRemoved);
    Mockito.when(abstractDeviceInitializer.initialize(any(), anyBoolean(), anyBoolean(), any(), any())).thenReturn(Futures.immediateFuture(null));
    final java.util.Optional<AbstractDeviceInitializer> deviceInitializer = java.util.Optional.of(this.abstractDeviceInitializer);
    Mockito.when(deviceInitializerProvider.lookup(OFConstants.OFP_VERSION_1_3)).thenReturn(deviceInitializer);
    Mockito.when(salRoleService.setRole(any())).thenReturn(Futures.immediateFuture(null));
    deviceContext = new DeviceContextImpl(connectionContext, dataBroker, messageSpy, translatorLibrary, convertorExecutor, false, timer, false, deviceInitializerProvider, true, false, contextChainHolder);
    ((DeviceContextImpl) deviceContext).lazyTransactionManagerInitialization();
    deviceContextSpy = Mockito.spy(deviceContext);
    xid = new Xid(atomicLong.incrementAndGet());
    xidMulti = new Xid(atomicLong.incrementAndGet());
    Mockito.doNothing().when(deviceContextSpy).writeToTransaction(any(), any(), any());
}
Also used : MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) TranslatorKey(org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey) PacketReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceivedBuilder) GetAsyncReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncReply) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) FlowRemoved(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) AbstractDeviceInitializer(org.opendaylight.openflowplugin.impl.device.initialization.AbstractDeviceInitializer) Optional(com.google.common.base.Optional) FeaturesReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) PortGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortGrouping) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) PacketIn(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketIn) Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) Capabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities) TransactionChainManager(org.opendaylight.openflowplugin.common.txchain.TransactionChainManager) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Before(org.junit.Before)

Example 4 with FeaturesReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.

the class OF13DeviceInitializerTest method setUp.

@Before
public void setUp() throws Exception {
    final KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier = DeviceStateUtil.createNodeInstanceIdentifier(new NodeId("openflow:1"));
    deviceInitializer = new OF13DeviceInitializer();
    when(multipartWriterProvider.lookup(any())).thenReturn(Optional.of(abstractMultipartWriter));
    when(featuresReply.getCapabilities()).thenReturn(capabilities);
    when(connectionContext.getFeatures()).thenReturn(featuresReply);
    when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
    when(deviceContext.getDeviceState()).thenReturn(deviceState);
    when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
    when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
    when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
    when(translatorLibrary.lookupTranslator(any())).thenReturn(messageTranslator);
    when(deviceContext.oook()).thenReturn(translatorLibrary);
    when(requestContext.getXid()).thenReturn(new Xid(42L));
    when(deviceContext.createRequestContext()).thenReturn(requestContext);
    when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Before(org.junit.Before)

Example 5 with FeaturesReply

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.

the class OF13DeviceInitializerTest method initializeSingleLayer.

@Test
public void initializeSingleLayer() throws Exception {
    when(deviceContext.canUseSingleLayerSerialization()).thenReturn(true);
    when(requestContext.getFuture()).thenReturn(RpcResultBuilder.success(Collections.singletonList(new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyDescBuilder().build()).build())).buildFuture());
    final Future<Void> initialize = deviceInitializer.initialize(deviceContext, true, false, multipartWriterProvider, convertorExecutor);
    initialize.get();
    verify(messageSpy, times(5)).spyMessage(eq(MultipartType.class), any());
    verify(requestContext, times(5)).getFuture();
    verify(featuresReply).getCapabilities();
    verify(deviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
Also used : MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder) MultipartReplyDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.multipart.reply.multipart.reply.body.MultipartReplyDescBuilder) Test(org.junit.Test)

Aggregations

FeaturesReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply)7 Before (org.junit.Before)6 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)4 ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)3 Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)3 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)3 Test (org.junit.Test)2 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)2 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)2 Capabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities)2 MultipartType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType)2 Optional (com.google.common.base.Optional)1 InetSocketAddress (java.net.InetSocketAddress)1 Date (java.util.Date)1 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)1 OutboundQueue (org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue)1 DeviceContext (org.opendaylight.openflowplugin.api.openflow.device.DeviceContext)1 DeviceManager (org.opendaylight.openflowplugin.api.openflow.device.DeviceManager)1 DeviceState (org.opendaylight.openflowplugin.api.openflow.device.DeviceState)1 ContextChain (org.opendaylight.openflowplugin.api.openflow.lifecycle.ContextChain)1