Search in sources :

Example 11 with Capabilities

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project openflowplugin by opendaylight.

the class MultipartReplyGroupFeaturesTest method testMultipartReplyGroupFeatures2.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
 * (with different group types and capabilities).
 */
@Test
public void testMultipartReplyGroupFeatures2() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 08 00 01 00 00 00 00 " + // types
    "00 00 00 00 " + // capabilities
    "00 00 00 00 " + // max groups
    "00 00 00 01 " + // max groups
    "00 00 00 02 " + // max groups
    "00 00 00 03 " + // max groups
    "00 00 00 04 " + // actions bitmap (all actions included)
    "00 00 00 00 " + // actions bitmap (no actions included)
    "00 00 00 00 " + // actions bitmap (no actions included)
    "00 00 00 00 " + // actions bitmap (no actions included)
    "00 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyGroupFeaturesCase messageCase = (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures();
    Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes());
    Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false), message.getCapabilities());
}
Also used : MultipartReplyGroupFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes) GroupCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 12 with Capabilities

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project openflowplugin by opendaylight.

the class FeaturesReplyMessageFactoryTest method test.

/**
 * Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00" + " 00 00 00 00 01 02 03");
    GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
    Assert.assertEquals("Wrong buffers", 0x00010203L, builtByFactory.getBuffers().longValue());
    Assert.assertEquals("Wrong number of tables", 0x01, builtByFactory.getTables().shortValue());
    Assert.assertEquals("Wrong auxiliaryId", 0x01, builtByFactory.getAuxiliaryId().shortValue());
    Assert.assertEquals("Wrong capabilities", new Capabilities(false, false, false, false, false, false, false), builtByFactory.getCapabilities());
    Assert.assertEquals("Wrong reserved", 0x00010203L, builtByFactory.getReserved().longValue());
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) Capabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 13 with Capabilities

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project openflowplugin by opendaylight.

the class FeaturesReplyMessageFactoryTest method testCapabilities.

/**
 * Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO
 * (capabilities set).
 */
@Test
public void testCapabilities() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00" + " 00 01 6F 00 01 02 03");
    GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong capabilities", new Capabilities(true, true, true, true, true, true, true), builtByFactory.getCapabilities());
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) Capabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 14 with Capabilities

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project openflowplugin by opendaylight.

the class DeviceManagerImplTest method setUp.

@Before
public void setUp() throws Exception {
    when(mockConnectionContext.getNodeId()).thenReturn(DUMMY_NODE_ID);
    when(mockConnectionContext.getFeatures()).thenReturn(mockFeatures);
    when(mockConnectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
    when(mockConnectionContext.getDeviceInfo()).thenReturn(deviceInfo);
    when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
    when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(DUMMY_IDENTIFIER);
    when(deviceInfo.getNodeId()).thenReturn(DUMMY_NODE_ID);
    when(mockFeatures.getCapabilities()).thenReturn(capabilities);
    when(mockFeatures.getCapabilitiesV10()).thenReturn(capabilitiesV10);
    when(mockFeatures.getDatapathId()).thenReturn(BigInteger.valueOf(21L));
    when(mockedFuture.isDone()).thenReturn(true);
    when(writeTransaction.submit()).thenReturn(mockedFuture);
    when(transactionChain.newWriteOnlyTransaction()).thenReturn(writeTransaction);
    when(dataBroker.createTransactionChain(any(TransactionChainListener.class))).thenReturn(transactionChain);
    when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction);
    deviceManager = new DeviceManagerImpl(new OpenflowProviderConfigBuilder().setBarrierCountLimit(new NonZeroUint16Type(BARRIER_COUNT_LIMIT)).setBarrierIntervalTimeoutLimit(new NonZeroUint32Type(BARRIER_INTERVAL_NANOS)).setGlobalNotificationQuota(TEST_VALUE_GLOBAL_NOTIFICATION_QUOTA).setSwitchFeaturesMandatory(false).setEnableFlowRemovedNotification(true).setSkipTableFeatures(false).setUseSingleLayerSerialization(true).build(), dataBroker, messageIntelligenceAgency, notificationPublishService, new HashedWheelTimer(), convertorExecutor, DeviceInitializerProviderFactory.createDefaultProvider());
    deviceManager.setTranslatorLibrary(translatorLibrary);
    verify(dataBroker).newWriteOnlyTransaction();
    verify(writeTransaction).merge(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
    verify(writeTransaction).submit();
}
Also used : NonZeroUint16Type(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint16Type) OpenflowProviderConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.OpenflowProviderConfigBuilder) TransactionChainListener(org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener) NonZeroUint32Type(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow.provider.config.rev160510.NonZeroUint32Type) HashedWheelTimer(io.netty.util.HashedWheelTimer) Before(org.junit.Before)

Example 15 with Capabilities

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testGroupFeaturesSerialize.

@Test
public void testGroupFeaturesSerialize() throws Exception {
    MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setFlags(new MultipartRequestFlags(true));
    builder.setType(MultipartType.forValue(8));
    final MultipartReplyGroupFeaturesCaseBuilder featureCase = new MultipartReplyGroupFeaturesCaseBuilder();
    MultipartReplyGroupFeaturesBuilder feature = new MultipartReplyGroupFeaturesBuilder();
    feature.setTypes(new GroupTypes(true, false, true, false));
    feature.setCapabilities(new GroupCapabilities(true, false, true, true));
    List<Long> maxGroups = new ArrayList<>();
    maxGroups.add(1L);
    maxGroups.add(2L);
    maxGroups.add(3L);
    maxGroups.add(4L);
    feature.setMaxGroups(maxGroups);
    feature.setActionsBitmap(createActionType());
    featureCase.setMultipartReplyGroupFeatures(feature.build());
    builder.setMultipartReplyBody(featureCase.build());
    MultipartReplyMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56);
    Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUPFEATURES.getIntValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
    serializedBuffer.skipBytes(PADDING);
    MultipartReplyGroupFeaturesCase body = (MultipartReplyGroupFeaturesCase) message.getMultipartReplyBody();
    MultipartReplyGroupFeatures messageOutput = body.getMultipartReplyGroupFeatures();
    Assert.assertEquals("Wrong type", messageOutput.getTypes(), createGroupTypes(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(), createGroupCapabilities(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(0).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(1).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(2).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(3).intValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(0), createActionType(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(1), createActionType(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(2), createActionType(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(3), createActionType(serializedBuffer.readInt()));
}
Also used : MultipartReplyGroupFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures) ArrayList(java.util.ArrayList) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes) MultipartReplyGroupFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase) GroupCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReplyGroupFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)18 ByteBuf (io.netty.buffer.ByteBuf)14 CapabilitiesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10)8 Capabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities)7 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)6 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)6 ArrayList (java.util.ArrayList)5 Before (org.junit.Before)3 GroupCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities)3 GroupTypes (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes)3 MeterBandTypeBitmap (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap)3 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags)3 MultipartReplyGroupFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase)3 MultipartReplyMeterFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)3 MultipartReplyGroupFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures)3 MultipartReplyMeterFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures)3 OptionalCapabilities (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.OptionalCapabilities)3 Nullable (javax.annotation.Nullable)2 ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)2 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)2