blob: f97d36d9067fe70c0dbfdc6fe16fd2c483d8df68 [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/*
Junxiao Shi1f481fa2017-01-26 15:14:43 +00003 * Copyright (c) 2014-2017, 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#include <ndn-cxx/security/signing-helpers.hpp>
28
Junxiao Shi1f481fa2017-01-26 15:14:43 +000029#include "status-fixture.hpp"
Junxiao Shi38f4ce92016-08-04 10:01:52 +000030
31namespace nfd {
32namespace tools {
Junxiao Shi331ade72016-08-19 14:07:19 +000033namespace nfdc {
Junxiao Shi38f4ce92016-08-04 10:01:52 +000034namespace tests {
35
Junxiao Shi331ade72016-08-19 14:07:19 +000036BOOST_AUTO_TEST_SUITE(Nfdc)
Junxiao Shi1f481fa2017-01-26 15:14:43 +000037BOOST_FIXTURE_TEST_SUITE(TestForwarderGeneralModule, StatusFixture<ForwarderGeneralModule>)
Junxiao Shi38f4ce92016-08-04 10:01:52 +000038
Junxiao Shib347b7f2017-07-23 14:01:58 +000039// class MakeNfdIdCollector
40// {
41// public:
42// unique_ptr<NfdIdCollector>
43// operator()(Face&, KeyChain&) const
44// {
45// return make_unique<NfdIdCollector>(make_unique<ValidatorNull>());
46// };
47// };
Junxiao Shi38f4ce92016-08-04 10:01:52 +000048
Junxiao Shib347b7f2017-07-23 14:01:58 +000049class ForwarderGeneralStatusFixture : public StatusFixture<ForwarderGeneralModule>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000050{
51protected:
52 ForwarderGeneralStatusFixture()
53 {
Junxiao Shib347b7f2017-07-23 14:01:58 +000054 // module.setNfdIdCollector(*validator);
Junxiao Shi38f4ce92016-08-04 10:01:52 +000055
Junxiao Shi16a3adf2017-05-26 17:38:51 +000056 BOOST_REQUIRE(this->addIdentity("/nfd-status/test-nfdid",
57 ndn::EcKeyParams(name::Component("KEYID"))));
Junxiao Shi38f4ce92016-08-04 10:01:52 +000058 }
59
60private:
Junxiao Shif03d4792017-04-06 16:41:22 +000061 void
Junxiao Shi38f4ce92016-08-04 10:01:52 +000062 signDatasetReply(Data& data) override
63 {
64 m_keyChain.sign(data, ndn::security::signingByIdentity("/nfd-status/test-nfdid"));
65 }
66};
67
68const std::string STATUS_XML = stripXmlSpaces(R"XML(
69 <generalStatus>
Junxiao Shib347b7f2017-07-23 14:01:58 +000070 <nfdId>/nfdId-unavailable</nfdId>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000071 <version>0.4.1-1-g704430c</version>
72 <startTime>2016-06-24T15:13:46.856000</startTime>
73 <currentTime>2016-07-17T17:55:54.109000</currentTime>
74 <uptime>PT1996927S</uptime>
75 <nNameTreeEntries>668</nNameTreeEntries>
76 <nFibEntries>70</nFibEntries>
77 <nPitEntries>7</nPitEntries>
78 <nMeasurementsEntries>1</nMeasurementsEntries>
79 <nCsEntries>65536</nCsEntries>
80 <packetCounters>
81 <incomingPackets>
82 <nInterests>20699052</nInterests>
Junxiao Shif03d4792017-04-06 16:41:22 +000083 <nData>5598070</nData>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000084 <nNacks>7230</nNacks>
85 </incomingPackets>
86 <outgoingPackets>
87 <nInterests>36501092</nInterests>
Junxiao Shif03d4792017-04-06 16:41:22 +000088 <nData>5671942</nData>
Junxiao Shi38f4ce92016-08-04 10:01:52 +000089 <nNacks>26762</nNacks>
90 </outgoingPackets>
91 </packetCounters>
92 </generalStatus>
93)XML");
94
95const std::string STATUS_TEXT = std::string(R"TEXT(
96General NFD status:
Junxiao Shib347b7f2017-07-23 14:01:58 +000097 nfdId=/nfdId-unavailable
Junxiao Shi38f4ce92016-08-04 10:01:52 +000098 version=0.4.1-1-g704430c
99 startTime=20160624T151346.856000
100 currentTime=20160717T175554.109000
101 uptime=1996927 seconds
102 nNameTreeEntries=668
103 nFibEntries=70
104 nPitEntries=7
105 nMeasurementsEntries=1
106 nCsEntries=65536
107 nInInterests=20699052
108 nOutInterests=36501092
Junxiao Shif03d4792017-04-06 16:41:22 +0000109 nInData=5598070
110 nOutData=5671942
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000111 nInNacks=7230
112 nOutNacks=26762
113)TEXT").substr(1);
114
115BOOST_FIXTURE_TEST_CASE(Status, ForwarderGeneralStatusFixture)
116{
117 this->fetchStatus();
118 ForwarderStatus payload;
119 payload.setNfdVersion("0.4.1-1-g704430c")
120 .setStartTimestamp(time::fromUnixTimestamp(time::milliseconds(1466781226856)))
121 .setCurrentTimestamp(time::fromUnixTimestamp(time::milliseconds(1468778154109)))
122 .setNNameTreeEntries(668)
123 .setNFibEntries(70)
124 .setNPitEntries(7)
125 .setNMeasurementsEntries(1)
126 .setNCsEntries(65536)
127 .setNInInterests(20699052)
Junxiao Shif03d4792017-04-06 16:41:22 +0000128 .setNInData(5598070)
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000129 .setNInNacks(7230)
130 .setNOutInterests(36501092)
Junxiao Shif03d4792017-04-06 16:41:22 +0000131 .setNOutData(5671942)
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000132 .setNOutNacks(26762);
133 this->sendDataset("/localhost/nfd/status/general", payload);
134 this->prepareStatusOutput();
135
136 BOOST_CHECK(statusXml.is_equal(STATUS_XML));
137 BOOST_CHECK(statusText.is_equal(STATUS_TEXT));
138}
139
140BOOST_AUTO_TEST_CASE(StatusNoNfdId)
141{
142 this->fetchStatus();
143 ForwarderStatus payload;
144 payload.setNfdVersion("0.4.1-1-g704430c");
145 this->sendDataset("/localhost/nfd/status/general", payload);
146 BOOST_CHECK_NO_THROW(this->prepareStatusOutput());
147}
148
149BOOST_AUTO_TEST_SUITE_END() // TestForwarderGeneralModule
Junxiao Shi331ade72016-08-19 14:07:19 +0000150BOOST_AUTO_TEST_SUITE_END() // Nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000151
152} // namespace tests
Junxiao Shi331ade72016-08-19 14:07:19 +0000153} // namespace nfdc
Junxiao Shi38f4ce92016-08-04 10:01:52 +0000154} // namespace tools
155} // namespace nfd