Search in sources :

Example 1 with TableFeatures

use of 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 in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImplTest method testUpdateTableFeatures.

@Test
public void testUpdateTableFeatures() throws Exception {
    Mockito.when(tableCommitter.update(Matchers.<InstanceIdentifier<TableFeatures>>any(), Matchers.isNull(TableFeatures.class), tableFeaturesCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateTableOutputBuilder().build()).buildFuture());
    final FlowCapableNode operational = new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setId((short) 1).build())).setTableFeatures(Collections.singletonList(new TableFeaturesBuilder().setName("test table features").setTableId((short) 1).build())).build();
    final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.updateTableFeatures(NODE_IDENT, operational);
    Assert.assertTrue(result.isDone());
    Assert.assertTrue(result.get().isSuccessful());
    final List<TableFeatures> groupCaptorAllValues = tableFeaturesCaptor.getAllValues();
    // TODO: uncomment when enabled in impl
    // Assert.assertEquals(1, groupCaptorAllValues.size());
    // Assert.assertEquals("test table features", groupCaptorAllValues.get(0).getName());
    // Assert.assertEquals(1, groupCaptorAllValues.get(0).getTableId().intValue());
    Mockito.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Also used : TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) UpdateTableOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder) Test(org.junit.Test)

Example 2 with TableFeatures

use of 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 in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImplTest method setUp.

@Before
public void setUp() throws Exception {
    Mockito.when(flowCapableTxService.sendBarrier(Matchers.<SendBarrierInput>any())).thenReturn(RpcResultBuilder.success((Void) null).buildFuture());
    Mockito.doAnswer(createSalServiceFutureAnswer()).when(groupCommitter).add(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.doAnswer(createSalServiceFutureAnswer()).when(groupCommitter).update(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.doAnswer(createSalServiceFutureAnswer()).when(groupCommitter).remove(Matchers.<InstanceIdentifier<Group>>any(), Matchers.<Group>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.doAnswer(createSalServiceFutureAnswer()).when(flowCommitter).add(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.doAnswer(createSalServiceFutureAnswer()).when(flowCommitter).update(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.doAnswer(createSalServiceFutureAnswer()).when(flowCommitter).remove(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.doAnswer(createSalServiceFutureAnswer()).when(meterCommitter).add(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.doAnswer(createSalServiceFutureAnswer()).when(meterCommitter).update(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.doAnswer(createSalServiceFutureAnswer()).when(meterCommitter).remove(Matchers.<InstanceIdentifier<Meter>>any(), Matchers.<Meter>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    Mockito.doAnswer(createSalServiceFutureAnswer()).when(tableCommitter).update(Matchers.<InstanceIdentifier<TableFeatures>>any(), Matchers.<TableFeatures>any(), Matchers.<TableFeatures>any(), Matchers.<InstanceIdentifier<FlowCapableNode>>any());
    syncPlanPushStrategy = new SyncPlanPushStrategyIncrementalImpl().setMeterForwarder(meterCommitter).setTableForwarder(tableCommitter).setGroupForwarder(groupCommitter).setFlowForwarder(flowCommitter).setTransactionService(flowCapableTxService);
    counters = new SyncCrudCounters();
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Meter(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) SyncCrudCounters(org.opendaylight.openflowplugin.applications.frsync.util.SyncCrudCounters) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) Before(org.junit.Before)

Example 3 with TableFeatures

use of 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 in project openflowplugin by opendaylight.

the class TableForwarderTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    Mockito.when(salTableService.updateTable(updateTableInputCpt.capture())).thenReturn(RpcResultBuilder.success(new UpdateTableOutputBuilder().setTransactionId(txId).build()).buildFuture());
    final TableFeatures tableFeaturesUpdate = new TableFeaturesBuilder(tableFeatures).setName("another-table").build();
    final Future<RpcResult<UpdateTableOutput>> updateResult = tableForwarder.update(tableFeaturesPath, tableFeatures, tableFeaturesUpdate, flowCapableNodePath);
    Mockito.verify(salTableService).updateTable(Matchers.<UpdateTableInput>any());
    Assert.assertTrue(updateResult.isDone());
    final RpcResult<UpdateTableOutput> updateTableResult = updateResult.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(updateTableResult.isSuccessful());
    Assert.assertEquals(1, updateTableResult.getResult().getTransactionId().getValue().intValue());
    final UpdateTableInput updateTableInput = updateTableInputCpt.getValue();
    Assert.assertEquals(tablePath, updateTableInput.getTableRef().getValue());
    Assert.assertEquals(nodePath, updateTableInput.getNode().getValue());
    Assert.assertEquals(1, updateTableInput.getOriginalTable().getTableFeatures().size());
    Assert.assertEquals("test-table", updateTableInput.getOriginalTable().getTableFeatures().get(0).getName());
    Assert.assertEquals(1, updateTableInput.getUpdatedTable().getTableFeatures().size());
    Assert.assertEquals("another-table", updateTableInput.getUpdatedTable().getTableFeatures().get(0).getName());
}
Also used : UpdateTableOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder) UpdateTableInput(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput) UpdateTableOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder) Test(org.junit.Test)

Example 4 with TableFeatures

use of 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 in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesDeserializer method deserialize.

@Override
public MultipartReplyBody deserialize(ByteBuf message) {
    final MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
    final List<TableFeatures> items = new ArrayList<>();
    while (message.readableBytes() > 0) {
        final int itemLength = message.readUnsignedShort();
        final TableFeaturesBuilder itemBuilder = new TableFeaturesBuilder().setTableId(message.readUnsignedByte());
        message.skipBytes(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
        final String name = ByteBufUtils.decodeNullTerminatedString(message, MAX_TABLE_NAME_LENGTH);
        final byte[] match = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        message.readBytes(match);
        final byte[] write = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
        message.readBytes(write);
        items.add(itemBuilder.setKey(new TableFeaturesKey(itemBuilder.getTableId())).setName(name).setMetadataMatch(new BigInteger(1, match)).setMetadataWrite(new BigInteger(1, write)).setConfig(readTableConfig(message)).setMaxEntries(message.readUnsignedInt()).setTableProperties(readTableProperties(message, itemLength - MULTIPART_REPLY_TABLE_FEATURES_STRUCTURE_LENGTH)).build());
    }
    return builder.setTableFeatures(items).build();
}
Also used : TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures) TableFeaturesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey) ArrayList(java.util.ArrayList) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder) BigInteger(java.math.BigInteger) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesBuilder)

Example 5 with TableFeatures

use of 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 in project openflowplugin by opendaylight.

the class TableFeaturesResponseConvertorTest method testWithMPTableFeature.

/**
 * Test correct input - without table properties.
 */
@Test
public void testWithMPTableFeature() {
    TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
    featuresBuilder.setTableId((short) 5);
    featuresBuilder.setName("Aloha");
    byte[] metaMatch = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 };
    featuresBuilder.setMetadataMatch(metaMatch);
    byte[] metaWrite = new byte[] { 8, 9, 10, 11, 12, 13, 14, 15 };
    featuresBuilder.setMetadataWrite(metaWrite);
    featuresBuilder.setConfig(new TableConfig(false));
    featuresBuilder.setMaxEntries(42L);
    List<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> features = new ArrayList<>();
    features.add(featuresBuilder.build());
    MultipartReplyTableFeaturesBuilder builder = new MultipartReplyTableFeaturesBuilder();
    builder.setTableFeatures(features);
    List<TableFeatures> list = convert(builder.build());
    Assert.assertEquals("Returned empty list", 1, list.size());
    TableFeatures feature = list.get(0);
    Assert.assertEquals("Wrong table-id", 5, feature.getTableId().intValue());
    Assert.assertEquals("Wrong name", "Aloha", feature.getName());
    Assert.assertEquals("Wrong metadata match", new BigInteger(1, metaMatch), feature.getMetadataMatch());
    Assert.assertEquals("Wrong metadata write", new BigInteger(1, metaWrite), feature.getMetadataWrite());
    Assert.assertEquals("Wrong config", false, feature.getConfig().isDEPRECATEDMASK());
    Assert.assertEquals("Wrong max-entries", 42, feature.getMaxEntries().intValue());
    Assert.assertEquals("Wrong properties", 0, feature.getTableProperties().getTableFeatureProperties().size());
}
Also used : ArrayList(java.util.ArrayList) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) TableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder) MultipartReplyTableFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder) TableFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.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) TableConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)13 TableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures)13 Test (org.junit.Test)12 BigInteger (java.math.BigInteger)8 MultipartReplyTableFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeatures)8 TableConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableConfig)7 ByteBuf (io.netty.buffer.ByteBuf)6 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)6 TableFeatureProperties (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties)6 MultipartReplyTableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder)5 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)5 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)5 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)4 NextTableIds (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.table.features.properties.container.table.feature.properties.NextTableIds)4 TableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder)4 MultipartRequestTableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.table.features._case.MultipartRequestTableFeaturesBuilder)4 TableFeaturePropertiesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeaturePropertiesBuilder)4 UpdatedTableBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder)4 TableFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder)4 ActionRelatedTableFeaturePropertyBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev150225.ActionRelatedTableFeaturePropertyBuilder)3