use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFactoryTest method testTable.
/**
* Testing OF10StatsRequestInputFactory (Table) for correct serialization.
*/
@Test
public void testTable() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setType(MultipartType.OFPMPTABLE);
builder.setFlags(new MultipartRequestFlags(false));
MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder();
MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder();
caseBuilder.setMultipartRequestTable(tableBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV10(out, (byte) 16, 12);
Assert.assertEquals("Wrong type", 3, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder in project openflowplugin by opendaylight.
the class OF10StatsRequestInputTableFactoryTest method createMultipartRequestBody.
private static MultipartRequestBody createMultipartRequestBody() {
MultipartRequestTableCaseBuilder caseBuilder = new MultipartRequestTableCaseBuilder();
MultipartRequestTableBuilder tableBuilder = new MultipartRequestTableBuilder();
tableBuilder.setEmpty(true);
caseBuilder.setMultipartRequestTable(tableBuilder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder in project openflowplugin by opendaylight.
the class FlowListenerTest method updateFlowTest.
@Test
public void updateFlowTest() throws Exception {
addFlowCapableNode(NODE_KEY);
FlowKey flowKey = new FlowKey(new FlowId("test_Flow"));
InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
Table table = new TableBuilder().setKey(tableKey).setFlow(Collections.<Flow>emptyList()).build();
Flow flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
assertCommit(writeTx.submit());
SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
List<AddFlowInput> addFlowCalls = salFlowService.getAddFlowCalls();
assertEquals(1, addFlowCalls.size());
assertEquals("DOM-0", addFlowCalls.get(0).getTransactionUri().getValue());
flowKey = new FlowKey(new FlowId("test_Flow"));
flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).setOutGroup((long) 5).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
assertCommit(writeTx.submit());
salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
List<UpdateFlowInput> updateFlowCalls = salFlowService.getUpdateFlowCalls();
assertEquals(1, updateFlowCalls.size());
assertEquals("DOM-1", updateFlowCalls.get(0).getTransactionUri().getValue());
assertEquals(flowII, updateFlowCalls.get(0).getFlowRef().getValue());
assertEquals(Boolean.TRUE, updateFlowCalls.get(0).getOriginalFlow().isStrict());
assertEquals(Boolean.TRUE, updateFlowCalls.get(0).getUpdatedFlow().isStrict());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder in project openflowplugin by opendaylight.
the class FlowListenerTest method addTwoFlowsTest.
@Test
public void addTwoFlowsTest() throws Exception {
addFlowCapableNode(NODE_KEY);
FlowKey flowKey = new FlowKey(new FlowId("test_Flow"));
InstanceIdentifier<Table> tableII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey);
InstanceIdentifier<Flow> flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
Table table = new TableBuilder().setKey(tableKey).setFlow(Collections.<Flow>emptyList()).build();
Flow flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, tableII, table);
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
assertCommit(writeTx.submit());
SalFlowServiceMock salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
List<AddFlowInput> addFlowCalls = salFlowService.getAddFlowCalls();
assertEquals(1, addFlowCalls.size());
assertEquals("DOM-0", addFlowCalls.get(0).getTransactionUri().getValue());
flowKey = new FlowKey(new FlowId("test_Flow2"));
flowII = InstanceIdentifier.create(Nodes.class).child(Node.class, NODE_KEY).augmentation(FlowCapableNode.class).child(Table.class, tableKey).child(Flow.class, flowKey);
flow = new FlowBuilder().setKey(flowKey).setTableId((short) 2).build();
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, flowII, flow);
assertCommit(writeTx.submit());
salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
addFlowCalls = salFlowService.getAddFlowCalls();
assertEquals(2, addFlowCalls.size());
assertEquals("DOM-1", addFlowCalls.get(1).getTransactionUri().getValue());
assertEquals(2, addFlowCalls.get(1).getTableId().intValue());
assertEquals(flowII, addFlowCalls.get(1).getFlowRef().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder in project openflowplugin by opendaylight.
the class SyncReactorImplTest method testSyncup.
@Test
public void testSyncup() throws Exception {
final FlowCapableNode configFcn = new FlowCapableNodeBuilder().setGroup(Collections.singletonList(DSInputFactory.createGroup(1L))).setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(DSInputFactory.createFlow("f1", 1))).build())).setMeter(Collections.singletonList(DSInputFactory.createMeter(1L))).build();
final FlowCapableNode operationalFcn = new FlowCapableNodeBuilder().setGroup(Collections.singletonList(DSInputFactory.createGroup(2L))).setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(DSInputFactory.createFlow("f2", 2))).build())).setMeter(Collections.singletonList(DSInputFactory.createMeter(2L))).build();
final SyncupEntry syncupEntry = new SyncupEntry(configFcn, LogicalDatastoreType.CONFIGURATION, operationalFcn, LogicalDatastoreType.OPERATIONAL);
Mockito.when(syncPlanPushStrategy.executeSyncStrategy(Matchers.<ListenableFuture<RpcResult<Void>>>any(), Matchers.<SynchronizationDiffInput>any(), Matchers.<SyncCrudCounters>any())).thenReturn(RpcResultBuilder.<Void>success().buildFuture());
final ListenableFuture<Boolean> syncupResult = reactor.syncup(NODE_IDENT, syncupEntry);
Assert.assertTrue(syncupResult.isDone());
final Boolean voidRpcResult = syncupResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(voidRpcResult);
Mockito.verify(syncPlanPushStrategy).executeSyncStrategy(Matchers.<ListenableFuture<RpcResult<Void>>>any(), syncDiffInputCaptor.capture(), Matchers.<SyncCrudCounters>any());
final SynchronizationDiffInput diffInput = syncDiffInputCaptor.getValue();
Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getFlowsToAddOrUpdate().values()));
Assert.assertEquals(0, ReconcileUtil.countTotalUpdated(diffInput.getFlowsToAddOrUpdate().values()));
Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getFlowsToRemove().values()));
Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getGroupsToAddOrUpdate()));
Assert.assertEquals(0, ReconcileUtil.countTotalUpdated(diffInput.getGroupsToAddOrUpdate()));
Assert.assertEquals(1, ReconcileUtil.countTotalPushed(diffInput.getGroupsToRemove()));
Assert.assertEquals(1, diffInput.getMetersToAddOrUpdate().getItemsToPush().size());
Assert.assertEquals(0, diffInput.getMetersToAddOrUpdate().getItemsToUpdate().size());
Assert.assertEquals(1, diffInput.getMetersToRemove().getItemsToPush().size());
}
Aggregations