blob: 1af98e9f00ffaa5619ab9cf847c7af058db9043e [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 Pesavento0f830802018-01-16 23:58:58 -05003 * Copyright (c) 2013-2018 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 Pesavento7e780642018-11-24 15:51:34 -050025#include "tests/boost-test.hpp"
26#include "tests/make-interest-data.hpp"
27#include "tests/unit/mgmt/nfd/controller-fixture.hpp"
Junxiao Shi034c1882016-06-24 18:06:51 +000028
29namespace ndn {
30namespace nfd {
31namespace tests {
32
Junxiao Shi85d90832016-08-04 03:19:46 +000033using namespace ndn::tests;
Junxiao Shi034c1882016-06-24 18:06:51 +000034
Junxiao Shi7357ef22016-09-07 02:39:37 +000035BOOST_AUTO_TEST_SUITE(Mgmt)
36BOOST_AUTO_TEST_SUITE(Nfd)
Junxiao Shi034c1882016-06-24 18:06:51 +000037
38class ControllerStatusDatasetFixture : public ControllerFixture
39{
40protected:
41 /** \brief send one WireEncodable as Data reply
42 * \param prefix dataset prefix without version and segment
43 * \param payload payload block
44 * \note payload must fit in one Data
45 */
46 template<typename T>
47 void
48 sendDataset(const Name& prefix, const T& payload)
49 {
50 BOOST_CONCEPT_ASSERT((WireEncodable<T>));
51
52 auto data = this->prepareDatasetReply(prefix);
53 data->setContent(payload.wireEncode());
54 face.receive(*signData(data));
55 }
56
57 /** \brief send two WireEncodables as Data reply
58 * \param prefix dataset prefix without version and segment
59 * \param payload1 first vector item
60 * \param payload2 second vector item
61 * \note all payloads must fit in one Data
62 */
63 template<typename T1, typename T2>
64 void
65 sendDataset(const Name& prefix, const T1& payload1, const T2& payload2)
66 {
67 // The test suite allows up to two items, and put them in the same Data packet,
68 // because this test suite focuses on Controller::fetch<StatusDataset>,
69 // and is not intended to cover SegmentFetcher behavior.
70
71 BOOST_CONCEPT_ASSERT((WireEncodable<T1>));
72 BOOST_CONCEPT_ASSERT((WireEncodable<T2>));
73
74 ndn::encoding::EncodingBuffer buffer;
75 payload2.wireEncode(buffer);
76 payload1.wireEncode(buffer);
77
78 auto data = this->prepareDatasetReply(prefix);
79 data->setContent(buffer.buf(), buffer.size());
80 face.receive(*signData(data));
81 }
82
83private:
84 shared_ptr<Data>
85 prepareDatasetReply(const Name& prefix)
86 {
87 Name name = prefix;
88 name.appendVersion().appendSegment(0);
89
90 // These warnings assist in debugging a `hasResult` check failure.
91 // They usually indicate a misspelled prefix or incorrect timing in the test case.
92 if (face.sentInterests.size() < 1) {
93 BOOST_WARN_MESSAGE(false, "no Interest expressed");
94 }
95 else {
96 BOOST_WARN_MESSAGE(face.sentInterests.back().getName().isPrefixOf(name),
97 "last Interest " << face.sentInterests.back().getName() <<
98 " cannot be satisfied by this Data " << name);
99 }
100
101 auto data = make_shared<Data>(name);
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>(
116 [] (const std::vector<FaceStatus>& result) { 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>(
131 [] (const std::vector<FaceStatus>& result) { 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
135 face.receive(*makeData("/localhost/nfd/faces/list/%FD%00"));
Davide Pesavento0f830802018-01-16 23:58:58 -0500136 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000137
138 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
139 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
140}
141
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000142BOOST_AUTO_TEST_CASE(ValidationFailure)
143{
144 this->setValidationResult(false);
145
146 controller.fetch<FaceDataset>(
147 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000148 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500149 this->advanceClocks(500_ms);
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000150
151 FaceStatus payload;
152 payload.setFaceId(5744);
153 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500154 this->advanceClocks(500_ms);
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000155
156 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
157 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_VALIDATION);
158}
159
Junxiao Shi034c1882016-06-24 18:06:51 +0000160BOOST_AUTO_TEST_CASE(Nack)
161{
162 controller.fetch<FaceDataset>(
163 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000164 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500165 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000166
167 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
168 face.receive(lp::Nack(face.sentInterests.back()));
Davide Pesavento0f830802018-01-16 23:58:58 -0500169 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000170
171 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
172 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_NACK);
173}
174
175BOOST_AUTO_TEST_CASE(ParseError1)
176{
177 controller.fetch<FaceDataset>(
178 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000179 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500180 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000181
182 Name payload; // Name is not valid FaceStatus
183 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500184 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000185
186 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
187 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
188}
189
190BOOST_AUTO_TEST_CASE(ParseError2)
191{
192 controller.fetch<FaceDataset>(
193 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000194 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500195 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000196
197 FaceStatus payload1;
198 payload1.setFaceId(10930);
199 Name payload2; // Name is not valid FaceStatus
200 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500201 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000202
203 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
204 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
205}
206
207BOOST_AUTO_TEST_SUITE_END() // Failures
208
Junxiao Shi600f7112016-07-16 11:57:18 +0000209BOOST_AUTO_TEST_SUITE(NoCallback)
210
211BOOST_AUTO_TEST_CASE(Success)
212{
213 controller.fetch<FaceDataset>(
214 nullptr,
Junxiao Shie7c7f152016-08-20 22:36:22 +0000215 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500216 this->advanceClocks(500_ms);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600217 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 1);
Junxiao Shi600f7112016-07-16 11:57:18 +0000218
219 FaceStatus payload;
220 payload.setFaceId(2577);
221 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500222 BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms));
Junxiao Shi600f7112016-07-16 11:57:18 +0000223
224 BOOST_CHECK_EQUAL(failCodes.size(), 0);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600225 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 0);
Junxiao Shi600f7112016-07-16 11:57:18 +0000226}
227
228BOOST_AUTO_TEST_CASE(Failure)
229{
230 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500231 options.setTimeout(3000_ms);
Junxiao Shi600f7112016-07-16 11:57:18 +0000232 controller.fetch<FaceDataset>(
233 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
234 nullptr,
235 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500236 BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms, 7));
Junxiao Shi600f7112016-07-16 11:57:18 +0000237}
238
239BOOST_AUTO_TEST_SUITE_END() // NoCallback
240
Junxiao Shi034c1882016-06-24 18:06:51 +0000241BOOST_AUTO_TEST_SUITE(Datasets)
242
243BOOST_AUTO_TEST_CASE(StatusGeneral)
244{
245 bool hasResult = false;
246 controller.fetch<ForwarderGeneralStatusDataset>(
247 [&hasResult] (const ForwarderStatus& result) {
248 hasResult = true;
249 BOOST_CHECK_EQUAL(result.getNfdVersion(), "0.4.2");
250 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000251 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500252 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000253
254 ForwarderStatus payload;
255 payload.setNfdVersion("0.4.2");
256 this->sendDataset("/localhost/nfd/status/general", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500257 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000258
259 BOOST_CHECK(hasResult);
260 BOOST_CHECK_EQUAL(failCodes.size(), 0);
261}
262
263BOOST_AUTO_TEST_CASE(FaceList)
264{
265 bool hasResult = false;
266 controller.fetch<FaceDataset>(
267 [&hasResult] (const std::vector<FaceStatus>& result) {
268 hasResult = true;
269 BOOST_CHECK_EQUAL(result.size(), 2);
270 BOOST_CHECK_EQUAL(result.front().getFaceId(), 24485);
271 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000272 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500273 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000274
275 FaceStatus payload1;
276 payload1.setFaceId(24485);
277 FaceStatus payload2;
278 payload2.setFaceId(12987);
279 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500280 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000281
282 BOOST_CHECK(hasResult);
283 BOOST_CHECK_EQUAL(failCodes.size(), 0);
284}
285
286BOOST_AUTO_TEST_CASE(FaceQuery)
287{
288 FaceQueryFilter filter;
289 filter.setUriScheme("udp4");
290 bool hasResult = false;
291 controller.fetch<FaceQueryDataset>(
292 filter,
293 [&hasResult] (const std::vector<FaceStatus>& result) {
294 hasResult = true;
295 BOOST_CHECK_EQUAL(result.size(), 1);
296 BOOST_CHECK_EQUAL(result.front().getFaceId(), 8795);
297 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000298 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500299 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000300
301 Name prefix("/localhost/nfd/faces/query");
302 prefix.append(filter.wireEncode());
303 FaceStatus payload;
304 payload.setFaceId(8795);
305 this->sendDataset(prefix, payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500306 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000307
308 BOOST_CHECK(hasResult);
309 BOOST_CHECK_EQUAL(failCodes.size(), 0);
310}
311
312BOOST_AUTO_TEST_CASE(FaceQueryWithOptions)
313{
314 FaceQueryFilter filter;
315 filter.setUriScheme("udp4");
316 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500317 options.setTimeout(3000_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000318 bool hasResult = false;
319 controller.fetch<FaceQueryDataset>(
320 filter,
321 [&hasResult] (const std::vector<FaceStatus>& result) {
322 hasResult = true;
323 BOOST_CHECK_EQUAL(result.size(), 1);
324 BOOST_CHECK_EQUAL(result.front().getFaceId(), 14022);
325 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000326 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000327 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500328 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000329
330 Name prefix("/localhost/nfd/faces/query");
331 prefix.append(filter.wireEncode());
332 FaceStatus payload;
333 payload.setFaceId(14022);
334 this->sendDataset(prefix, payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500335 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000336
337 BOOST_CHECK(hasResult);
338 BOOST_CHECK_EQUAL(failCodes.size(), 0);
339}
340
Junxiao Shi1eacb972016-07-07 22:51:07 +0000341BOOST_AUTO_TEST_CASE(FaceChannels)
342{
343 bool hasResult = false;
344 controller.fetch<ChannelDataset>(
345 [&hasResult] (const std::vector<ChannelStatus>& result) {
346 hasResult = true;
347 BOOST_CHECK_EQUAL(result.size(), 2);
348 BOOST_CHECK_EQUAL(result.front().getLocalUri(), "tcp4://192.0.2.1:6363");
349 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000350 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500351 this->advanceClocks(500_ms);
Junxiao Shi1eacb972016-07-07 22:51:07 +0000352
353 ChannelStatus payload1;
354 payload1.setLocalUri("tcp4://192.0.2.1:6363");
355 ChannelStatus payload2;
356 payload2.setLocalUri("udp4://192.0.2.1:6363");
357 this->sendDataset("/localhost/nfd/faces/channels", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500358 this->advanceClocks(500_ms);
Junxiao Shi1eacb972016-07-07 22:51:07 +0000359
360 BOOST_CHECK(hasResult);
361 BOOST_CHECK_EQUAL(failCodes.size(), 0);
362}
363
Junxiao Shi034c1882016-06-24 18:06:51 +0000364BOOST_AUTO_TEST_CASE(FibList)
365{
366 bool hasResult = false;
367 controller.fetch<FibDataset>(
368 [&hasResult] (const std::vector<FibEntry>& result) {
369 hasResult = true;
370 BOOST_CHECK_EQUAL(result.size(), 2);
371 BOOST_CHECK_EQUAL(result.front().getPrefix(), "/wYs7fzYcfG");
372 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000373 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500374 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000375
376 FibEntry payload1;
377 payload1.setPrefix("/wYs7fzYcfG");
378 FibEntry payload2;
379 payload2.setPrefix("/LKvmnzY5S");
380 this->sendDataset("/localhost/nfd/fib/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500381 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000382
383 BOOST_CHECK(hasResult);
384 BOOST_CHECK_EQUAL(failCodes.size(), 0);
385}
386
Junxiao Shi7f012472017-12-07 20:40:47 +0000387BOOST_AUTO_TEST_CASE(CsInfo)
388{
389 using ndn::nfd::CsInfo;
390
391 bool hasResult = false;
392 controller.fetch<CsInfoDataset>(
393 [&hasResult] (const CsInfo& result) {
394 hasResult = true;
395 BOOST_CHECK_EQUAL(result.getNHits(), 4539);
396 },
397 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500398 this->advanceClocks(500_ms);
Junxiao Shi7f012472017-12-07 20:40:47 +0000399
400 CsInfo payload;
401 payload.setNHits(4539);
402 this->sendDataset("/localhost/nfd/cs/info", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500403 this->advanceClocks(500_ms);
Junxiao Shi7f012472017-12-07 20:40:47 +0000404
405 BOOST_CHECK(hasResult);
406 BOOST_CHECK_EQUAL(failCodes.size(), 0);
407}
408
Junxiao Shi034c1882016-06-24 18:06:51 +0000409BOOST_AUTO_TEST_CASE(StrategyChoiceList)
410{
411 bool hasResult = false;
412 controller.fetch<StrategyChoiceDataset>(
413 [&hasResult] (const std::vector<StrategyChoice>& result) {
414 hasResult = true;
415 BOOST_CHECK_EQUAL(result.size(), 2);
416 BOOST_CHECK_EQUAL(result.front().getName(), "/8MLz6N3B");
417 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000418 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500419 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000420
421 StrategyChoice payload1;
422 payload1.setName("/8MLz6N3B");
423 StrategyChoice payload2;
424 payload2.setName("/svqcBu0YwU");
425 this->sendDataset("/localhost/nfd/strategy-choice/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500426 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000427
428 BOOST_CHECK(hasResult);
429 BOOST_CHECK_EQUAL(failCodes.size(), 0);
430}
431
432BOOST_AUTO_TEST_CASE(RibList)
433{
434 bool hasResult = false;
435 controller.fetch<RibDataset>(
436 [&hasResult] (const std::vector<RibEntry>& result) {
437 hasResult = true;
438 BOOST_CHECK_EQUAL(result.size(), 2);
439 BOOST_CHECK_EQUAL(result.front().getName(), "/zXxBth97ee");
440 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000441 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500442 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000443
444 RibEntry payload1;
445 payload1.setName("/zXxBth97ee");
446 RibEntry payload2;
447 payload2.setName("/rJ8CvUpr4G");
448 this->sendDataset("/localhost/nfd/rib/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500449 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000450
451 BOOST_CHECK(hasResult);
452 BOOST_CHECK_EQUAL(failCodes.size(), 0);
453}
454
455BOOST_AUTO_TEST_CASE(RibListWithOptions)
456{
457 CommandOptions options;
458 options.setPrefix("/localhop/nfd");
459 bool hasResult = false;
460 controller.fetch<RibDataset>(
461 [&hasResult] (const std::vector<RibEntry>& result) {
462 hasResult = true;
463 BOOST_CHECK_EQUAL(result.size(), 1);
464 BOOST_CHECK_EQUAL(result.front().getName(), "/e6L5K4ascd");
465 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000466 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000467 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500468 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000469
470 RibEntry payload;
471 payload.setName("/e6L5K4ascd");
472 this->sendDataset("/localhop/nfd/rib/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500473 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000474
475 BOOST_CHECK(hasResult);
476 BOOST_CHECK_EQUAL(failCodes.size(), 0);
477}
478
479BOOST_AUTO_TEST_SUITE_END() // Datasets
480
Junxiao Shi7357ef22016-09-07 02:39:37 +0000481BOOST_AUTO_TEST_SUITE_END() // TestStatusDataset
482BOOST_AUTO_TEST_SUITE_END() // Nfd
483BOOST_AUTO_TEST_SUITE_END() // Mgmt
Junxiao Shi034c1882016-06-24 18:06:51 +0000484
485} // namespace tests
486} // namespace nfd
487} // namespace ndn