Search in sources :

Example 96 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.Config in project openflowplugin by opendaylight.

the class MultipartRequestTableFeaturesTest method testMultipartRequestTableFeaturesExperimenter.

/**
 * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
 */
@Test
public void testMultipartRequestTableFeaturesExperimenter() throws Exception {
    MultipartRequestInputFactory factory = new MultipartRequestInputFactory();
    factory.injectSerializerRegistry(mockRegistry);
    MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setType(MultipartType.forValue(12));
    builder.setFlags(new MultipartRequestFlags(true));
    TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
    tableFeaturesBuilder.setTableId((short) 8);
    tableFeaturesBuilder.setName("AAAABBBBCCCCDDDDEEEEFFFFGGGG");
    tableFeaturesBuilder.setMetadataMatch(new BigInteger(new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }));
    tableFeaturesBuilder.setMetadataWrite(new BigInteger(new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }));
    tableFeaturesBuilder.setConfig(new TableConfig(true));
    tableFeaturesBuilder.setMaxEntries(65L);
    TableFeaturePropertiesBuilder propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTER);
    ExperimenterIdTableFeaturePropertyBuilder expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
    expBuilder.setExperimenter(new ExperimenterId(42L));
    propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
    List<TableFeatureProperties> properties = new ArrayList<>();
    properties.add(propBuilder.build());
    propBuilder = new TableFeaturePropertiesBuilder();
    propBuilder.setType(TableFeaturesPropType.OFPTFPTEXPERIMENTERMISS);
    expBuilder = new ExperimenterIdTableFeaturePropertyBuilder();
    expBuilder.setExperimenter(new ExperimenterId(43L));
    propBuilder.addAugmentation(ExperimenterIdTableFeatureProperty.class, expBuilder.build());
    properties.add(propBuilder.build());
    tableFeaturesBuilder.setTableFeatureProperties(properties);
    List<TableFeatures> tableFeaturesList = new ArrayList<>();
    tableFeaturesList.add(tableFeaturesBuilder.build());
    MultipartRequestTableFeaturesBuilder featuresBuilder = new MultipartRequestTableFeaturesBuilder();
    featuresBuilder.setTableFeatures(tableFeaturesList);
    MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
    caseBuilder.setMultipartRequestTableFeatures(featuresBuilder.build());
    builder.setMultipartRequestBody(caseBuilder.build());
    MultipartRequestInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, out);
    BufferHelper.checkHeaderV13(out, (byte) 18, 80);
    Assert.assertEquals("Wrong type", 12, out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort());
    out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
    Assert.assertEquals("Wrong length", 64, out.readUnsignedShort());
    Assert.assertEquals("Wrong registry-id", 8, out.readUnsignedByte());
    out.skipBytes(5);
    Assert.assertEquals("Wrong name", "AAAABBBBCCCCDDDDEEEEFFFFGGGG", ByteBufUtils.decodeNullTerminatedString(out, 32));
    byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(metadataMatch);
    Assert.assertArrayEquals("Wrong metadata-match", new byte[] { 0x00, 0x01, 0x02, 0x03, 0x01, 0x04, 0x08, 0x01 }, metadataMatch);
    byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
    out.readBytes(metadataWrite);
    Assert.assertArrayEquals("Wrong metadata-write", new byte[] { 0x00, 0x07, 0x01, 0x05, 0x01, 0x00, 0x03, 0x01 }, metadataWrite);
    Assert.assertEquals("Wrong config", 8, out.readUnsignedInt());
    Assert.assertEquals("Wrong max-entries", 65, out.readUnsignedInt());
    Mockito.verify(serializer, Mockito.times(2)).serialize(Matchers.any(TableFeatureProperties.class), Matchers.any(ByteBuf.class));
}
Also used : ExperimenterIdTableFeaturePropertyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ExperimenterIdTableFeaturePropertyBuilder) TableFeatureProperties(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties) ArrayList(java.util.ArrayList) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeaturesBuilder) MultipartRequestTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder) ByteBuf(io.netty.buffer.ByteBuf) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) MultipartRequestInputFactory(org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactory) MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestTableFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.MultipartRequestTableFeaturesCaseBuilder) MultipartRequestTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder) TableFeaturePropertiesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.multipart.request.table.features.TableFeatures) BigInteger(java.math.BigInteger) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) MultipartRequestInputFactoryTest(org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest) Test(org.junit.Test)

Example 97 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.Config in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesTest method testMultipartReplyTableFeatures.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyTableFeatures() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 0C 00 00 00 00 00 00 " + // first table feature
    "00 40 01 00 00 00 00 00 " + // length, tableId, padding
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + // 
    "00 00 00 00 00 00 00 00 00 00 00 00 00 " + // name
    "00 00 00 00 00 00 00 01 " + // metadata match
    "00 00 00 00 00 00 00 02 " + // metadata write
    "00 00 00 00 " + // config
    "00 00 00 2A " + // second table feature
    "00 40 02 00 00 00 00 00 " + // length, tableId, padding
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00" + // name
    " 00 00 00 00 00 00 00 00 00 00 00 00 00 " + // metadata match
    "00 00 00 00 00 00 00 03 " + // metadata write
    "00 00 00 00 00 00 00 04 " + // config
    "00 00 00 03 " + // max entries
    "00 00 00 2B");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
    Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size());
    TableFeatures feature = message.getTableFeatures().get(0);
    Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
    Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
    Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, feature.getMetadataMatch());
    Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, feature.getMetadataWrite());
    Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
    Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
    feature = message.getTableFeatures().get(1);
    Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue());
    Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
    Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 3 }, feature.getMetadataMatch());
    Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 4 }, feature.getMetadataWrite());
    Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK());
    Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue());
}
Also used : MultipartReplyTableFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCase) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeatures) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyTableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures) Test(org.junit.Test)

Example 98 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.Config in project openflowplugin by opendaylight.

the class PortConvertor method convert.

@Override
public PortModInput convert(Port source, VersionConvertorData data) {
    PortConfig config = maskPortConfigFields(source.getConfiguration());
    PortConfigV10 configV10 = maskPortConfigV10Fields(source.getConfiguration());
    PortModInputBuilder portModInputBuilder = new PortModInputBuilder();
    portModInputBuilder.setAdvertise(getPortFeatures(source.getAdvertisedFeatures()));
    portModInputBuilder.setPortNo(new PortNumber(OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.get(data.getVersion()), source.getPortNumber())));
    portModInputBuilder.setConfig(config);
    portModInputBuilder.setMask(MoreObjects.firstNonNull(maskPortConfigFields(source.getMask()), new PortConfig(true, true, true, true)));
    portModInputBuilder.setHwAddress(new MacAddress(source.getHardwareAddress()));
    portModInputBuilder.setVersion(data.getVersion());
    portModInputBuilder.setConfigV10(configV10);
    portModInputBuilder.setMaskV10(MoreObjects.firstNonNull(maskPortConfigV10Fields(source.getMask()), new PortConfigV10(true, true, true, true, true, true, true)));
    portModInputBuilder.setAdvertiseV10(getPortFeaturesV10(source.getAdvertisedFeatures()));
    return portModInputBuilder.build();
}
Also used : PortConfigV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10) PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)

Example 99 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.Config in project openflowplugin by opendaylight.

the class PortConvertor method toPortDesc.

/**
 * This method is called as a reply to OFPMP_PORT_DESCRIPTION message(OF1.3.1).
 *
 * @param source  FlowCapablePort
 * @param version openflow version
 * @return OF:Ports
 */
@VisibleForTesting
static Ports toPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.FlowCapablePort source, short version) {
    PortsBuilder ofPortDescDataBuilder = new PortsBuilder();
    ofPortDescDataBuilder.setPortNo(OpenflowPortsUtil.getProtocolPortNumber(OpenflowVersion.get(version), // portNO
    source.getPortNumber()));
    ofPortDescDataBuilder.setHwAddr(source.getHardwareAddress());
    ofPortDescDataBuilder.setName(source.getName());
    PortConfig config = maskPortConfigFields(source.getConfiguration());
    ofPortDescDataBuilder.setConfig(config);
    PortState portState = getPortState(source.getState());
    ofPortDescDataBuilder.setState(portState);
    ofPortDescDataBuilder.setCurrentFeatures(getPortFeatures(source.getCurrentFeature()));
    ofPortDescDataBuilder.setAdvertisedFeatures(getPortFeatures(source.getAdvertisedFeatures()));
    ofPortDescDataBuilder.setSupportedFeatures(getPortFeatures(source.getSupported()));
    ofPortDescDataBuilder.setPeerFeatures(getPortFeatures(source.getPeerFeatures()));
    ofPortDescDataBuilder.setCurrSpeed(source.getCurrentSpeed());
    ofPortDescDataBuilder.setMaxSpeed(source.getMaximumSpeed());
    return ofPortDescDataBuilder.build();
}
Also used : PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState) PortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.PortsBuilder) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 100 with Config

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.Config in project controller by opendaylight.

the class DsbenchmarkProvider method startTest.

@Override
public Future<RpcResult<StartTestOutput>> startTest(final StartTestInput input) {
    LOG.info("Starting the data store benchmark test, input: {}", input);
    // Check if there is a test in progress
    if (execStatus.compareAndSet(ExecStatus.Idle, ExecStatus.Executing) == false) {
        LOG.info("Test in progress");
        return RpcResultBuilder.success(new StartTestOutputBuilder().setStatus(StartTestOutput.Status.TESTINPROGRESS).build()).buildFuture();
    }
    // Cleanup data that may be left over from a previous test run
    cleanupTestStore();
    // Get the appropriate writer based on operation type and data format
    DatastoreAbstractWriter dsWriter = getDatastoreWriter(input);
    // Create listeners on OPERATIONAL and CONFIG test data subtrees
    listenerProvider.createAndRegisterListeners(input.getListeners().intValue());
    long startTime, endTime, listCreateTime, execTime;
    startTime = System.nanoTime();
    dsWriter.createList();
    endTime = System.nanoTime();
    listCreateTime = (endTime - startTime) / 1000;
    // Run the test and measure the execution time
    try {
        startTime = System.nanoTime();
        dsWriter.executeList();
        endTime = System.nanoTime();
        execTime = (endTime - startTime) / 1000;
        this.testsCompleted++;
    } catch (final Exception e) {
        LOG.error("Test error: {}", e.toString());
        execStatus.set(ExecStatus.Idle);
        return RpcResultBuilder.success(new StartTestOutputBuilder().setStatus(StartTestOutput.Status.FAILED).build()).buildFuture();
    }
    LOG.info("Test finished");
    setTestOperData(ExecStatus.Idle, testsCompleted);
    execStatus.set(ExecStatus.Idle);
    // Get the number of data change events and cleanup the data change listeners
    long numDataChanges = listenerProvider.getDataChangeCount();
    long numEvents = listenerProvider.getEventCountAndDestroyListeners();
    StartTestOutput output = new StartTestOutputBuilder().setStatus(StartTestOutput.Status.OK).setListBuildTime(listCreateTime).setExecTime(execTime).setTxOk((long) dsWriter.getTxOk()).setNtfOk(numEvents).setDataChangeEventsOk(numDataChanges).setTxError((long) dsWriter.getTxError()).build();
    return RpcResultBuilder.success(output).buildFuture();
}
Also used : StartTestOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestOutputBuilder) StartTestOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.StartTestOutput) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)

Aggregations

ArrayList (java.util.ArrayList)47 Test (org.junit.Test)45 BigInteger (java.math.BigInteger)29 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)23 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)23 ByteBuf (io.netty.buffer.ByteBuf)21 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)21 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)20 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)19 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)19 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)19 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)16 ExecutionException (java.util.concurrent.ExecutionException)16 Optional (com.google.common.base.Optional)15 List (java.util.List)15 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)14 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)14 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)14 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)12 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)12