blob: 5d2255ba2a09cd84aad110cdbb02eba116b4a181 [file] [log] [blame]
Junxiao Shi38f4ce92016-08-04 10:01:52 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shib347b7f2017-07-23 14:01:58 +00002/*
Davide Pesavento21353752020-11-20 00:43:44 -05003 * Copyright (c) 2014-2020, Regents of the University of California,
Junxiao Shi38f4ce92016-08-04 10:01:52 +00004 * 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 Shi331ade72016-08-19 14:07:19 +000026#include "nfdc/forwarder-general-module.hpp"
Junxiao Shi38f4ce92016-08-04 10:01:52 +000027
Junxiao Shi1f481fa2017-01-26 15:14:43 +000028#include "status-fixture.hpp"
Junxiao Shi38f4ce92016-08-04 10:01:52 +000029
30namespace nfd {
31namespace tools {
Junxiao Shi331ade72016-08-19 14:07:19 +000032namespace nfdc {
Junxiao Shi38f4ce92016-08-04 10:01:52 +000033namespace tests {
34
Junxiao Shi331ade72016-08-19 14:07:19 +000035BOOST_AUTO_TEST_SUITE(Nfdc)
Junxiao Shi1f481fa2017-01-26 15:14:43 +000036BOOST_FIXTURE_TEST_SUITE(TestForwarderGeneralModule, StatusFixture<ForwarderGeneralModule>)
Junxiao Shi38f4ce92016-08-04 10:01:52 +000037
Junxiao Shi38f4ce92016-08-04 10:01:52 +000038const std::string STATUS_XML = stripXmlSpaces(R"XML(
39 <generalStatus>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000040 <version>0.4.1-1-g704430c</version>
41 <startTime>2016-06-24T15:13:46.856000</startTime>
42 <currentTime>2016-07-17T17:55:54.109000</currentTime>
43 <uptime>PT1996927S</uptime>
44 <nNameTreeEntries>668</nNameTreeEntries>
45 <nFibEntries>70</nFibEntries>
46 <nPitEntries>7</nPitEntries>
47 <nMeasurementsEntries>1</nMeasurementsEntries>
48 <nCsEntries>65536</nCsEntries>
49 <packetCounters>
50 <incomingPackets>
51 <nInterests>20699052</nInterests>
Junxiao Shif03d4792017-04-06 16:41:22 +000052 <nData>5598070</nData>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000053 <nNacks>7230</nNacks>
54 </incomingPackets>
55 <outgoingPackets>
56 <nInterests>36501092</nInterests>
Junxiao Shif03d4792017-04-06 16:41:22 +000057 <nData>5671942</nData>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000058 <nNacks>26762</nNacks>
59 </outgoingPackets>
60 </packetCounters>
Ju Pan7570e772018-10-27 03:33:58 +000061 <nSatisfiedInterests>123</nSatisfiedInterests>
62 <nUnsatisfiedInterests>321</nUnsatisfiedInterests>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000063 </generalStatus>
64)XML");
65
66const std::string STATUS_TEXT = std::string(R"TEXT(
67General NFD status:
Ju Pan7570e772018-10-27 03:33:58 +000068 version=0.4.1-1-g704430c
69 startTime=20160624T151346.856000
70 currentTime=20160717T175554.109000
71 uptime=1996927 seconds
72 nNameTreeEntries=668
73 nFibEntries=70
74 nPitEntries=7
75 nMeasurementsEntries=1
76 nCsEntries=65536
77 nInInterests=20699052
78 nOutInterests=36501092
79 nInData=5598070
80 nOutData=5671942
81 nInNacks=7230
82 nOutNacks=26762
83 nSatisfiedInterests=123
84 nUnsatisfiedInterests=321
Junxiao Shi38f4ce92016-08-04 10:01:52 +000085)TEXT").substr(1);
86
Alexander Afanasyev01bbd092017-08-14 23:56:19 +000087BOOST_AUTO_TEST_CASE(Status)
Junxiao Shi38f4ce92016-08-04 10:01:52 +000088{
89 this->fetchStatus();
90 ForwarderStatus payload;
91 payload.setNfdVersion("0.4.1-1-g704430c")
Davide Pesavento14e71f02019-03-28 17:35:25 -040092 .setStartTimestamp(time::fromUnixTimestamp(1466781226856_ms))
93 .setCurrentTimestamp(time::fromUnixTimestamp(1468778154109_ms))
Junxiao Shi38f4ce92016-08-04 10:01:52 +000094 .setNNameTreeEntries(668)
95 .setNFibEntries(70)
96 .setNPitEntries(7)
97 .setNMeasurementsEntries(1)
98 .setNCsEntries(65536)
99 .setNInInterests(20699052)
Junxiao Shif03d4792017-04-06 16:41:22 +0000100 .setNInData(5598070)
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000101 .setNInNacks(7230)
102 .setNOutInterests(36501092)
Junxiao Shif03d4792017-04-06 16:41:22 +0000103 .setNOutData(5671942)
Ju Pan7570e772018-10-27 03:33:58 +0000104 .setNOutNacks(26762)
105 .setNSatisfiedInterests(123)
106 .setNUnsatisfiedInterests(321);
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000107 this->sendDataset("/localhost/nfd/status/general", payload);
108 this->prepareStatusOutput();
109
110 BOOST_CHECK(statusXml.is_equal(STATUS_XML));
111 BOOST_CHECK(statusText.is_equal(STATUS_TEXT));
112}
113
114BOOST_AUTO_TEST_CASE(StatusNoNfdId)
115{
116 this->fetchStatus();
117 ForwarderStatus payload;
118 payload.setNfdVersion("0.4.1-1-g704430c");
119 this->sendDataset("/localhost/nfd/status/general", payload);
120 BOOST_CHECK_NO_THROW(this->prepareStatusOutput());
121}
122
123BOOST_AUTO_TEST_SUITE_END() // TestForwarderGeneralModule
Junxiao Shi331ade72016-08-19 14:07:19 +0000124BOOST_AUTO_TEST_SUITE_END() // Nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000125
126} // namespace tests
Junxiao Shi331ade72016-08-19 14:07:19 +0000127} // namespace nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000128} // namespace tools
129} // namespace nfd