use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project openflowplugin by opendaylight.
the class FlowDirectStatisticsServiceTest method setUp.
@Override
public void setUp() throws Exception {
service = new FlowDirectStatisticsService(requestContextStack, deviceContext, convertorManager, multipartWriterProvider);
final DeviceFlowRegistry registry = mock(DeviceFlowRegistry.class);
when(registry.retrieveDescriptor(any())).thenReturn(FlowDescriptorFactory.create(TABLE_NO, new FlowId("1")));
when(deviceContext.getDeviceFlowRegistry()).thenReturn(registry);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project openflowplugin by opendaylight.
the class DeviceFlowRegistryImplTest method testStoreIfNecessary.
@Test
public void testStoreIfNecessary() throws Exception {
FlowId newFlowId;
// store existing key
deviceFlowRegistry.store(key);
newFlowId = deviceFlowRegistry.retrieveDescriptor(key).getFlowId();
Assert.assertEquals(1, deviceFlowRegistry.getAllFlowDescriptors().size());
Assert.assertEquals(descriptor, deviceFlowRegistry.retrieveDescriptor(key));
Assert.assertEquals(descriptor.getFlowId(), newFlowId);
// store new key
final String alienPrefix = "#UF$TABLE*2-";
final FlowRegistryKey key2 = FlowRegistryKeyFactory.create(OFConstants.OFP_VERSION_1_3, TestFlowHelper.createFlowAndStatisticsMapListBuilder(2).build());
deviceFlowRegistry.store(key2);
newFlowId = deviceFlowRegistry.retrieveDescriptor(key2).getFlowId();
Assert.assertTrue(newFlowId.getValue().startsWith(alienPrefix));
Assert.assertTrue(deviceFlowRegistry.retrieveDescriptor(key2).getFlowId().getValue().startsWith(alienPrefix));
Assert.assertEquals(2, deviceFlowRegistry.getAllFlowDescriptors().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testGatherStatistics_flow.
@Test
public void testGatherStatistics_flow() throws Exception {
final short tableId = 0;
final MultipartType type = MultipartType.OFPMPFLOW;
final InstanceIdentifier<FlowCapableNode> nodePath = deviceInfo.getNodeInstanceIdentifier().augmentation(FlowCapableNode.class);
final TableBuilder tableDataBld = new TableBuilder();
tableDataBld.setId(tableId);
final FlowCapableNodeBuilder flowNodeBuilder = new FlowCapableNodeBuilder();
flowNodeBuilder.setTable(Collections.singletonList(tableDataBld.build()));
final Optional<FlowCapableNode> flowNodeOpt = Optional.of(flowNodeBuilder.build());
final CheckedFuture<Optional<FlowCapableNode>, ReadFailedException> flowNodeFuture = Futures.immediateCheckedFuture(flowNodeOpt);
when(readTx.read(LogicalDatastoreType.OPERATIONAL, nodePath)).thenReturn(flowNodeFuture);
when(flowDescriptor.getFlowId()).thenReturn(flowId);
final org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder matchBld = new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder().setMatchEntry(Collections.<MatchEntry>emptyList());
final FlowStatsBuilder flowStatsBld = new FlowStatsBuilder().setByteCount(BigInteger.valueOf(55L)).setPacketCount(BigInteger.valueOf(56L)).setDurationSec(57L).setDurationNsec(58L).setTableId((short) 0).setMatch(matchBld.build()).setFlags(new FlowModFlags(true, false, false, false, true));
final MultipartReplyFlowBuilder mpReplyFlowBld = new MultipartReplyFlowBuilder();
mpReplyFlowBld.setFlowStats(Lists.newArrayList(flowStatsBld.build()));
final MultipartReplyFlowCaseBuilder mpReplyFlowCaseBld = new MultipartReplyFlowCaseBuilder();
mpReplyFlowCaseBld.setMultipartReplyFlow(mpReplyFlowBld.build());
final MultipartReply flowStatsUpdated = assembleMPReplyMessage(type, mpReplyFlowCaseBld.build());
final List<MultipartReply> statsData = Collections.singletonList(flowStatsUpdated);
fireAndCheck(type, statsData);
final FlowBuilder flowBld = new FlowBuilder().setTableId((short) 0).setMatch(new MatchBuilder().build());
final KeyedInstanceIdentifier<Table, TableKey> tablePath = dummyNodePath.augmentation(FlowCapableNode.class).child(Table.class, new TableKey((short) 0));
final KeyedInstanceIdentifier<Flow, FlowKey> flowPath = tablePath.child(Flow.class, new FlowKey(flowId));
verify(deviceContext, Mockito.never()).addDeleteToTxChain(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.<InstanceIdentifier<?>>any());
final InOrder inOrder = Mockito.inOrder(deviceContext);
inOrder.verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.any(), Matchers.any());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project openflowplugin by opendaylight.
the class FlowDirectStatisticsServiceTest method setUp.
@Override
public void setUp() throws Exception {
service = new FlowDirectStatisticsService(requestContextStack, deviceContext, convertorManager, multipartWriterProvider);
final DeviceFlowRegistry registry = mock(DeviceFlowRegistry.class);
when(registry.retrieveDescriptor(any())).thenReturn(FlowDescriptorFactory.create(TABLE_NO, new FlowId("1")));
when(deviceContext.getDeviceFlowRegistry()).thenReturn(registry);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.FlowId in project openflowplugin by opendaylight.
the class FlatBatchUtilTest method testMergeJobsResultsFutures.
@Test
public void testMergeJobsResultsFutures() throws Exception {
final BatchFailure batchFailure = new BatchFailureBuilder().setBatchOrder(9).setBatchItemIdChoice(new FlatBatchFailureFlowIdCaseBuilder().setFlowId(new FlowId("11")).build()).build();
final ProcessFlatBatchOutput output = new ProcessFlatBatchOutputBuilder().setBatchFailure(Lists.newArrayList(batchFailure)).build();
final RpcResult<ProcessFlatBatchOutput> rpcResultFailed = RpcResultBuilder.<ProcessFlatBatchOutput>failed().withError(RpcError.ErrorType.APPLICATION, "ut-rpcError").withResult(output).build();
final RpcResult<ProcessFlatBatchOutput> rpcResultSuccess = RpcResultBuilder.<ProcessFlatBatchOutput>success().withResult(new ProcessFlatBatchOutputBuilder().setBatchFailure(new ArrayList<>())).build();
final RpcResult<ProcessFlatBatchOutput> rpcResult1 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultSuccess));
Assert.assertEquals(1, rpcResult1.getErrors().size());
Assert.assertFalse(rpcResult1.isSuccessful());
final RpcResult<ProcessFlatBatchOutput> rpcResult2 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultFailed, rpcResultFailed));
Assert.assertEquals(2, rpcResult2.getErrors().size());
Assert.assertFalse(rpcResult2.isSuccessful());
final RpcResult<ProcessFlatBatchOutput> rpcResult3 = FlatBatchUtil.mergeRpcResults().apply(Lists.newArrayList(rpcResultSuccess, rpcResultSuccess));
Assert.assertEquals(0, rpcResult3.getErrors().size());
Assert.assertTrue(rpcResult3.isSuccessful());
}
Aggregations