Search in sources :

Example 1 with RemoveFlowInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput 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 RemoveFlowInput

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

the class SalFlowServiceImplTest method removeFlow.

private void removeFlow(short version) throws Exception {
    RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder().setMatch(match).setTableId((short) 1).build();
    SalFlowServiceImpl salFlowService = mockSalFlowService(version);
    verifyOutput(salFlowService.removeFlow(mockedRemoveFlowInput));
}
Also used : RemoveFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput) RemoveFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder)

Example 3 with RemoveFlowInput

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

the class FlowConvertorTest method test.

/**
 * Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
 */
@Test
public void test() {
    RemoveFlowInputBuilder flowBuilder = new RemoveFlowInputBuilder();
    flowBuilder.setBarrier(false);
    flowBuilder.setCookie(new FlowCookie(new BigInteger("4")));
    flowBuilder.setCookieMask(new FlowCookie(new BigInteger("5")));
    flowBuilder.setTableId((short) 6);
    flowBuilder.setStrict(true);
    flowBuilder.setIdleTimeout(50);
    flowBuilder.setHardTimeout(500);
    flowBuilder.setPriority(40);
    flowBuilder.setBufferId(18L);
    flowBuilder.setOutPort(new BigInteger("65535"));
    flowBuilder.setOutGroup(5000L);
    flowBuilder.setFlags(null);
    flowBuilder.setMatch(null);
    RemoveFlowInput flow = flowBuilder.build();
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
    data.setDatapathId(new BigInteger("42"));
    List<FlowModInputBuilder> flowMod = convert(flow, data);
    Assert.assertEquals("Wrong version", 4, flowMod.get(0).getVersion().intValue());
    Assert.assertEquals("Wrong cookie", 4, flowMod.get(0).getCookie().intValue());
    Assert.assertEquals("Wrong cookie mask", 5, flowMod.get(0).getCookieMask().intValue());
    Assert.assertEquals("Wrong table id", 6, flowMod.get(0).getTableId().getValue().intValue());
    Assert.assertEquals("Wrong command", FlowModCommand.OFPFCDELETESTRICT, flowMod.get(0).getCommand());
    Assert.assertEquals("Wrong idle timeout", 50, flowMod.get(0).getIdleTimeout().intValue());
    Assert.assertEquals("Wrong hard timeout", 500, flowMod.get(0).getHardTimeout().intValue());
    Assert.assertEquals("Wrong priority", 40, flowMod.get(0).getPriority().intValue());
    Assert.assertEquals("Wrong buffer id", 18, flowMod.get(0).getBufferId().intValue());
    Assert.assertEquals("Wrong out port", 65535, flowMod.get(0).getOutPort().getValue().intValue());
    Assert.assertEquals("Wrong out group", 5000, flowMod.get(0).getOutGroup().intValue());
    Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowMod.get(0).getFlags());
    Assert.assertEquals("Wrong match", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType", flowMod.get(0).getMatch().getType().getName());
    Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().getMatchEntry().size());
}
Also used : FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags) RemoveFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput) RemoveFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder) BigInteger(java.math.BigInteger) FlowModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder) Test(org.junit.Test)

Example 4 with RemoveFlowInput

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

the class FlowListenerTest method deleteFlowTest.

@Test
public void deleteFlowTest() 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());
    writeTx = getDataBroker().newWriteOnlyTransaction();
    writeTx.delete(LogicalDatastoreType.CONFIGURATION, flowII);
    assertCommit(writeTx.submit());
    salFlowService = (SalFlowServiceMock) forwardingRulesManager.getSalFlowService();
    List<RemoveFlowInput> removeFlowCalls = salFlowService.getRemoveFlowCalls();
    assertEquals(1, removeFlowCalls.size());
    assertEquals("DOM-1", removeFlowCalls.get(0).getTransactionUri().getValue());
    assertEquals(flowII, removeFlowCalls.get(0).getFlowRef().getValue());
    assertEquals(Boolean.TRUE, removeFlowCalls.get(0).isStrict());
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) StaleFlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowKey) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) Nodes(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) StaleFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlow) SalFlowServiceMock(test.mock.util.SalFlowServiceMock) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) StaleFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.StaleFlowBuilder) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) RemoveFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput) FRMTest(test.mock.util.FRMTest) Test(org.junit.Test)

Example 5 with RemoveFlowInput

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

the class SalFlowsBatchServiceImplTest method testRemoveFlowsBatch_failed.

@Test
public void testRemoveFlowsBatch_failed() throws Exception {
    Mockito.when(salFlowService.removeFlow(Matchers.<RemoveFlowInput>any())).thenReturn(RpcResultBuilder.<RemoveFlowOutput>failed().withError(RpcError.ErrorType.APPLICATION, "flow-remove-fail-1").buildFuture());
    final BatchRemoveFlows batchFlow1 = createEmptyBatchRemoveFlow(FLOW_ID_VALUE_1, 42);
    final BatchRemoveFlows batchFlow2 = createEmptyBatchRemoveFlow(FLOW_ID_VALUE_2, 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.assertFalse(rpcResult.isSuccessful());
    final RemoveFlowsBatchOutput result = rpcResult.getResult();
    Assert.assertEquals(2, result.getBatchFailedFlowsOutput().size());
    Assert.assertEquals(FLOW_ID_VALUE_1, result.getBatchFailedFlowsOutput().get(0).getFlowId().getValue());
    Assert.assertEquals(FLOW_ID_VALUE_2, result.getBatchFailedFlowsOutput().get(1).getFlowId().getValue());
    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) 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

RemoveFlowInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)8 Test (org.junit.Test)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)5 RemoveFlowInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder)4 RemoveFlowOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutputBuilder)3 ArrayList (java.util.ArrayList)2 InOrder (org.mockito.InOrder)2 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)2 FlowBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder)2 RemoveFlowOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput)2 RemoveFlowsBatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchInput)2 RemoveFlowsBatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchInputBuilder)2 RemoveFlowsBatchOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.RemoveFlowsBatchOutput)2 BatchRemoveFlows (org.opendaylight.yang.gen.v1.urn.opendaylight.flows.service.rev160314.remove.flows.batch.input.BatchRemoveFlows)2 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 BigInteger (java.math.BigInteger)1 ExecutionException (java.util.concurrent.ExecutionException)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)1