use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsOutput in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceTest method getStatsTwoPortBothDirection.
/**
* Test stats for two ports and both direction. <br>
* port1 is valid <br>
* port2 is invalid <br>
* Expectation: Error expected for port2
*
* @throws Exception the exception
*/
@Test
public void getStatsTwoPortBothDirection() throws Exception {
List<String> lstInterfaces = Arrays.asList(PORT_1, PORT_2);
Direction direction = Direction.Both;
GetAclPortStatisticsInput input = new GetAclPortStatisticsInputBuilder().setDirection(direction).setInterfaceNames(lstInterfaces).build();
Future<RpcResult<GetAclPortStatisticsOutput>> rpcResultFuture = aclStatsService.getAclPortStatistics(input);
RpcResult<GetAclPortStatisticsOutput> output = rpcResultFuture.get();
LOG.info("getStatsTwoPortBothDirection output = {}", output);
assertStatsOutput(output, direction);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsOutput in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceImpl method getAclPortStatistics.
@Override
public Future<RpcResult<GetAclPortStatisticsOutput>> getAclPortStatistics(GetAclPortStatisticsInput input) {
LOG.trace("Get ACL port statistics for input: {}", input);
RpcResultBuilder<GetAclPortStatisticsOutput> rpcResultBuilder;
if (this.securityGroupMode != SecurityGroupMode.Stateful) {
rpcResultBuilder = RpcResultBuilder.failed();
rpcResultBuilder.withError(ErrorType.APPLICATION, "operation-not-supported", "Operation not supported for ACL " + this.securityGroupMode + " mode");
return Futures.immediateFuture(rpcResultBuilder.build());
}
// Default direction is Both
Direction direction = input.getDirection() == null ? Direction.Both : input.getDirection();
List<AclPortStats> lstAclInterfaceStats = AclLiveStatisticsHelper.getAclPortStats(direction, input.getInterfaceNames(), this.odlDirectStatsService, this.dataBroker);
GetAclPortStatisticsOutputBuilder output = new GetAclPortStatisticsOutputBuilder().setAclPortStats(lstAclInterfaceStats);
rpcResultBuilder = RpcResultBuilder.success();
rpcResultBuilder.withResult(output.build());
return Futures.immediateFuture(rpcResultBuilder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsOutput in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceTest method getStatsTwoPortEgressOnly.
/**
* Test stats for two ports and egress direction only. <br>
* port1 is valid <br>
* port2 is invalid <br>
* Expectation: Error expected for port2. Drop stats should be available for
* egress direction only.
*
* @throws Exception the exception
*/
@Test
public void getStatsTwoPortEgressOnly() throws Exception {
List<String> lstInterfaces = Arrays.asList(PORT_1, PORT_2);
Direction direction = Direction.Egress;
GetAclPortStatisticsInput input = new GetAclPortStatisticsInputBuilder().setDirection(direction).setInterfaceNames(lstInterfaces).build();
Future<RpcResult<GetAclPortStatisticsOutput>> rpcResultFuture = aclStatsService.getAclPortStatistics(input);
RpcResult<GetAclPortStatisticsOutput> output = rpcResultFuture.get();
LOG.info("getStatsTwoPortEgressOnly output = {}", output);
assertStatsOutput(output, direction);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsOutput in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceTest method assertStatsOutput.
private void assertStatsOutput(RpcResult<GetAclPortStatisticsOutput> output, Direction inputDirection) {
assertNotNull(output);
GetAclPortStatisticsOutput aclPortStats = output.getResult();
assertNotNull(aclPortStats);
List<AclPortStats> lstAclPortStats = aclPortStats.getAclPortStats();
assertNotNull(lstAclPortStats);
assertFalse(lstAclPortStats.isEmpty());
for (AclPortStats stats : lstAclPortStats) {
List<AclDropStats> aclDropStats = stats.getAclDropStats();
if (stats.getInterfaceName().equals(PORT_1)) {
assertNotNull(aclDropStats);
assertTrue(!aclDropStats.isEmpty());
if (inputDirection == Direction.Both) {
assertTrue(aclDropStats.size() == 2);
} else {
assertTrue(aclDropStats.size() == 1);
}
for (AclDropStats dropStats : aclDropStats) {
if (inputDirection != Direction.Both) {
Assert.assertEquals(dropStats.getDirection(), inputDirection);
}
assertTrue(dropStats.getBytes().getDropCount().intValue() > 0);
assertTrue(dropStats.getBytes().getInvalidDropCount().intValue() > 0);
assertTrue(dropStats.getPackets().getDropCount().intValue() > 0);
assertTrue(dropStats.getPackets().getInvalidDropCount().intValue() > 0);
}
assertNull(stats.getError());
} else {
// Other than port1, error is returned in the output
assertNull(aclDropStats);
assertNotNull(stats.getError());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.acl.live.statistics.rev161129.GetAclPortStatisticsOutput in project netvirt by opendaylight.
the class AclLiveStatisticsRpcServiceTest method getStatsOnePortBothDirection.
/**
* Test stats for one port and both direction. <br>
* port1 is valid <br>
* Expectation: This is a success case.
*
* @throws Exception the exception
*/
@Test
public void getStatsOnePortBothDirection() throws Exception {
List<String> lstInterfaces = Arrays.asList(PORT_1);
Direction direction = Direction.Both;
GetAclPortStatisticsInput input = new GetAclPortStatisticsInputBuilder().setDirection(direction).setInterfaceNames(lstInterfaces).build();
Future<RpcResult<GetAclPortStatisticsOutput>> rpcResultFuture = aclStatsService.getAclPortStatistics(input);
RpcResult<GetAclPortStatisticsOutput> output = rpcResultFuture.get();
LOG.info("getStatsOnePortBothDirection output = {}", output);
assertStatsOutput(output, direction);
}
Aggregations