use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImplTest method testAddMissingFlows_withUpdate.
@Test
public void testAddMissingFlows_withUpdate() throws Exception {
Mockito.when(flowCommitter.add(Matchers.<InstanceIdentifier<Flow>>any(), flowCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
Mockito.when(flowCommitter.update(Matchers.<InstanceIdentifier<Flow>>any(), flowUpdateCaptor.capture(), flowUpdateCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new UpdateFlowOutputBuilder().build()).buildFuture());
final ItemSyncBox<Flow> flowBox = new ItemSyncBox<>();
flowBox.getItemsToPush().add(DSInputFactory.createFlow("f3", 3));
flowBox.getItemsToPush().add(DSInputFactory.createFlow("f4", 4));
flowBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(DSInputFactory.createFlow("f1", 1), DSInputFactory.createFlowWithInstruction("f1", 1)));
final Map<TableKey, ItemSyncBox<Flow>> flowBoxMap = new LinkedHashMap<>();
flowBoxMap.put(new TableKey((short) 0), flowBox);
// TODO: replace null
final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.addMissingFlows(NODE_ID, NODE_IDENT, flowBoxMap, counters);
Assert.assertTrue(result.isDone());
Assert.assertTrue(result.get().isSuccessful());
final List<Flow> flowCaptorAllValues = flowCaptor.getAllValues();
Assert.assertEquals(2, flowCaptorAllValues.size());
Assert.assertEquals("f3", flowCaptorAllValues.get(0).getId().getValue());
Assert.assertEquals("f4", flowCaptorAllValues.get(1).getId().getValue());
final List<Flow> flowUpdateCaptorAllValues = flowUpdateCaptor.getAllValues();
Assert.assertEquals(2, flowUpdateCaptorAllValues.size());
Assert.assertEquals("f1", flowUpdateCaptorAllValues.get(0).getId().getValue());
Assert.assertEquals("f1", flowUpdateCaptorAllValues.get(1).getId().getValue());
final InOrder inOrderFlow = Mockito.inOrder(flowCapableTxService, flowCommitter);
// add f3, f4
inOrderFlow.verify(flowCommitter, Mockito.times(2)).add(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.eq(NODE_IDENT));
// update f1
inOrderFlow.verify(flowCommitter).update(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.<Flow>any(), Matchers.eq(NODE_IDENT));
// TODO: uncomment when enabled in impl
// inOrderFlow.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
inOrderFlow.verifyNoMoreInteractions();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder in project openflowplugin by opendaylight.
the class SalFlowsBatchServiceImplTest method testUpdateFlowsBatch_success.
@Test
public void testUpdateFlowsBatch_success() throws Exception {
Mockito.when(salFlowService.updateFlow(Matchers.<UpdateFlowInput>any())).thenReturn(RpcResultBuilder.success(new UpdateFlowOutputBuilder().build()).buildFuture());
final UpdateFlowsBatchInput input = new UpdateFlowsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchUpdateFlows(Lists.newArrayList(createEmptyBatchUpdateFlow(FLOW_ID_VALUE_1, 42), createEmptyBatchUpdateFlow(FLOW_ID_VALUE_2, 44))).build();
final Future<RpcResult<UpdateFlowsBatchOutput>> resultFuture = salFlowsBatchService.updateFlowsBatch(input);
Assert.assertTrue(resultFuture.isDone());
Assert.assertTrue(resultFuture.get().isSuccessful());
final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
inOrder.verify(salFlowService, Mockito.times(2)).updateFlow(updateFlowInputCpt.capture());
final List<UpdateFlowInput> allValues = updateFlowInputCpt.getAllValues();
Assert.assertEquals(2, allValues.size());
Assert.assertEquals(42, allValues.get(0).getOriginalFlow().getPriority().longValue());
Assert.assertEquals(43, allValues.get(0).getUpdatedFlow().getPriority().longValue());
Assert.assertEquals(44, allValues.get(1).getOriginalFlow().getPriority().longValue());
Assert.assertEquals(45, allValues.get(1).getUpdatedFlow().getPriority().longValue());
inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder in project openflowplugin by opendaylight.
the class FlowForwarderTest method updateTest.
@Test
public void updateTest() throws Exception {
Mockito.when(salFlowService.updateFlow(updateFlowInputCpt.capture())).thenReturn(RpcResultBuilder.success(new UpdateFlowOutputBuilder().setTransactionId(new TransactionId(BigInteger.ONE)).build()).buildFuture());
final Instructions originalInstructions = new InstructionsBuilder().setInstruction(Collections.singletonList(new InstructionBuilder().setInstruction(new ApplyActionsCaseBuilder().setApplyActions(new ApplyActionsBuilder().setAction(Collections.singletonList(new ActionBuilder().setAction(new DropActionCaseBuilder().build()).build())).build()).build()).build())).build();
final Flow flowUpdated = new FlowBuilder(flow).setInstructions(originalInstructions).setMatch(new MatchBuilder().build()).build();
final Future<RpcResult<UpdateFlowOutput>> updateResult = flowForwarder.update(flowPath, flow, flowUpdated, flowCapableNodePath);
Mockito.verify(salFlowService).updateFlow(Matchers.<UpdateFlowInput>any());
final UpdateFlowInput updateFlowInput = updateFlowInputCpt.getValue();
final OriginalFlow flowOrigInput = updateFlowInput.getOriginalFlow();
final UpdatedFlow flowInput = updateFlowInput.getUpdatedFlow();
Assert.assertEquals(nodePath, updateFlowInput.getNode().getValue());
Assert.assertEquals(flowPath, updateFlowInput.getFlowRef().getValue());
Assert.assertEquals(2, flowInput.getTableId().shortValue());
Assert.assertEquals(emptyMatch, flowInput.getMatch());
Assert.assertEquals(originalInstructions, flowInput.getInstructions());
Assert.assertEquals(true, flowInput.isStrict());
Assert.assertEquals(2, flowOrigInput.getTableId().shortValue());
Assert.assertEquals(emptyMatch, flowOrigInput.getMatch());
Assert.assertEquals(null, flowOrigInput.getInstructions());
Assert.assertEquals(true, flowOrigInput.isStrict());
final RpcResult<UpdateFlowOutput> updateFlowOutputRpcResult = updateResult.get(2, TimeUnit.SECONDS);
Assert.assertTrue(updateFlowOutputRpcResult.isSuccessful());
final UpdateFlowOutput resultValue = updateFlowOutputRpcResult.getResult();
Assert.assertEquals(1, resultValue.getTransactionId().getValue().intValue());
}
Aggregations