blob: 21fb2888225e7116ecc100807473bd8feed51f84 [file] [log] [blame]
Junxiao Shi034c1882016-06-24 18:06:51 +00001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi2bea5c42017-08-14 20:10:32 +00002/*
Davide Pesavento221a72d2021-12-30 17:48:36 -05003 * Copyright (c) 2013-2021 Regents of the University of California.
Junxiao Shi034c1882016-06-24 18:06:51 +00004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6 *
7 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20 */
21
Davide Pesavento7e780642018-11-24 15:51:34 -050022#include "ndn-cxx/mgmt/nfd/status-dataset.hpp"
23#include "ndn-cxx/mgmt/nfd/controller.hpp"
Junxiao Shi034c1882016-06-24 18:06:51 +000024
Davide Pesavento4c1ad4c2020-11-16 21:12:02 -050025#include "tests/test-common.hpp"
Davide Pesavento7e780642018-11-24 15:51:34 -050026#include "tests/unit/mgmt/nfd/controller-fixture.hpp"
Junxiao Shi034c1882016-06-24 18:06:51 +000027
28namespace ndn {
29namespace nfd {
30namespace tests {
31
Junxiao Shi85d90832016-08-04 03:19:46 +000032using namespace ndn::tests;
Junxiao Shi034c1882016-06-24 18:06:51 +000033
Junxiao Shi7357ef22016-09-07 02:39:37 +000034BOOST_AUTO_TEST_SUITE(Mgmt)
35BOOST_AUTO_TEST_SUITE(Nfd)
Junxiao Shi034c1882016-06-24 18:06:51 +000036
37class ControllerStatusDatasetFixture : public ControllerFixture
38{
39protected:
40 /** \brief send one WireEncodable as Data reply
41 * \param prefix dataset prefix without version and segment
42 * \param payload payload block
43 * \note payload must fit in one Data
44 */
45 template<typename T>
46 void
47 sendDataset(const Name& prefix, const T& payload)
48 {
49 BOOST_CONCEPT_ASSERT((WireEncodable<T>));
50
51 auto data = this->prepareDatasetReply(prefix);
52 data->setContent(payload.wireEncode());
53 face.receive(*signData(data));
54 }
55
56 /** \brief send two WireEncodables as Data reply
57 * \param prefix dataset prefix without version and segment
58 * \param payload1 first vector item
59 * \param payload2 second vector item
60 * \note all payloads must fit in one Data
61 */
62 template<typename T1, typename T2>
63 void
64 sendDataset(const Name& prefix, const T1& payload1, const T2& payload2)
65 {
66 // The test suite allows up to two items, and put them in the same Data packet,
67 // because this test suite focuses on Controller::fetch<StatusDataset>,
68 // and is not intended to cover SegmentFetcher behavior.
69
70 BOOST_CONCEPT_ASSERT((WireEncodable<T1>));
71 BOOST_CONCEPT_ASSERT((WireEncodable<T2>));
72
73 ndn::encoding::EncodingBuffer buffer;
74 payload2.wireEncode(buffer);
75 payload1.wireEncode(buffer);
76
77 auto data = this->prepareDatasetReply(prefix);
78 data->setContent(buffer.buf(), buffer.size());
79 face.receive(*signData(data));
80 }
81
82private:
83 shared_ptr<Data>
84 prepareDatasetReply(const Name& prefix)
85 {
86 Name name = prefix;
87 name.appendVersion().appendSegment(0);
88
89 // These warnings assist in debugging a `hasResult` check failure.
90 // They usually indicate a misspelled prefix or incorrect timing in the test case.
91 if (face.sentInterests.size() < 1) {
92 BOOST_WARN_MESSAGE(false, "no Interest expressed");
93 }
94 else {
95 BOOST_WARN_MESSAGE(face.sentInterests.back().getName().isPrefixOf(name),
96 "last Interest " << face.sentInterests.back().getName() <<
97 " cannot be satisfied by this Data " << name);
98 }
99
100 auto data = make_shared<Data>(name);
Junxiao Shi2ad2fbe2019-05-24 03:11:05 +0000101 data->setFreshnessPeriod(1_s);
Junxiao Shiebfe4a22018-04-01 23:53:40 +0000102 data->setFinalBlock(name[-1]);
Junxiao Shi034c1882016-06-24 18:06:51 +0000103 return data;
104 }
105};
106
Junxiao Shi7357ef22016-09-07 02:39:37 +0000107BOOST_FIXTURE_TEST_SUITE(TestStatusDataset, ControllerStatusDatasetFixture)
Junxiao Shi034c1882016-06-24 18:06:51 +0000108
109BOOST_AUTO_TEST_SUITE(Failures)
110
111BOOST_AUTO_TEST_CASE(Timeout)
112{
113 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500114 options.setTimeout(3000_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000115 controller.fetch<FaceDataset>(
Davide Pesavento221a72d2021-12-30 17:48:36 -0500116 [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000117 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000118 options);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600119 this->advanceClocks(500_ms);
120 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 1);
Junxiao Shi034c1882016-06-24 18:06:51 +0000121
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600122 this->advanceClocks(500_ms, 6);
123 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 0);
Junxiao Shi034c1882016-06-24 18:06:51 +0000124 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
125 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_TIMEOUT);
126}
127
128BOOST_AUTO_TEST_CASE(DataHasNoSegment)
129{
130 controller.fetch<FaceDataset>(
Davide Pesavento221a72d2021-12-30 17:48:36 -0500131 [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000132 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500133 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000134
Junxiao Shi2ad2fbe2019-05-24 03:11:05 +0000135 auto data = makeData("/localhost/nfd/faces/list/%FD%00");
136 data->setFreshnessPeriod(1_s);
137 face.receive(*data);
Davide Pesavento0f830802018-01-16 23:58:58 -0500138 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000139
140 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
141 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
142}
143
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000144BOOST_AUTO_TEST_CASE(ValidationFailure)
145{
146 this->setValidationResult(false);
147
148 controller.fetch<FaceDataset>(
Davide Pesavento221a72d2021-12-30 17:48:36 -0500149 [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000150 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500151 this->advanceClocks(500_ms);
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000152
153 FaceStatus payload;
154 payload.setFaceId(5744);
155 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500156 this->advanceClocks(500_ms);
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000157
158 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
159 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_VALIDATION);
160}
161
Junxiao Shi034c1882016-06-24 18:06:51 +0000162BOOST_AUTO_TEST_CASE(Nack)
163{
164 controller.fetch<FaceDataset>(
Davide Pesavento221a72d2021-12-30 17:48:36 -0500165 [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000166 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500167 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000168
169 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
170 face.receive(lp::Nack(face.sentInterests.back()));
Davide Pesavento0f830802018-01-16 23:58:58 -0500171 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000172
173 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
174 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_NACK);
175}
176
177BOOST_AUTO_TEST_CASE(ParseError1)
178{
179 controller.fetch<FaceDataset>(
Davide Pesavento221a72d2021-12-30 17:48:36 -0500180 [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000181 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500182 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000183
184 Name payload; // Name is not valid FaceStatus
185 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500186 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000187
188 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
189 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
190}
191
192BOOST_AUTO_TEST_CASE(ParseError2)
193{
194 controller.fetch<FaceDataset>(
Davide Pesavento221a72d2021-12-30 17:48:36 -0500195 [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000196 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500197 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000198
199 FaceStatus payload1;
200 payload1.setFaceId(10930);
201 Name payload2; // Name is not valid FaceStatus
202 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500203 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000204
205 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
206 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
207}
208
209BOOST_AUTO_TEST_SUITE_END() // Failures
210
Junxiao Shi600f7112016-07-16 11:57:18 +0000211BOOST_AUTO_TEST_SUITE(NoCallback)
212
213BOOST_AUTO_TEST_CASE(Success)
214{
215 controller.fetch<FaceDataset>(
216 nullptr,
Junxiao Shie7c7f152016-08-20 22:36:22 +0000217 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500218 this->advanceClocks(500_ms);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600219 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 1);
Junxiao Shi600f7112016-07-16 11:57:18 +0000220
221 FaceStatus payload;
222 payload.setFaceId(2577);
223 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500224 BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms));
Junxiao Shi600f7112016-07-16 11:57:18 +0000225
226 BOOST_CHECK_EQUAL(failCodes.size(), 0);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600227 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 0);
Junxiao Shi600f7112016-07-16 11:57:18 +0000228}
229
230BOOST_AUTO_TEST_CASE(Failure)
231{
232 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500233 options.setTimeout(3000_ms);
Junxiao Shi600f7112016-07-16 11:57:18 +0000234 controller.fetch<FaceDataset>(
Davide Pesavento221a72d2021-12-30 17:48:36 -0500235 [] (auto&&) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shi600f7112016-07-16 11:57:18 +0000236 nullptr,
237 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500238 BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms, 7));
Junxiao Shi600f7112016-07-16 11:57:18 +0000239}
240
241BOOST_AUTO_TEST_SUITE_END() // NoCallback
242
Junxiao Shi034c1882016-06-24 18:06:51 +0000243BOOST_AUTO_TEST_SUITE(Datasets)
244
245BOOST_AUTO_TEST_CASE(StatusGeneral)
246{
247 bool hasResult = false;
248 controller.fetch<ForwarderGeneralStatusDataset>(
249 [&hasResult] (const ForwarderStatus& result) {
250 hasResult = true;
251 BOOST_CHECK_EQUAL(result.getNfdVersion(), "0.4.2");
252 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000253 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500254 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000255
256 ForwarderStatus payload;
257 payload.setNfdVersion("0.4.2");
258 this->sendDataset("/localhost/nfd/status/general", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500259 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000260
261 BOOST_CHECK(hasResult);
262 BOOST_CHECK_EQUAL(failCodes.size(), 0);
263}
264
265BOOST_AUTO_TEST_CASE(FaceList)
266{
267 bool hasResult = false;
268 controller.fetch<FaceDataset>(
269 [&hasResult] (const std::vector<FaceStatus>& result) {
270 hasResult = true;
271 BOOST_CHECK_EQUAL(result.size(), 2);
272 BOOST_CHECK_EQUAL(result.front().getFaceId(), 24485);
273 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000274 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500275 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000276
277 FaceStatus payload1;
278 payload1.setFaceId(24485);
279 FaceStatus payload2;
280 payload2.setFaceId(12987);
281 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500282 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000283
284 BOOST_CHECK(hasResult);
285 BOOST_CHECK_EQUAL(failCodes.size(), 0);
286}
287
288BOOST_AUTO_TEST_CASE(FaceQuery)
289{
290 FaceQueryFilter filter;
291 filter.setUriScheme("udp4");
292 bool hasResult = false;
293 controller.fetch<FaceQueryDataset>(
294 filter,
295 [&hasResult] (const std::vector<FaceStatus>& result) {
296 hasResult = true;
297 BOOST_CHECK_EQUAL(result.size(), 1);
298 BOOST_CHECK_EQUAL(result.front().getFaceId(), 8795);
299 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000300 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500301 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000302
303 Name prefix("/localhost/nfd/faces/query");
Davide Pesavento221a72d2021-12-30 17:48:36 -0500304 prefix.append(filter.wireEncode().begin(), filter.wireEncode().end());
Junxiao Shi034c1882016-06-24 18:06:51 +0000305 FaceStatus payload;
306 payload.setFaceId(8795);
307 this->sendDataset(prefix, payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500308 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000309
310 BOOST_CHECK(hasResult);
311 BOOST_CHECK_EQUAL(failCodes.size(), 0);
312}
313
314BOOST_AUTO_TEST_CASE(FaceQueryWithOptions)
315{
316 FaceQueryFilter filter;
317 filter.setUriScheme("udp4");
318 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500319 options.setTimeout(3000_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000320 bool hasResult = false;
321 controller.fetch<FaceQueryDataset>(
322 filter,
323 [&hasResult] (const std::vector<FaceStatus>& result) {
324 hasResult = true;
325 BOOST_CHECK_EQUAL(result.size(), 1);
326 BOOST_CHECK_EQUAL(result.front().getFaceId(), 14022);
327 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000328 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000329 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500330 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000331
332 Name prefix("/localhost/nfd/faces/query");
Davide Pesavento221a72d2021-12-30 17:48:36 -0500333 prefix.append(filter.wireEncode().begin(), filter.wireEncode().end());
Junxiao Shi034c1882016-06-24 18:06:51 +0000334 FaceStatus payload;
335 payload.setFaceId(14022);
336 this->sendDataset(prefix, payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500337 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000338
339 BOOST_CHECK(hasResult);
340 BOOST_CHECK_EQUAL(failCodes.size(), 0);
341}
342
Junxiao Shi1eacb972016-07-07 22:51:07 +0000343BOOST_AUTO_TEST_CASE(FaceChannels)
344{
345 bool hasResult = false;
346 controller.fetch<ChannelDataset>(
347 [&hasResult] (const std::vector<ChannelStatus>& result) {
348 hasResult = true;
349 BOOST_CHECK_EQUAL(result.size(), 2);
350 BOOST_CHECK_EQUAL(result.front().getLocalUri(), "tcp4://192.0.2.1:6363");
351 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000352 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500353 this->advanceClocks(500_ms);
Junxiao Shi1eacb972016-07-07 22:51:07 +0000354
355 ChannelStatus payload1;
356 payload1.setLocalUri("tcp4://192.0.2.1:6363");
357 ChannelStatus payload2;
358 payload2.setLocalUri("udp4://192.0.2.1:6363");
359 this->sendDataset("/localhost/nfd/faces/channels", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500360 this->advanceClocks(500_ms);
Junxiao Shi1eacb972016-07-07 22:51:07 +0000361
362 BOOST_CHECK(hasResult);
363 BOOST_CHECK_EQUAL(failCodes.size(), 0);
364}
365
Junxiao Shi034c1882016-06-24 18:06:51 +0000366BOOST_AUTO_TEST_CASE(FibList)
367{
368 bool hasResult = false;
369 controller.fetch<FibDataset>(
370 [&hasResult] (const std::vector<FibEntry>& result) {
371 hasResult = true;
372 BOOST_CHECK_EQUAL(result.size(), 2);
373 BOOST_CHECK_EQUAL(result.front().getPrefix(), "/wYs7fzYcfG");
374 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000375 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500376 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000377
378 FibEntry payload1;
379 payload1.setPrefix("/wYs7fzYcfG");
380 FibEntry payload2;
381 payload2.setPrefix("/LKvmnzY5S");
382 this->sendDataset("/localhost/nfd/fib/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500383 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000384
385 BOOST_CHECK(hasResult);
386 BOOST_CHECK_EQUAL(failCodes.size(), 0);
387}
388
Junxiao Shi7f012472017-12-07 20:40:47 +0000389BOOST_AUTO_TEST_CASE(CsInfo)
390{
391 using ndn::nfd::CsInfo;
392
393 bool hasResult = false;
394 controller.fetch<CsInfoDataset>(
395 [&hasResult] (const CsInfo& result) {
396 hasResult = true;
397 BOOST_CHECK_EQUAL(result.getNHits(), 4539);
398 },
399 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500400 this->advanceClocks(500_ms);
Junxiao Shi7f012472017-12-07 20:40:47 +0000401
402 CsInfo payload;
403 payload.setNHits(4539);
404 this->sendDataset("/localhost/nfd/cs/info", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500405 this->advanceClocks(500_ms);
Junxiao Shi7f012472017-12-07 20:40:47 +0000406
407 BOOST_CHECK(hasResult);
408 BOOST_CHECK_EQUAL(failCodes.size(), 0);
409}
410
Junxiao Shi034c1882016-06-24 18:06:51 +0000411BOOST_AUTO_TEST_CASE(StrategyChoiceList)
412{
413 bool hasResult = false;
414 controller.fetch<StrategyChoiceDataset>(
415 [&hasResult] (const std::vector<StrategyChoice>& result) {
416 hasResult = true;
417 BOOST_CHECK_EQUAL(result.size(), 2);
418 BOOST_CHECK_EQUAL(result.front().getName(), "/8MLz6N3B");
419 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000420 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500421 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000422
423 StrategyChoice payload1;
424 payload1.setName("/8MLz6N3B");
425 StrategyChoice payload2;
426 payload2.setName("/svqcBu0YwU");
427 this->sendDataset("/localhost/nfd/strategy-choice/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500428 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000429
430 BOOST_CHECK(hasResult);
431 BOOST_CHECK_EQUAL(failCodes.size(), 0);
432}
433
434BOOST_AUTO_TEST_CASE(RibList)
435{
436 bool hasResult = false;
437 controller.fetch<RibDataset>(
438 [&hasResult] (const std::vector<RibEntry>& result) {
439 hasResult = true;
440 BOOST_CHECK_EQUAL(result.size(), 2);
441 BOOST_CHECK_EQUAL(result.front().getName(), "/zXxBth97ee");
442 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000443 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500444 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000445
446 RibEntry payload1;
447 payload1.setName("/zXxBth97ee");
448 RibEntry payload2;
449 payload2.setName("/rJ8CvUpr4G");
450 this->sendDataset("/localhost/nfd/rib/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500451 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000452
453 BOOST_CHECK(hasResult);
454 BOOST_CHECK_EQUAL(failCodes.size(), 0);
455}
456
457BOOST_AUTO_TEST_CASE(RibListWithOptions)
458{
459 CommandOptions options;
460 options.setPrefix("/localhop/nfd");
461 bool hasResult = false;
462 controller.fetch<RibDataset>(
463 [&hasResult] (const std::vector<RibEntry>& result) {
464 hasResult = true;
465 BOOST_CHECK_EQUAL(result.size(), 1);
466 BOOST_CHECK_EQUAL(result.front().getName(), "/e6L5K4ascd");
467 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000468 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000469 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500470 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000471
472 RibEntry payload;
473 payload.setName("/e6L5K4ascd");
474 this->sendDataset("/localhop/nfd/rib/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500475 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000476
477 BOOST_CHECK(hasResult);
478 BOOST_CHECK_EQUAL(failCodes.size(), 0);
479}
480
481BOOST_AUTO_TEST_SUITE_END() // Datasets
482
Junxiao Shi7357ef22016-09-07 02:39:37 +0000483BOOST_AUTO_TEST_SUITE_END() // TestStatusDataset
484BOOST_AUTO_TEST_SUITE_END() // Nfd
485BOOST_AUTO_TEST_SUITE_END() // Mgmt
Junxiao Shi034c1882016-06-24 18:06:51 +0000486
487} // namespace tests
488} // namespace nfd
489} // namespace ndn