Search in sources :

Example 1 with RemoveFlowOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder in project openflowplugin by opendaylight.

the class FlowForwarderTest method removeTest.

@Test
public void removeTest() throws Exception {
    Mockito.when(salFlowService.removeFlow(removeFlowInputCpt.capture())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().setTransactionId(new TransactionId(BigInteger.ONE)).build()).buildFuture());
    final Flow removeFlow = new FlowBuilder(flow).build();
    final Future<RpcResult<RemoveFlowOutput>> removeResult = flowForwarder.remove(flowPath, removeFlow, flowCapableNodePath);
    Mockito.verify(salFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
    final RemoveFlowInput flowInput = removeFlowInputCpt.getValue();
    Assert.assertEquals(2, flowInput.getTableId().shortValue());
    Assert.assertEquals(emptyMatch, flowInput.getMatch());
    Assert.assertEquals(null, flowInput.getInstructions());
    Assert.assertEquals(true, flowInput.isStrict());
    final RpcResult<RemoveFlowOutput> removeFlowOutputRpcResult = removeResult.get(2, TimeUnit.SECONDS);
    Assert.assertTrue(removeFlowOutputRpcResult.isSuccessful());
    final RemoveFlowOutput resultValue = removeFlowOutputRpcResult.getResult();
    Assert.assertEquals(1, resultValue.getTransactionId().getValue().intValue());
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) RemoveFlowOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput) RemoveFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder) RemoveFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TransactionId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) UpdatedFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow) OriginalFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow) Test(org.junit.Test)

Example 2 with RemoveFlowOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder in project openflowplugin by opendaylight.

the class SalBulkFlowServiceImplTest method testAddRemoveFlowsRpc.

@Test
public void testAddRemoveFlowsRpc() throws Exception {
    Mockito.when(mockSalFlowService.addFlow(Matchers.<AddFlowInput>any())).thenReturn(RpcResultBuilder.success(new AddFlowOutputBuilder().build()).buildFuture());
    Mockito.when(mockSalFlowService.removeFlow(Matchers.<RemoveFlowInput>any())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
    final BulkFlowItemBuilder bulkFlowItemBuilder = new BulkFlowItemBuilder();
    final InstanceIdentifier<Node> nodeId = BulkOMaticUtils.getFlowCapableNodeId("1");
    bulkFlowItemBuilder.setNode(new NodeRef(nodeId));
    final BulkFlowItem bulkFlowItem = bulkFlowItemBuilder.build();
    final List<BulkFlowItem> bulkFlowItems = new ArrayList<>();
    bulkFlowItems.add(bulkFlowItem);
    final AddFlowsRpcInputBuilder addFlowsRpcInputBuilder = new AddFlowsRpcInputBuilder();
    addFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
    final AddFlowsRpcInput addFlowsRpcInput = addFlowsRpcInputBuilder.build();
    salBulkFlowService.addFlowsRpc(addFlowsRpcInput);
    verify(mockSalFlowService).addFlow(Matchers.<AddFlowInput>any());
    final RemoveFlowsRpcInputBuilder removeFlowsRpcInputBuilder = new RemoveFlowsRpcInputBuilder();
    removeFlowsRpcInputBuilder.setBulkFlowItem(bulkFlowItems);
    final RemoveFlowsRpcInput removeFlowsRpcInput = removeFlowsRpcInputBuilder.build();
    salBulkFlowService.removeFlowsRpc(removeFlowsRpcInput);
    verify(mockSalFlowService).removeFlow(Matchers.<RemoveFlowInput>any());
}
Also used : BulkFlowItemBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItemBuilder) BulkFlowItem(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItem) RemoveFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) ArrayList(java.util.ArrayList) AddFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder) RemoveFlowsRpcInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInput) NodeRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef) AddFlowsRpcInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInputBuilder) AddFlowsRpcInput(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput) RemoveFlowsRpcInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInputBuilder) Test(org.junit.Test)

Example 3 with RemoveFlowOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder in project openflowplugin by opendaylight.

the class SyncPlanPushStrategyIncrementalImplTest method testRemoveRedundantFlows.

@Test
public void testRemoveRedundantFlows() throws Exception {
    Mockito.when(flowCommitter.remove(Matchers.<InstanceIdentifier<Flow>>any(), flowCaptor.capture(), Matchers.same(NODE_IDENT))).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
    final ItemSyncBox<Flow> flowBox = new ItemSyncBox<>();
    flowBox.getItemsToPush().add(DSInputFactory.createFlow("f3", 3));
    flowBox.getItemsToPush().add(DSInputFactory.createFlow("f4", 4));
    final Map<TableKey, ItemSyncBox<Flow>> flowBoxMap = new LinkedHashMap<>();
    flowBoxMap.put(new TableKey((short) 0), flowBox);
    final ListenableFuture<RpcResult<Void>> result = syncPlanPushStrategy.removeRedundantFlows(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 InOrder inOrderFlow = Mockito.inOrder(flowCapableTxService, flowCommitter);
    inOrderFlow.verify(flowCommitter, Mockito.times(2)).remove(Matchers.<InstanceIdentifier<Flow>>any(), Matchers.<Flow>any(), Matchers.eq(NODE_IDENT));
    inOrderFlow.verify(flowCapableTxService).sendBarrier(Matchers.<SendBarrierInput>any());
    inOrderFlow.verifyNoMoreInteractions();
}
Also used : InOrder(org.mockito.InOrder) ItemSyncBox(org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox) RemoveFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 4 with RemoveFlowOutputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder in project openflowplugin by opendaylight.

the class SalFlowsBatchServiceImplTest method testRemoveFlowsBatch_success.

@Test
public void testRemoveFlowsBatch_success() throws Exception {
    Mockito.when(salFlowService.removeFlow(Matchers.<RemoveFlowInput>any())).thenReturn(RpcResultBuilder.success(new RemoveFlowOutputBuilder().build()).buildFuture());
    final String flow1IdValue = "ut-dummy-flow1";
    final String flow2IdValue = "ut-dummy-flow2";
    final BatchRemoveFlows batchFlow1 = createEmptyBatchRemoveFlow(flow1IdValue, 42);
    final BatchRemoveFlows batchFlow2 = createEmptyBatchRemoveFlow(flow2IdValue, 43);
    final RemoveFlowsBatchInput input = new RemoveFlowsBatchInputBuilder().setNode(NODE_REF).setBarrierAfter(true).setBatchRemoveFlows(Lists.newArrayList(batchFlow1, batchFlow2)).build();
    final Future<RpcResult<RemoveFlowsBatchOutput>> resultFuture = salFlowsBatchService.removeFlowsBatch(input);
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<RemoveFlowsBatchOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    final RemoveFlowsBatchOutput result = rpcResult.getResult();
    Assert.assertEquals(0, result.getBatchFailedFlowsOutput().size());
    final InOrder inOrder = Mockito.inOrder(salFlowService, transactionService);
    inOrder.verify(salFlowService, Mockito.times(2)).removeFlow(removeFlowInputCpt.capture());
    final List<RemoveFlowInput> allValues = removeFlowInputCpt.getAllValues();
    Assert.assertEquals(2, allValues.size());
    Assert.assertEquals(42, allValues.get(0).getPriority().longValue());
    Assert.assertEquals(43, allValues.get(1).getPriority().longValue());
    inOrder.verify(transactionService).sendBarrier(Matchers.<SendBarrierInput>any());
}
Also used : RemoveFlowsBatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchInputBuilder) InOrder(org.mockito.InOrder) RemoveFlowsBatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchOutput) RemoveFlowOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder) RemoveFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) BatchRemoveFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.remove.flows.batch.input.BatchRemoveFlows) RemoveFlowsBatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchInput) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 RemoveFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder)4 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)3 InOrder (org.mockito.InOrder)2 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)2 RemoveFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 ItemSyncBox (org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox)1 AddFlowsRpcInput (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInput)1 AddFlowsRpcInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.AddFlowsRpcInputBuilder)1 RemoveFlowsRpcInput (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInput)1 RemoveFlowsRpcInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.RemoveFlowsRpcInputBuilder)1 BulkFlowItem (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItem)1 BulkFlowItemBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.bulk.flow.service.rev150608.bulk.flow.list.grouping.BulkFlowItemBuilder)1 TableKey (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey)1 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)1 AddFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutputBuilder)1 RemoveFlowOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput)1 OriginalFlow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow)1