use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testPortStatsSerialize.
@Test
public void testPortStatsSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(4));
MultipartReplyPortStatsCaseBuilder portStatsCase = new MultipartReplyPortStatsCaseBuilder();
MultipartReplyPortStatsBuilder portStats = new MultipartReplyPortStatsBuilder();
portStats.setPortStats(createPortStats());
portStatsCase.setMultipartReplyPortStats(portStats.build());
builder.setMultipartReplyBody(portStatsCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 128);
Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTSTATS.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyPortStatsCase body = (MultipartReplyPortStatsCase) message.getMultipartReplyBody();
MultipartReplyPortStats messageOutput = body.getMultipartReplyPortStats();
PortStats portStatsOutput = messageOutput.getPortStats().get(0);
Assert.assertEquals("Wrong port no", portStatsOutput.getPortNo().intValue(), serializedBuffer.readInt());
serializedBuffer.skipBytes(4);
Assert.assertEquals("Wrong rx packets", portStatsOutput.getRxPackets().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx packets", portStatsOutput.getTxPackets().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx bytes", portStatsOutput.getRxBytes().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx bytes", portStatsOutput.getTxBytes().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx dropped", portStatsOutput.getRxDropped().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx dropped", portStatsOutput.getTxDropped().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx errors", portStatsOutput.getRxErrors().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx errors", portStatsOutput.getTxErrors().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx frame err", portStatsOutput.getRxFrameErr().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx over err", portStatsOutput.getRxOverErr().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx crc err", portStatsOutput.getRxCrcErr().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong collisions", portStatsOutput.getCollisions().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong duration sec", portStatsOutput.getDurationSec().intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong duration nsec", portStatsOutput.getDurationNsec().intValue(), serializedBuffer.readInt());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder in project openflowplugin by opendaylight.
the class OF10StatsReplyMessageFactoryTest method testPortStatsBodySerialize.
@Test
public void testPortStatsBodySerialize() throws Exception {
MultipartReplyMessageBuilder builder;
builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(4));
MultipartReplyPortStatsCaseBuilder portStatsCase = new MultipartReplyPortStatsCaseBuilder();
MultipartReplyPortStatsBuilder portStats = new MultipartReplyPortStatsBuilder();
portStats.setPortStats(createPortStats());
portStatsCase.setMultipartReplyPortStats(portStats.build());
builder.setMultipartReplyBody(portStatsCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 118);
Assert.assertEquals("Wrong type", MultipartType.OFPMPPORTSTATS.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
MultipartReplyPortStatsCase body = (MultipartReplyPortStatsCase) message.getMultipartReplyBody();
MultipartReplyPortStats messageOutput = body.getMultipartReplyPortStats();
PortStats portStatsOutput = messageOutput.getPortStats().get(0);
Assert.assertEquals("Wrong port no", portStatsOutput.getPortNo().intValue(), serializedBuffer.readInt());
serializedBuffer.skipBytes(6);
Assert.assertEquals("Wrong rx packets", portStatsOutput.getRxPackets().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx packets", portStatsOutput.getTxPackets().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx bytes", portStatsOutput.getRxBytes().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx bytes", portStatsOutput.getTxBytes().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx dropped", portStatsOutput.getRxDropped().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx dropped", portStatsOutput.getTxDropped().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx errors", portStatsOutput.getRxErrors().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong tx errors", portStatsOutput.getTxErrors().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx frame err", portStatsOutput.getRxFrameErr().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx over err", portStatsOutput.getRxOverErr().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong rx crc err", portStatsOutput.getRxCrcErr().longValue(), serializedBuffer.readLong());
Assert.assertEquals("Wrong collisions", portStatsOutput.getCollisions().longValue(), serializedBuffer.readLong());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorTest method prepareMultipartReplyPortStats.
private MultipartReplyBody prepareMultipartReplyPortStats() {
PortStatsBuilder dummyPortStatBuilder = new PortStatsBuilder();
dummyPortStatBuilder.setPortNo(DUMMY_PORT_NO);
dummyPortStatBuilder.setRxBytes(DUMMY_RX_BYTES);
dummyPortStatBuilder.setTxBytes(DUMMY_TX_BYTES);
dummyPortStatBuilder.setRxPackets(DUMMY_RX_PACKETS);
dummyPortStatBuilder.setTxPackets(DUMMY_TX_PACKETS);
dummyPortStatBuilder.setCollisions(DUMMY_COLLISIONS);
dummyPortStatBuilder.setRxCrcErr(DUMMY_RX_CRC_ERR);
dummyPortStatBuilder.setRxDropped(DUMMY_RX_DROPPED);
dummyPortStatBuilder.setRxErrors(DUMMY_RX_ERRORS);
dummyPortStatBuilder.setRxFrameErr(DUMMY_RX_FRAME_ERR);
dummyPortStatBuilder.setRxOverErr(DUMMY_OVER_ERR);
dummyPortStatBuilder.setTxDropped(DUMMY_TX_DROPPED);
dummyPortStatBuilder.setTxErrors(DUMMY_TX_ERRORS);
MultipartReplyPortStatsBuilder multipartReplyPortStatsBuilder = new MultipartReplyPortStatsBuilder();
multipartReplyPortStatsBuilder.setPortStats(Lists.newArrayList(dummyPortStatBuilder.build()));
MultipartReplyPortStatsCaseBuilder multipartReplyPortStatsCaseBuilder = new MultipartReplyPortStatsCaseBuilder();
multipartReplyPortStatsCaseBuilder.setMultipartReplyPortStats(multipartReplyPortStatsBuilder.build());
return multipartReplyPortStatsCaseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder in project openflowplugin by opendaylight.
the class StatisticsGatheringUtilsTest method testGatherStatistics_nodeConnector.
@Test
public void testGatherStatistics_nodeConnector() throws Exception {
final MultipartType type = MultipartType.OFPMPPORTSTATS;
final PortStatsBuilder portStatsBld = new PortStatsBuilder().setPortNo(11L);
final MultipartReplyPortStatsBuilder mpReplyMeterBld = new MultipartReplyPortStatsBuilder();
mpReplyMeterBld.setPortStats(Lists.newArrayList(portStatsBld.build()));
final MultipartReplyPortStatsCaseBuilder mpReplyMeterCaseBld = new MultipartReplyPortStatsCaseBuilder();
mpReplyMeterCaseBld.setMultipartReplyPortStats(mpReplyMeterBld.build());
final MultipartReply meterStatsUpdated = assembleMPReplyMessage(type, mpReplyMeterCaseBld.build());
final List<MultipartReply> statsData = Collections.singletonList(meterStatsUpdated);
fireAndCheck(type, statsData);
final InstanceIdentifier<FlowCapableNodeConnectorStatistics> portPath = dummyNodePath.child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("openflow:" + DUMMY_NODE_ID_VALUE + ":11"))).augmentation(FlowCapableNodeConnectorStatisticsData.class).child(FlowCapableNodeConnectorStatistics.class);
verify(deviceContext).writeToTransaction(Matchers.eq(LogicalDatastoreType.OPERATIONAL), Matchers.eq(portPath), Matchers.any(FlowCapableNodeConnectorStatistics.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.multipart.reply.multipart.reply.body.MultipartReplyPortStatsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtilTest method translatePortStats.
@Test
public void translatePortStats() {
final MultipartReply multipartReply = buildReply(MultipartType.OFPMPPORTSTATS, new MultipartReplyPortStatsCaseBuilder().setMultipartReplyPortStats(new MultipartReplyPortStatsBuilder().setPortStats(Collections.singletonList(new PortStatsBuilder().build())).build()).build());
dummyAssertReply(multipartReply);
}
Aggregations