blob: aac874b80a31649af231b33a41f76b21f1b10e79 [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/*
Junxiao Shi2ad2fbe2019-05-24 03:11:05 +00003 * Copyright (c) 2013-2019 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 Shi2ad2fbe2019-05-24 03:11:05 +0000102 data->setFreshnessPeriod(1_s);
Junxiao Shiebfe4a22018-04-01 23:53:40 +0000103 data->setFinalBlock(name[-1]);
Junxiao Shi034c1882016-06-24 18:06:51 +0000104 return data;
105 }
106};
107
Junxiao Shi7357ef22016-09-07 02:39:37 +0000108BOOST_FIXTURE_TEST_SUITE(TestStatusDataset, ControllerStatusDatasetFixture)
Junxiao Shi034c1882016-06-24 18:06:51 +0000109
110BOOST_AUTO_TEST_SUITE(Failures)
111
112BOOST_AUTO_TEST_CASE(Timeout)
113{
114 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500115 options.setTimeout(3000_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000116 controller.fetch<FaceDataset>(
117 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000118 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000119 options);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600120 this->advanceClocks(500_ms);
121 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 1);
Junxiao Shi034c1882016-06-24 18:06:51 +0000122
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600123 this->advanceClocks(500_ms, 6);
124 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 0);
Junxiao Shi034c1882016-06-24 18:06:51 +0000125 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
126 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_TIMEOUT);
127}
128
129BOOST_AUTO_TEST_CASE(DataHasNoSegment)
130{
131 controller.fetch<FaceDataset>(
132 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000133 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500134 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000135
Junxiao Shi2ad2fbe2019-05-24 03:11:05 +0000136 auto data = makeData("/localhost/nfd/faces/list/%FD%00");
137 data->setFreshnessPeriod(1_s);
138 face.receive(*data);
Davide Pesavento0f830802018-01-16 23:58:58 -0500139 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000140
141 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
142 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
143}
144
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000145BOOST_AUTO_TEST_CASE(ValidationFailure)
146{
147 this->setValidationResult(false);
148
149 controller.fetch<FaceDataset>(
150 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000151 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500152 this->advanceClocks(500_ms);
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000153
154 FaceStatus payload;
155 payload.setFaceId(5744);
156 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500157 this->advanceClocks(500_ms);
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000158
159 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
160 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_VALIDATION);
161}
162
Junxiao Shi034c1882016-06-24 18:06:51 +0000163BOOST_AUTO_TEST_CASE(Nack)
164{
165 controller.fetch<FaceDataset>(
166 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000167 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500168 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000169
170 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
171 face.receive(lp::Nack(face.sentInterests.back()));
Davide Pesavento0f830802018-01-16 23:58:58 -0500172 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000173
174 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
175 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_NACK);
176}
177
178BOOST_AUTO_TEST_CASE(ParseError1)
179{
180 controller.fetch<FaceDataset>(
181 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000182 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500183 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000184
185 Name payload; // Name is not valid FaceStatus
186 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500187 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000188
189 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
190 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
191}
192
193BOOST_AUTO_TEST_CASE(ParseError2)
194{
195 controller.fetch<FaceDataset>(
196 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000197 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500198 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000199
200 FaceStatus payload1;
201 payload1.setFaceId(10930);
202 Name payload2; // Name is not valid FaceStatus
203 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500204 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000205
206 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
207 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
208}
209
210BOOST_AUTO_TEST_SUITE_END() // Failures
211
Junxiao Shi600f7112016-07-16 11:57:18 +0000212BOOST_AUTO_TEST_SUITE(NoCallback)
213
214BOOST_AUTO_TEST_CASE(Success)
215{
216 controller.fetch<FaceDataset>(
217 nullptr,
Junxiao Shie7c7f152016-08-20 22:36:22 +0000218 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500219 this->advanceClocks(500_ms);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600220 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 1);
Junxiao Shi600f7112016-07-16 11:57:18 +0000221
222 FaceStatus payload;
223 payload.setFaceId(2577);
224 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500225 BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms));
Junxiao Shi600f7112016-07-16 11:57:18 +0000226
227 BOOST_CHECK_EQUAL(failCodes.size(), 0);
Ashlesh Gawande3e3a9892018-11-16 20:26:15 -0600228 BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 0);
Junxiao Shi600f7112016-07-16 11:57:18 +0000229}
230
231BOOST_AUTO_TEST_CASE(Failure)
232{
233 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500234 options.setTimeout(3000_ms);
Junxiao Shi600f7112016-07-16 11:57:18 +0000235 controller.fetch<FaceDataset>(
236 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
237 nullptr,
238 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500239 BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms, 7));
Junxiao Shi600f7112016-07-16 11:57:18 +0000240}
241
242BOOST_AUTO_TEST_SUITE_END() // NoCallback
243
Junxiao Shi034c1882016-06-24 18:06:51 +0000244BOOST_AUTO_TEST_SUITE(Datasets)
245
246BOOST_AUTO_TEST_CASE(StatusGeneral)
247{
248 bool hasResult = false;
249 controller.fetch<ForwarderGeneralStatusDataset>(
250 [&hasResult] (const ForwarderStatus& result) {
251 hasResult = true;
252 BOOST_CHECK_EQUAL(result.getNfdVersion(), "0.4.2");
253 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000254 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500255 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000256
257 ForwarderStatus payload;
258 payload.setNfdVersion("0.4.2");
259 this->sendDataset("/localhost/nfd/status/general", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500260 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000261
262 BOOST_CHECK(hasResult);
263 BOOST_CHECK_EQUAL(failCodes.size(), 0);
264}
265
266BOOST_AUTO_TEST_CASE(FaceList)
267{
268 bool hasResult = false;
269 controller.fetch<FaceDataset>(
270 [&hasResult] (const std::vector<FaceStatus>& result) {
271 hasResult = true;
272 BOOST_CHECK_EQUAL(result.size(), 2);
273 BOOST_CHECK_EQUAL(result.front().getFaceId(), 24485);
274 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000275 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500276 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000277
278 FaceStatus payload1;
279 payload1.setFaceId(24485);
280 FaceStatus payload2;
281 payload2.setFaceId(12987);
282 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500283 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000284
285 BOOST_CHECK(hasResult);
286 BOOST_CHECK_EQUAL(failCodes.size(), 0);
287}
288
289BOOST_AUTO_TEST_CASE(FaceQuery)
290{
291 FaceQueryFilter filter;
292 filter.setUriScheme("udp4");
293 bool hasResult = false;
294 controller.fetch<FaceQueryDataset>(
295 filter,
296 [&hasResult] (const std::vector<FaceStatus>& result) {
297 hasResult = true;
298 BOOST_CHECK_EQUAL(result.size(), 1);
299 BOOST_CHECK_EQUAL(result.front().getFaceId(), 8795);
300 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000301 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500302 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000303
304 Name prefix("/localhost/nfd/faces/query");
305 prefix.append(filter.wireEncode());
306 FaceStatus payload;
307 payload.setFaceId(8795);
308 this->sendDataset(prefix, payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500309 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000310
311 BOOST_CHECK(hasResult);
312 BOOST_CHECK_EQUAL(failCodes.size(), 0);
313}
314
315BOOST_AUTO_TEST_CASE(FaceQueryWithOptions)
316{
317 FaceQueryFilter filter;
318 filter.setUriScheme("udp4");
319 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500320 options.setTimeout(3000_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000321 bool hasResult = false;
322 controller.fetch<FaceQueryDataset>(
323 filter,
324 [&hasResult] (const std::vector<FaceStatus>& result) {
325 hasResult = true;
326 BOOST_CHECK_EQUAL(result.size(), 1);
327 BOOST_CHECK_EQUAL(result.front().getFaceId(), 14022);
328 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000329 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000330 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500331 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000332
333 Name prefix("/localhost/nfd/faces/query");
334 prefix.append(filter.wireEncode());
335 FaceStatus payload;
336 payload.setFaceId(14022);
337 this->sendDataset(prefix, payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500338 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000339
340 BOOST_CHECK(hasResult);
341 BOOST_CHECK_EQUAL(failCodes.size(), 0);
342}
343
Junxiao Shi1eacb972016-07-07 22:51:07 +0000344BOOST_AUTO_TEST_CASE(FaceChannels)
345{
346 bool hasResult = false;
347 controller.fetch<ChannelDataset>(
348 [&hasResult] (const std::vector<ChannelStatus>& result) {
349 hasResult = true;
350 BOOST_CHECK_EQUAL(result.size(), 2);
351 BOOST_CHECK_EQUAL(result.front().getLocalUri(), "tcp4://192.0.2.1:6363");
352 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000353 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500354 this->advanceClocks(500_ms);
Junxiao Shi1eacb972016-07-07 22:51:07 +0000355
356 ChannelStatus payload1;
357 payload1.setLocalUri("tcp4://192.0.2.1:6363");
358 ChannelStatus payload2;
359 payload2.setLocalUri("udp4://192.0.2.1:6363");
360 this->sendDataset("/localhost/nfd/faces/channels", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500361 this->advanceClocks(500_ms);
Junxiao Shi1eacb972016-07-07 22:51:07 +0000362
363 BOOST_CHECK(hasResult);
364 BOOST_CHECK_EQUAL(failCodes.size(), 0);
365}
366
Junxiao Shi034c1882016-06-24 18:06:51 +0000367BOOST_AUTO_TEST_CASE(FibList)
368{
369 bool hasResult = false;
370 controller.fetch<FibDataset>(
371 [&hasResult] (const std::vector<FibEntry>& result) {
372 hasResult = true;
373 BOOST_CHECK_EQUAL(result.size(), 2);
374 BOOST_CHECK_EQUAL(result.front().getPrefix(), "/wYs7fzYcfG");
375 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000376 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500377 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000378
379 FibEntry payload1;
380 payload1.setPrefix("/wYs7fzYcfG");
381 FibEntry payload2;
382 payload2.setPrefix("/LKvmnzY5S");
383 this->sendDataset("/localhost/nfd/fib/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500384 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000385
386 BOOST_CHECK(hasResult);
387 BOOST_CHECK_EQUAL(failCodes.size(), 0);
388}
389
Junxiao Shi7f012472017-12-07 20:40:47 +0000390BOOST_AUTO_TEST_CASE(CsInfo)
391{
392 using ndn::nfd::CsInfo;
393
394 bool hasResult = false;
395 controller.fetch<CsInfoDataset>(
396 [&hasResult] (const CsInfo& result) {
397 hasResult = true;
398 BOOST_CHECK_EQUAL(result.getNHits(), 4539);
399 },
400 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500401 this->advanceClocks(500_ms);
Junxiao Shi7f012472017-12-07 20:40:47 +0000402
403 CsInfo payload;
404 payload.setNHits(4539);
405 this->sendDataset("/localhost/nfd/cs/info", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500406 this->advanceClocks(500_ms);
Junxiao Shi7f012472017-12-07 20:40:47 +0000407
408 BOOST_CHECK(hasResult);
409 BOOST_CHECK_EQUAL(failCodes.size(), 0);
410}
411
Junxiao Shi034c1882016-06-24 18:06:51 +0000412BOOST_AUTO_TEST_CASE(StrategyChoiceList)
413{
414 bool hasResult = false;
415 controller.fetch<StrategyChoiceDataset>(
416 [&hasResult] (const std::vector<StrategyChoice>& result) {
417 hasResult = true;
418 BOOST_CHECK_EQUAL(result.size(), 2);
419 BOOST_CHECK_EQUAL(result.front().getName(), "/8MLz6N3B");
420 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000421 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500422 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000423
424 StrategyChoice payload1;
425 payload1.setName("/8MLz6N3B");
426 StrategyChoice payload2;
427 payload2.setName("/svqcBu0YwU");
428 this->sendDataset("/localhost/nfd/strategy-choice/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500429 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000430
431 BOOST_CHECK(hasResult);
432 BOOST_CHECK_EQUAL(failCodes.size(), 0);
433}
434
435BOOST_AUTO_TEST_CASE(RibList)
436{
437 bool hasResult = false;
438 controller.fetch<RibDataset>(
439 [&hasResult] (const std::vector<RibEntry>& result) {
440 hasResult = true;
441 BOOST_CHECK_EQUAL(result.size(), 2);
442 BOOST_CHECK_EQUAL(result.front().getName(), "/zXxBth97ee");
443 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000444 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500445 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000446
447 RibEntry payload1;
448 payload1.setName("/zXxBth97ee");
449 RibEntry payload2;
450 payload2.setName("/rJ8CvUpr4G");
451 this->sendDataset("/localhost/nfd/rib/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500452 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000453
454 BOOST_CHECK(hasResult);
455 BOOST_CHECK_EQUAL(failCodes.size(), 0);
456}
457
458BOOST_AUTO_TEST_CASE(RibListWithOptions)
459{
460 CommandOptions options;
461 options.setPrefix("/localhop/nfd");
462 bool hasResult = false;
463 controller.fetch<RibDataset>(
464 [&hasResult] (const std::vector<RibEntry>& result) {
465 hasResult = true;
466 BOOST_CHECK_EQUAL(result.size(), 1);
467 BOOST_CHECK_EQUAL(result.front().getName(), "/e6L5K4ascd");
468 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000469 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000470 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500471 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000472
473 RibEntry payload;
474 payload.setName("/e6L5K4ascd");
475 this->sendDataset("/localhop/nfd/rib/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500476 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000477
478 BOOST_CHECK(hasResult);
479 BOOST_CHECK_EQUAL(failCodes.size(), 0);
480}
481
482BOOST_AUTO_TEST_SUITE_END() // Datasets
483
Junxiao Shi7357ef22016-09-07 02:39:37 +0000484BOOST_AUTO_TEST_SUITE_END() // TestStatusDataset
485BOOST_AUTO_TEST_SUITE_END() // Nfd
486BOOST_AUTO_TEST_SUITE_END() // Mgmt
Junxiao Shi034c1882016-06-24 18:06:51 +0000487
488} // namespace tests
489} // namespace nfd
490} // namespace ndn