Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | b347b7f | 2017-07-23 14:01:58 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2019, Regents of the University of California, |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 26 | #include "nfdc/forwarder-general-module.hpp" |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 27 | |
Junxiao Shi | 1f481fa | 2017-01-26 15:14:43 +0000 | [diff] [blame] | 28 | #include "status-fixture.hpp" |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 29 | |
Alexander Afanasyev | 01bbd09 | 2017-08-14 23:56:19 +0000 | [diff] [blame] | 30 | #include <ndn-cxx/security/signing-helpers.hpp> |
| 31 | |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 32 | namespace nfd { |
| 33 | namespace tools { |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 34 | namespace nfdc { |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 35 | namespace tests { |
| 36 | |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 37 | BOOST_AUTO_TEST_SUITE(Nfdc) |
Junxiao Shi | 1f481fa | 2017-01-26 15:14:43 +0000 | [diff] [blame] | 38 | BOOST_FIXTURE_TEST_SUITE(TestForwarderGeneralModule, StatusFixture<ForwarderGeneralModule>) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 39 | |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 40 | const std::string STATUS_XML = stripXmlSpaces(R"XML( |
| 41 | <generalStatus> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 42 | <version>0.4.1-1-g704430c</version> |
| 43 | <startTime>2016-06-24T15:13:46.856000</startTime> |
| 44 | <currentTime>2016-07-17T17:55:54.109000</currentTime> |
| 45 | <uptime>PT1996927S</uptime> |
| 46 | <nNameTreeEntries>668</nNameTreeEntries> |
| 47 | <nFibEntries>70</nFibEntries> |
| 48 | <nPitEntries>7</nPitEntries> |
| 49 | <nMeasurementsEntries>1</nMeasurementsEntries> |
| 50 | <nCsEntries>65536</nCsEntries> |
| 51 | <packetCounters> |
| 52 | <incomingPackets> |
| 53 | <nInterests>20699052</nInterests> |
Junxiao Shi | f03d479 | 2017-04-06 16:41:22 +0000 | [diff] [blame] | 54 | <nData>5598070</nData> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 55 | <nNacks>7230</nNacks> |
| 56 | </incomingPackets> |
| 57 | <outgoingPackets> |
| 58 | <nInterests>36501092</nInterests> |
Junxiao Shi | f03d479 | 2017-04-06 16:41:22 +0000 | [diff] [blame] | 59 | <nData>5671942</nData> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 60 | <nNacks>26762</nNacks> |
| 61 | </outgoingPackets> |
| 62 | </packetCounters> |
Ju Pan | 7570e77 | 2018-10-27 03:33:58 +0000 | [diff] [blame] | 63 | <nSatisfiedInterests>123</nSatisfiedInterests> |
| 64 | <nUnsatisfiedInterests>321</nUnsatisfiedInterests> |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 65 | </generalStatus> |
| 66 | )XML"); |
| 67 | |
| 68 | const std::string STATUS_TEXT = std::string(R"TEXT( |
| 69 | General NFD status: |
Ju Pan | 7570e77 | 2018-10-27 03:33:58 +0000 | [diff] [blame] | 70 | version=0.4.1-1-g704430c |
| 71 | startTime=20160624T151346.856000 |
| 72 | currentTime=20160717T175554.109000 |
| 73 | uptime=1996927 seconds |
| 74 | nNameTreeEntries=668 |
| 75 | nFibEntries=70 |
| 76 | nPitEntries=7 |
| 77 | nMeasurementsEntries=1 |
| 78 | nCsEntries=65536 |
| 79 | nInInterests=20699052 |
| 80 | nOutInterests=36501092 |
| 81 | nInData=5598070 |
| 82 | nOutData=5671942 |
| 83 | nInNacks=7230 |
| 84 | nOutNacks=26762 |
| 85 | nSatisfiedInterests=123 |
| 86 | nUnsatisfiedInterests=321 |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 87 | )TEXT").substr(1); |
| 88 | |
Alexander Afanasyev | 01bbd09 | 2017-08-14 23:56:19 +0000 | [diff] [blame] | 89 | BOOST_AUTO_TEST_CASE(Status) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 90 | { |
| 91 | this->fetchStatus(); |
| 92 | ForwarderStatus payload; |
| 93 | payload.setNfdVersion("0.4.1-1-g704430c") |
Davide Pesavento | 14e71f0 | 2019-03-28 17:35:25 -0400 | [diff] [blame] | 94 | .setStartTimestamp(time::fromUnixTimestamp(1466781226856_ms)) |
| 95 | .setCurrentTimestamp(time::fromUnixTimestamp(1468778154109_ms)) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 96 | .setNNameTreeEntries(668) |
| 97 | .setNFibEntries(70) |
| 98 | .setNPitEntries(7) |
| 99 | .setNMeasurementsEntries(1) |
| 100 | .setNCsEntries(65536) |
| 101 | .setNInInterests(20699052) |
Junxiao Shi | f03d479 | 2017-04-06 16:41:22 +0000 | [diff] [blame] | 102 | .setNInData(5598070) |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 103 | .setNInNacks(7230) |
| 104 | .setNOutInterests(36501092) |
Junxiao Shi | f03d479 | 2017-04-06 16:41:22 +0000 | [diff] [blame] | 105 | .setNOutData(5671942) |
Ju Pan | 7570e77 | 2018-10-27 03:33:58 +0000 | [diff] [blame] | 106 | .setNOutNacks(26762) |
| 107 | .setNSatisfiedInterests(123) |
| 108 | .setNUnsatisfiedInterests(321); |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 109 | this->sendDataset("/localhost/nfd/status/general", payload); |
| 110 | this->prepareStatusOutput(); |
| 111 | |
| 112 | BOOST_CHECK(statusXml.is_equal(STATUS_XML)); |
| 113 | BOOST_CHECK(statusText.is_equal(STATUS_TEXT)); |
| 114 | } |
| 115 | |
| 116 | BOOST_AUTO_TEST_CASE(StatusNoNfdId) |
| 117 | { |
| 118 | this->fetchStatus(); |
| 119 | ForwarderStatus payload; |
| 120 | payload.setNfdVersion("0.4.1-1-g704430c"); |
| 121 | this->sendDataset("/localhost/nfd/status/general", payload); |
| 122 | BOOST_CHECK_NO_THROW(this->prepareStatusOutput()); |
| 123 | } |
| 124 | |
| 125 | BOOST_AUTO_TEST_SUITE_END() // TestForwarderGeneralModule |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 126 | BOOST_AUTO_TEST_SUITE_END() // Nfdc |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 127 | |
| 128 | } // namespace tests |
Junxiao Shi | 331ade7 | 2016-08-19 14:07:19 +0000 | [diff] [blame] | 129 | } // namespace nfdc |
Junxiao Shi | 38f4ce9 | 2016-08-04 10:01:52 +0000 | [diff] [blame] | 130 | } // namespace tools |
| 131 | } // namespace nfd |