Search in sources :

Example 26 with Stats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project bgpcep by opendaylight.

the class Stateful07TopologySessionListenerTest method testStateful07TopologySessionListener.

@Test
public void testStateful07TopologySessionListener() throws Exception {
    this.listener.onSessionUp(this.session);
    final PcepSessionState listenerState = this.listener.listenerState;
    assertEquals(this.testAddress, listenerState.getPeerPref().getIpAddress());
    final LocalPref state = this.listener.listenerState.getLocalPref();
    assertNotNull(state);
    assertEquals(DEAD_TIMER, state.getDeadtimer().shortValue());
    assertEquals(KEEP_ALIVE, state.getKeepalive().shortValue());
    assertEquals(0, state.getSessionId().intValue());
    assertEquals(this.testAddress, state.getIpAddress());
    final PeerPref peerState = listenerState.getPeerPref();
    assertEquals(DEAD_TIMER, peerState.getDeadtimer().shortValue());
    assertEquals(KEEP_ALIVE, peerState.getKeepalive().shortValue());
    assertEquals(0, peerState.getSessionId().intValue());
    assertEquals(this.testAddress, peerState.getIpAddress());
    // add-lsp
    this.topologyRpcs.addLsp(createAddLspInput());
    assertEquals(1, this.receivedMsgs.size());
    assertTrue(this.receivedMsgs.get(0) instanceof Pcinitiate);
    final Pcinitiate pcinitiate = (Pcinitiate) this.receivedMsgs.get(0);
    final Requests req = pcinitiate.getPcinitiateMessage().getRequests().get(0);
    final long srpId = req.getSrp().getOperationId().getValue();
    final Tlvs tlvs = createLspTlvs(req.getLsp().getPlspId().getValue(), true, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
    final Pcrpt pcRpt = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req.getLsp()).setTlvs(tlvs).setPlspId(new PlspId(1L)).setSync(false).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId)), MsgBuilderUtil.createPath(req.getEro().getSubobject()));
    final Pcrpt esm = MsgBuilderUtil.createPcRtpMessage(new LspBuilder().setSync(false).build(), Optional.of(MsgBuilderUtil.createSrp(0L)), null);
    this.listener.onMessage(this.session, esm);
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertEquals(this.testAddress, pcc.getIpAddress().getIpv4Address().getValue());
        // reported lsp so far empty, has not received response (PcRpt) yet
        assertTrue(pcc.getReportedLsp().isEmpty());
        return pcc;
    });
    this.listener.onMessage(this.session, pcRpt);
    // check created lsp
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertEquals(1, pcc.getReportedLsp().size());
        final ReportedLsp reportedLsp = pcc.getReportedLsp().get(0);
        assertEquals(this.tunnelName, reportedLsp.getName());
        assertEquals(1, reportedLsp.getPath().size());
        final Path path = reportedLsp.getPath().get(0);
        assertEquals(1, path.getEro().getSubobject().size());
        assertEquals(this.eroIpPrefix, getLastEroIpPrefix(path.getEro()));
        return pcc;
    });
    // check stats
    checkEquals(() -> assertEquals(1, listenerState.getDelegatedLspsCount().intValue()));
    checkEquals(() -> assertTrue(this.listener.isSessionSynchronized()));
    checkEquals(() -> assertTrue(listenerState.getMessages().getAugmentation(StatefulMessagesStatsAug.class).getLastReceivedRptMsgTimestamp() > 0));
    checkEquals(() -> assertEquals(2, listenerState.getMessages().getAugmentation(StatefulMessagesStatsAug.class).getReceivedRptMsgCount().intValue()));
    checkEquals(() -> assertEquals(1, listenerState.getMessages().getAugmentation(StatefulMessagesStatsAug.class).getSentInitMsgCount().intValue()));
    checkEquals(() -> assertEquals(0, listenerState.getMessages().getAugmentation(StatefulMessagesStatsAug.class).getSentUpdMsgCount().intValue()));
    // update-lsp
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.update.lsp.args.ArgumentsBuilder updArgsBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.update.lsp.args.ArgumentsBuilder();
    updArgsBuilder.setEro(createEroWithIpPrefixes(Lists.newArrayList(this.eroIpPrefix, this.dstIpPrefix)));
    updArgsBuilder.addAugmentation(Arguments3.class, new Arguments3Builder().setLsp(new LspBuilder().setDelegate(true).setAdministrative(true).build()).build());
    final UpdateLspInput update = new UpdateLspInputBuilder().setArguments(updArgsBuilder.build()).setName(this.tunnelName).setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID)).setNode(this.nodeId).build();
    this.topologyRpcs.updateLsp(update);
    assertEquals(2, this.receivedMsgs.size());
    assertTrue(this.receivedMsgs.get(1) instanceof Pcupd);
    final Pcupd updateMsg = (Pcupd) this.receivedMsgs.get(1);
    final Updates upd = updateMsg.getPcupdMessage().getUpdates().get(0);
    final long srpId2 = upd.getSrp().getOperationId().getValue();
    final Tlvs tlvs2 = createLspTlvs(upd.getLsp().getPlspId().getValue(), false, this.newDestinationAddress, this.testAddress, this.testAddress, Optional.absent());
    final Pcrpt pcRpt2 = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(upd.getLsp()).setTlvs(tlvs2).setSync(true).setRemove(false).setOperational(OperationalStatus.Active).build(), Optional.of(MsgBuilderUtil.createSrp(srpId2)), MsgBuilderUtil.createPath(upd.getPath().getEro().getSubobject()));
    this.listener.onMessage(this.session, pcRpt2);
    // check updated lsp
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertEquals(1, pcc.getReportedLsp().size());
        final ReportedLsp reportedLsp = pcc.getReportedLsp().get(0);
        assertEquals(this.tunnelName, reportedLsp.getName());
        assertEquals(1, reportedLsp.getPath().size());
        final Path path = reportedLsp.getPath().get(0);
        assertEquals(2, path.getEro().getSubobject().size());
        assertEquals(this.dstIpPrefix, getLastEroIpPrefix(path.getEro()));
        assertEquals(1, listenerState.getDelegatedLspsCount().intValue());
        assertTrue(this.listener.isSessionSynchronized());
        final StatefulMessagesStatsAug statefulstate = listenerState.getMessages().getAugmentation(StatefulMessagesStatsAug.class);
        assertTrue(statefulstate.getLastReceivedRptMsgTimestamp() > 0);
        assertEquals(3, statefulstate.getReceivedRptMsgCount().intValue());
        assertEquals(1, statefulstate.getSentInitMsgCount().intValue());
        assertEquals(1, statefulstate.getSentUpdMsgCount().intValue());
        final ReplyTime replyTime = listenerState.getMessages().getReplyTime();
        assertTrue(replyTime.getAverageTime() > 0);
        assertTrue(replyTime.getMaxTime() > 0);
        final StatefulCapabilitiesStatsAug statefulCapabilities = listenerState.getPeerCapabilities().getAugmentation(StatefulCapabilitiesStatsAug.class);
        assertFalse(statefulCapabilities.isActive());
        assertTrue(statefulCapabilities.isInstantiation());
        assertTrue(statefulCapabilities.isStateful());
        return pcc;
    });
    // ensure-operational
    final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.ensure.lsp.operational.args.ArgumentsBuilder ensureArgs = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.ensure.lsp.operational.args.ArgumentsBuilder();
    ensureArgs.addAugmentation(Arguments1.class, new Arguments1Builder().setOperational(OperationalStatus.Active).build());
    final EnsureLspOperationalInput ensure = new EnsureLspOperationalInputBuilder().setArguments(ensureArgs.build()).setName(this.tunnelName).setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID)).setNode(this.nodeId).build();
    final OperationResult result = this.topologyRpcs.ensureLspOperational(ensure).get().getResult();
    // check result
    assertNull(result.getFailure());
    // remove-lsp
    final RemoveLspInput remove = new RemoveLspInputBuilder().setName(this.tunnelName).setNetworkTopologyRef(new NetworkTopologyRef(TOPO_IID)).setNode(this.nodeId).build();
    this.topologyRpcs.removeLsp(remove);
    assertEquals(3, this.receivedMsgs.size());
    assertTrue(this.receivedMsgs.get(2) instanceof Pcinitiate);
    final Pcinitiate pcinitiate2 = (Pcinitiate) this.receivedMsgs.get(2);
    final Requests req2 = pcinitiate2.getPcinitiateMessage().getRequests().get(0);
    final long srpId3 = req2.getSrp().getOperationId().getValue();
    final Tlvs tlvs3 = createLspTlvs(req2.getLsp().getPlspId().getValue(), false, this.testAddress, this.testAddress, this.testAddress, Optional.absent());
    final Pcrpt pcRpt3 = MsgBuilderUtil.createPcRtpMessage(new LspBuilder(req2.getLsp()).setTlvs(tlvs3).setRemove(true).setSync(true).setOperational(OperationalStatus.Down).build(), Optional.of(MsgBuilderUtil.createSrp(srpId3)), MsgBuilderUtil.createPath(Collections.emptyList()));
    this.listener.onMessage(this.session, pcRpt3);
    // check if lsp was removed
    readDataOperational(getDataBroker(), this.pathComputationClientIId, pcc -> {
        assertEquals(0, pcc.getReportedLsp().size());
        return pcc;
    });
    // check stats
    checkEquals(() -> assertEquals(0, listenerState.getDelegatedLspsCount().intValue()));
    checkEquals(() -> assertTrue(this.listener.isSessionSynchronized()));
    checkEquals(() -> assertTrue(listenerState.getMessages().getAugmentation(StatefulMessagesStatsAug.class).getLastReceivedRptMsgTimestamp() > 0));
    checkEquals(() -> assertEquals(4, listenerState.getMessages().getAugmentation(StatefulMessagesStatsAug.class).getReceivedRptMsgCount().intValue()));
    checkEquals(() -> assertEquals(2, listenerState.getMessages().getAugmentation(StatefulMessagesStatsAug.class).getSentInitMsgCount().intValue()));
    checkEquals(() -> assertEquals(1, listenerState.getMessages().getAugmentation(StatefulMessagesStatsAug.class).getSentUpdMsgCount().intValue()));
}
Also used : NetworkTopologyRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyRef) StatefulCapabilitiesStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulCapabilitiesStatsAug) PcepSessionState(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.PcepSessionState) Collections(java.util.Collections) RemoveLspInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.RemoveLspInput) OperationResult(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.OperationResult) EnsureLspOperationalInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.EnsureLspOperationalInputBuilder) Requests(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.pcinitiate.message.pcinitiate.message.Requests) ReportedLsp(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.ReportedLsp) UpdateLspInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.UpdateLspInputBuilder) LocalPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref) Pcrpt(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcrpt) Updates(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcupd.message.pcupd.message.Updates) EnsureLspOperationalInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.EnsureLspOperationalInput) Arguments1Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Arguments1Builder) Pcinitiate(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId) Path(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.Path) Pcupd(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcupd) Arguments3Builder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Arguments3Builder) ArgumentsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.add.lsp.args.ArgumentsBuilder) UpdateLspInput(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.UpdateLspInput) ReplyTime(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.reply.time.grouping.ReplyTime) Tlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs) MsgBuilderUtil.createLspTlvs(org.opendaylight.protocol.pcep.pcc.mock.spi.MsgBuilderUtil.createLspTlvs) LspBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.LspBuilder) RemoveLspInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.RemoveLspInputBuilder) PeerPref(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerPref) StatefulMessagesStatsAug(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulMessagesStatsAug) Test(org.junit.Test)

Example 27 with Stats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.

the class GroupStatsResponseConvertorTest method testTwoGroupStats.

/**
 * Test two GroupStats conversion.
 */
@Test
public void testTwoGroupStats() {
    GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
    statsBuilder.setByteCount(new BigInteger("12345"));
    statsBuilder.setDurationNsec(1000000L);
    statsBuilder.setDurationSec(5000L);
    statsBuilder.setGroupId(new GroupId(42L));
    statsBuilder.setPacketCount(new BigInteger("54321"));
    statsBuilder.setRefCount(24L);
    statsBuilder.setBucketStats(new ArrayList<BucketStats>());
    List<GroupStats> groupStats = new ArrayList<>();
    groupStats.add(statsBuilder.build());
    statsBuilder = new GroupStatsBuilder();
    statsBuilder.setByteCount(new BigInteger("1"));
    statsBuilder.setDurationNsec(2L);
    statsBuilder.setDurationSec(3L);
    statsBuilder.setGroupId(new GroupId(4L));
    statsBuilder.setPacketCount(new BigInteger("5"));
    statsBuilder.setRefCount(6L);
    statsBuilder.setBucketStats(new ArrayList<BucketStats>());
    groupStats.add(statsBuilder.build());
    Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> salGroupStats = salGroupStatsOptional.get();
    Assert.assertEquals("Wrong group stats size", 2, salGroupStats.size());
    org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = salGroupStats.get(0);
    Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong key", 42, stat.getKey().getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
    Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
    Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
    Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
    stat = salGroupStats.get(1);
    Assert.assertEquals("Wrong group-id", 4, stat.getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong key", 4, stat.getKey().getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong ref-count", 6, stat.getRefCount().getValue().intValue());
    Assert.assertEquals("Wrong packet count", 5, stat.getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong byte count", 1, stat.getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong duration sec", 3, stat.getDuration().getSecond().getValue().intValue());
    Assert.assertEquals("Wrong duration n sec", 2, stat.getDuration().getNanosecond().getValue().intValue());
    Assert.assertEquals("Wrong bucket stats", 0, stat.getBuckets().getBucketCounter().size());
}
Also used : ArrayList(java.util.ArrayList) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) BigInteger(java.math.BigInteger) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) ArrayList(java.util.ArrayList) List(java.util.List) BucketStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats) Test(org.junit.Test)

Example 28 with Stats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.

the class GroupStatsResponseConvertorTest method testGroupStatsWithBuckets.

/**
 * Test GroupStats with buckets conversion.
 */
@Test
public void testGroupStatsWithBuckets() {
    GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
    statsBuilder.setByteCount(new BigInteger("12345"));
    statsBuilder.setDurationNsec(1000000L);
    statsBuilder.setDurationSec(5000L);
    statsBuilder.setGroupId(new GroupId(42L));
    statsBuilder.setPacketCount(new BigInteger("54321"));
    statsBuilder.setRefCount(24L);
    List<BucketStats> bucketStats = new ArrayList<>();
    BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
    bucketStatsBuilder.setByteCount(new BigInteger("987"));
    bucketStatsBuilder.setPacketCount(new BigInteger("654"));
    bucketStats.add(bucketStatsBuilder.build());
    bucketStatsBuilder = new BucketStatsBuilder();
    bucketStatsBuilder.setByteCount(new BigInteger("123"));
    bucketStatsBuilder.setPacketCount(new BigInteger("456"));
    bucketStats.add(bucketStatsBuilder.build());
    statsBuilder.setBucketStats(bucketStats);
    List<GroupStats> groupStats = new ArrayList<>();
    groupStats.add(statsBuilder.build());
    Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> salGroupStats = salGroupStatsOptional.get();
    Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());
    org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = salGroupStats.get(0);
    Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
    Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
    Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
    Assert.assertEquals("Wrong bucket stats", 2, stat.getBuckets().getBucketCounter().size());
    List<BucketCounter> list = stat.getBuckets().getBucketCounter();
    Assert.assertEquals("Wrong bucket-id", 0, list.get(0).getBucketId().getValue().intValue());
    Assert.assertEquals("Wrong bucket packet count", 654, list.get(0).getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong bucket byte count", 987, list.get(0).getByteCount().getValue().intValue());
    Assert.assertEquals("Wrong bucket-id", 1, list.get(1).getBucketId().getValue().intValue());
    Assert.assertEquals("Wrong bucket packet count", 456, list.get(1).getPacketCount().getValue().intValue());
    Assert.assertEquals("Wrong bucket byte count", 123, list.get(1).getByteCount().getValue().intValue());
}
Also used : ArrayList(java.util.ArrayList) BucketStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStatsBuilder) GroupStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats) ArrayList(java.util.ArrayList) List(java.util.List) BucketStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.group.stats.BucketStats) BucketCounter(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.buckets.BucketCounter) GroupStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStatsBuilder) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) BigInteger(java.math.BigInteger) Test(org.junit.Test)

Example 29 with Stats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.

the class MultipartReplyFlowTest method testEmptyMultipartReplyFlowBody.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testEmptyMultipartReplyFlowBody() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 00 01 00 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
    Assert.assertEquals("Wrong flow stats size", 0, message.getFlowStats().size());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 30 with Stats

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.peers.peer.Stats in project openflowplugin by opendaylight.

the class MultipartReplyFlowTest method testMultipartReplyFlowBody.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyFlowBody() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 01 00 01 00 00 00 00 " + // first flow stat
    "00 48 08 00 " + // length, tableId, padding
    "00 00 00 09 " + // durationSec
    "00 00 00 07 " + // durationNsec
    "00 0C 00 0E 00 0F 00 1F " + // priority, idleTimeout, hardTimeout, flags
    "00 00 00 00 " + // pad_02
    "FF 01 01 01 01 01 01 01 " + // cookie
    "EF 01 01 01 01 01 01 01 " + // packetCount
    "7F 01 01 01 01 01 01 01 " + // byteCount
    "00 01 00 04 00 00 00 00 " + // empty match
    "00 01 00 08 06 00 00 00 " + // 
    "00 01 00 08 06 00 00 00 " + // second flow stat
    "00 48 08 00 " + // length, tableId, padding
    "00 00 00 09 " + // durationSec
    "00 00 00 07 " + // durationNsec
    "00 0C 00 0E 00 0F 00 00 " + // priority, idleTimeout, hardTimeout, flags
    "00 00 00 00 " + // pad_02
    "FF 01 01 01 01 01 01 01 " + // cookie
    "EF 01 01 01 01 01 01 01 " + // packetCount
    "7F 01 01 01 01 01 01 01 " + // byteCount
    "00 01 00 04 00 00 00 00 " + // empty match
    "00 01 00 08 06 00 00 00 " + // 
    "00 01 00 08 06 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0x01, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyFlowCase messageCase = (MultipartReplyFlowCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyFlow message = messageCase.getMultipartReplyFlow();
    Assert.assertEquals("Wrong flow stats size", 2, message.getFlowStats().size());
    FlowStats flowStats1 = message.getFlowStats().get(0);
    Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());
    Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());
    Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());
    Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());
    Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
    Assert.assertEquals("Wrong flags", new FlowModFlags(true, true, true, true, true), flowStats1.getFlags());
    Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getCookie());
    Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xEF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getPacketCount());
    Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getByteCount());
    Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
    flowStats1 = message.getFlowStats().get(1);
    Assert.assertEquals("Wrong tableId", 8, flowStats1.getTableId().intValue());
    Assert.assertEquals("Wrong durationSec", 9, flowStats1.getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 7, flowStats1.getDurationNsec().intValue());
    Assert.assertEquals("Wrong priority", 12, flowStats1.getPriority().intValue());
    Assert.assertEquals("Wrong idleTimeOut", 14, flowStats1.getIdleTimeout().intValue());
    Assert.assertEquals("Wrong hardTimeOut", 15, flowStats1.getHardTimeout().intValue());
    Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowStats1.getFlags());
    Assert.assertEquals("Wrong cookie", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getCookie());
    Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xEF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getPacketCount());
    Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0x7F, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), flowStats1.getByteCount());
    Assert.assertEquals("Wrong match type", OxmMatchType.class, flowStats1.getMatch().getType());
}
Also used : FlowStats(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags) MultipartReplyFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow) BigInteger(java.math.BigInteger) MultipartReplyFlowCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)15 ArrayList (java.util.ArrayList)14 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)11 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)10 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)10 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)10 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)10 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)10 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)9 List (java.util.List)8 BigInteger (java.math.BigInteger)6 GroupStats (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.multipart.reply.group.GroupStats)6 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 GetFlowStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput)5 GetNodeConnectorStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetNodeConnectorStatisticsOutput)5 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)5 GetGroupStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetGroupStatisticsOutput)4 GetMeterStatisticsOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetMeterStatisticsOutput)4 FlowAndStatisticsMapList (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.flow.and.statistics.map.list.FlowAndStatisticsMapList)4 GroupId (org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId)4