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