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());
}
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();
}
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());
}
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();
}
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());
}
Aggregations