blob: a436de05a46c9e0bf185507289005396cb269bc7 [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
Junxiao Shi7357ef22016-09-07 02:39:37 +000022#include "mgmt/nfd/status-dataset.hpp"
23#include "mgmt/nfd/controller.hpp"
Junxiao Shi034c1882016-06-24 18:06:51 +000024
Junxiao Shi7357ef22016-09-07 02:39:37 +000025#include "controller-fixture.hpp"
Junxiao Shi2bea5c42017-08-14 20:10:32 +000026#include "make-interest-data.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 Shiebfe4a22018-04-01 23:53:40 +0000101 data->setFinalBlock(name[-1]);
Junxiao Shi034c1882016-06-24 18:06:51 +0000102 return data;
103 }
104};
105
Junxiao Shi7357ef22016-09-07 02:39:37 +0000106BOOST_FIXTURE_TEST_SUITE(TestStatusDataset, ControllerStatusDatasetFixture)
Junxiao Shi034c1882016-06-24 18:06:51 +0000107
108BOOST_AUTO_TEST_SUITE(Failures)
109
110BOOST_AUTO_TEST_CASE(Timeout)
111{
112 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500113 options.setTimeout(3000_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000114 controller.fetch<FaceDataset>(
115 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000116 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000117 options);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600118 this->advanceClocks(500_ms);
119 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 1);
Junxiao Shi034c1882016-06-24 18:06:51 +0000120
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600121 this->advanceClocks(500_ms, 6);
122 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 0);
Junxiao Shi034c1882016-06-24 18:06:51 +0000123 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
124 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_TIMEOUT);
125}
126
127BOOST_AUTO_TEST_CASE(DataHasNoSegment)
128{
129 controller.fetch<FaceDataset>(
130 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000131 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500132 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000133
134 face.receive(*makeData("/localhost/nfd/faces/list/%FD%00"));
Davide Pesavento0f830802018-01-16 23:58:58 -0500135 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000136
137 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
138 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
139}
140
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000141BOOST_AUTO_TEST_CASE(ValidationFailure)
142{
143 this->setValidationResult(false);
144
145 controller.fetch<FaceDataset>(
146 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000147 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500148 this->advanceClocks(500_ms);
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000149
150 FaceStatus payload;
151 payload.setFaceId(5744);
152 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500153 this->advanceClocks(500_ms);
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000154
155 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
156 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_VALIDATION);
157}
158
Junxiao Shi034c1882016-06-24 18:06:51 +0000159BOOST_AUTO_TEST_CASE(Nack)
160{
161 controller.fetch<FaceDataset>(
162 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000163 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500164 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000165
166 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
167 face.receive(lp::Nack(face.sentInterests.back()));
Davide Pesavento0f830802018-01-16 23:58:58 -0500168 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000169
170 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
171 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_NACK);
172}
173
174BOOST_AUTO_TEST_CASE(ParseError1)
175{
176 controller.fetch<FaceDataset>(
177 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000178 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500179 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000180
181 Name payload; // Name is not valid FaceStatus
182 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500183 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000184
185 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
186 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
187}
188
189BOOST_AUTO_TEST_CASE(ParseError2)
190{
191 controller.fetch<FaceDataset>(
192 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000193 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500194 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000195
196 FaceStatus payload1;
197 payload1.setFaceId(10930);
198 Name payload2; // Name is not valid FaceStatus
199 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500200 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000201
202 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
203 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
204}
205
206BOOST_AUTO_TEST_SUITE_END() // Failures
207
Junxiao Shi600f7112016-07-16 11:57:18 +0000208BOOST_AUTO_TEST_SUITE(NoCallback)
209
210BOOST_AUTO_TEST_CASE(Success)
211{
212 controller.fetch<FaceDataset>(
213 nullptr,
Junxiao Shie7c7f152016-08-20 22:36:22 +0000214 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500215 this->advanceClocks(500_ms);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600216 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 1);
Junxiao Shi600f7112016-07-16 11:57:18 +0000217
218 FaceStatus payload;
219 payload.setFaceId(2577);
220 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500221 BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms));
Junxiao Shi600f7112016-07-16 11:57:18 +0000222
223 BOOST_CHECK_EQUAL(failCodes.size(), 0);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600224 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 0);
Junxiao Shi600f7112016-07-16 11:57:18 +0000225}
226
227BOOST_AUTO_TEST_CASE(Failure)
228{
229 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500230 options.setTimeout(3000_ms);
Junxiao Shi600f7112016-07-16 11:57:18 +0000231 controller.fetch<FaceDataset>(
232 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
233 nullptr,
234 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500235 BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms, 7));
Junxiao Shi600f7112016-07-16 11:57:18 +0000236}
237
238BOOST_AUTO_TEST_SUITE_END() // NoCallback
239
Junxiao Shi034c1882016-06-24 18:06:51 +0000240BOOST_AUTO_TEST_SUITE(Datasets)
241
242BOOST_AUTO_TEST_CASE(StatusGeneral)
243{
244 bool hasResult = false;
245 controller.fetch<ForwarderGeneralStatusDataset>(
246 [&hasResult] (const ForwarderStatus& result) {
247 hasResult = true;
248 BOOST_CHECK_EQUAL(result.getNfdVersion(), "0.4.2");
249 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000250 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500251 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000252
253 ForwarderStatus payload;
254 payload.setNfdVersion("0.4.2");
255 this->sendDataset("/localhost/nfd/status/general", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500256 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000257
258 BOOST_CHECK(hasResult);
259 BOOST_CHECK_EQUAL(failCodes.size(), 0);
260}
261
262BOOST_AUTO_TEST_CASE(FaceList)
263{
264 bool hasResult = false;
265 controller.fetch<FaceDataset>(
266 [&hasResult] (const std::vector<FaceStatus>& result) {
267 hasResult = true;
268 BOOST_CHECK_EQUAL(result.size(), 2);
269 BOOST_CHECK_EQUAL(result.front().getFaceId(), 24485);
270 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000271 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500272 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000273
274 FaceStatus payload1;
275 payload1.setFaceId(24485);
276 FaceStatus payload2;
277 payload2.setFaceId(12987);
278 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500279 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000280
281 BOOST_CHECK(hasResult);
282 BOOST_CHECK_EQUAL(failCodes.size(), 0);
283}
284
285BOOST_AUTO_TEST_CASE(FaceQuery)
286{
287 FaceQueryFilter filter;
288 filter.setUriScheme("udp4");
289 bool hasResult = false;
290 controller.fetch<FaceQueryDataset>(
291 filter,
292 [&hasResult] (const std::vector<FaceStatus>& result) {
293 hasResult = true;
294 BOOST_CHECK_EQUAL(result.size(), 1);
295 BOOST_CHECK_EQUAL(result.front().getFaceId(), 8795);
296 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000297 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500298 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000299
300 Name prefix("/localhost/nfd/faces/query");
301 prefix.append(filter.wireEncode());
302 FaceStatus payload;
303 payload.setFaceId(8795);
304 this->sendDataset(prefix, payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500305 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000306
307 BOOST_CHECK(hasResult);
308 BOOST_CHECK_EQUAL(failCodes.size(), 0);
309}
310
311BOOST_AUTO_TEST_CASE(FaceQueryWithOptions)
312{
313 FaceQueryFilter filter;
314 filter.setUriScheme("udp4");
315 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500316 options.setTimeout(3000_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000317 bool hasResult = false;
318 controller.fetch<FaceQueryDataset>(
319 filter,
320 [&hasResult] (const std::vector<FaceStatus>& result) {
321 hasResult = true;
322 BOOST_CHECK_EQUAL(result.size(), 1);
323 BOOST_CHECK_EQUAL(result.front().getFaceId(), 14022);
324 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000325 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000326 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500327 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000328
329 Name prefix("/localhost/nfd/faces/query");
330 prefix.append(filter.wireEncode());
331 FaceStatus payload;
332 payload.setFaceId(14022);
333 this->sendDataset(prefix, payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500334 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000335
336 BOOST_CHECK(hasResult);
337 BOOST_CHECK_EQUAL(failCodes.size(), 0);
338}
339
Junxiao Shi1eacb972016-07-07 22:51:07 +0000340BOOST_AUTO_TEST_CASE(FaceChannels)
341{
342 bool hasResult = false;
343 controller.fetch<ChannelDataset>(
344 [&hasResult] (const std::vector<ChannelStatus>& result) {
345 hasResult = true;
346 BOOST_CHECK_EQUAL(result.size(), 2);
347 BOOST_CHECK_EQUAL(result.front().getLocalUri(), "tcp4://192.0.2.1:6363");
348 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000349 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500350 this->advanceClocks(500_ms);
Junxiao Shi1eacb972016-07-07 22:51:07 +0000351
352 ChannelStatus payload1;
353 payload1.setLocalUri("tcp4://192.0.2.1:6363");
354 ChannelStatus payload2;
355 payload2.setLocalUri("udp4://192.0.2.1:6363");
356 this->sendDataset("/localhost/nfd/faces/channels", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500357 this->advanceClocks(500_ms);
Junxiao Shi1eacb972016-07-07 22:51:07 +0000358
359 BOOST_CHECK(hasResult);
360 BOOST_CHECK_EQUAL(failCodes.size(), 0);
361}
362
Junxiao Shi034c1882016-06-24 18:06:51 +0000363BOOST_AUTO_TEST_CASE(FibList)
364{
365 bool hasResult = false;
366 controller.fetch<FibDataset>(
367 [&hasResult] (const std::vector<FibEntry>& result) {
368 hasResult = true;
369 BOOST_CHECK_EQUAL(result.size(), 2);
370 BOOST_CHECK_EQUAL(result.front().getPrefix(), "/wYs7fzYcfG");
371 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000372 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500373 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000374
375 FibEntry payload1;
376 payload1.setPrefix("/wYs7fzYcfG");
377 FibEntry payload2;
378 payload2.setPrefix("/LKvmnzY5S");
379 this->sendDataset("/localhost/nfd/fib/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500380 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000381
382 BOOST_CHECK(hasResult);
383 BOOST_CHECK_EQUAL(failCodes.size(), 0);
384}
385
Junxiao Shi7f012472017-12-07 20:40:47 +0000386BOOST_AUTO_TEST_CASE(CsInfo)
387{
388 using ndn::nfd::CsInfo;
389
390 bool hasResult = false;
391 controller.fetch<CsInfoDataset>(
392 [&hasResult] (const CsInfo& result) {
393 hasResult = true;
394 BOOST_CHECK_EQUAL(result.getNHits(), 4539);
395 },
396 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500397 this->advanceClocks(500_ms);
Junxiao Shi7f012472017-12-07 20:40:47 +0000398
399 CsInfo payload;
400 payload.setNHits(4539);
401 this->sendDataset("/localhost/nfd/cs/info", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500402 this->advanceClocks(500_ms);
Junxiao Shi7f012472017-12-07 20:40:47 +0000403
404 BOOST_CHECK(hasResult);
405 BOOST_CHECK_EQUAL(failCodes.size(), 0);
406}
407
Junxiao Shi034c1882016-06-24 18:06:51 +0000408BOOST_AUTO_TEST_CASE(StrategyChoiceList)
409{
410 bool hasResult = false;
411 controller.fetch<StrategyChoiceDataset>(
412 [&hasResult] (const std::vector<StrategyChoice>& result) {
413 hasResult = true;
414 BOOST_CHECK_EQUAL(result.size(), 2);
415 BOOST_CHECK_EQUAL(result.front().getName(), "/8MLz6N3B");
416 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000417 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500418 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000419
420 StrategyChoice payload1;
421 payload1.setName("/8MLz6N3B");
422 StrategyChoice payload2;
423 payload2.setName("/svqcBu0YwU");
424 this->sendDataset("/localhost/nfd/strategy-choice/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500425 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000426
427 BOOST_CHECK(hasResult);
428 BOOST_CHECK_EQUAL(failCodes.size(), 0);
429}
430
431BOOST_AUTO_TEST_CASE(RibList)
432{
433 bool hasResult = false;
434 controller.fetch<RibDataset>(
435 [&hasResult] (const std::vector<RibEntry>& result) {
436 hasResult = true;
437 BOOST_CHECK_EQUAL(result.size(), 2);
438 BOOST_CHECK_EQUAL(result.front().getName(), "/zXxBth97ee");
439 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000440 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500441 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000442
443 RibEntry payload1;
444 payload1.setName("/zXxBth97ee");
445 RibEntry payload2;
446 payload2.setName("/rJ8CvUpr4G");
447 this->sendDataset("/localhost/nfd/rib/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500448 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000449
450 BOOST_CHECK(hasResult);
451 BOOST_CHECK_EQUAL(failCodes.size(), 0);
452}
453
454BOOST_AUTO_TEST_CASE(RibListWithOptions)
455{
456 CommandOptions options;
457 options.setPrefix("/localhop/nfd");
458 bool hasResult = false;
459 controller.fetch<RibDataset>(
460 [&hasResult] (const std::vector<RibEntry>& result) {
461 hasResult = true;
462 BOOST_CHECK_EQUAL(result.size(), 1);
463 BOOST_CHECK_EQUAL(result.front().getName(), "/e6L5K4ascd");
464 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000465 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000466 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500467 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000468
469 RibEntry payload;
470 payload.setName("/e6L5K4ascd");
471 this->sendDataset("/localhop/nfd/rib/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500472 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000473
474 BOOST_CHECK(hasResult);
475 BOOST_CHECK_EQUAL(failCodes.size(), 0);
476}
477
478BOOST_AUTO_TEST_SUITE_END() // Datasets
479
Junxiao Shi7357ef22016-09-07 02:39:37 +0000480BOOST_AUTO_TEST_SUITE_END() // TestStatusDataset
481BOOST_AUTO_TEST_SUITE_END() // Nfd
482BOOST_AUTO_TEST_SUITE_END() // Mgmt
Junxiao Shi034c1882016-06-24 18:06:51 +0000483
484} // namespace tests
485} // namespace nfd
486} // namespace ndn