blob: 12a7fa1b11729a52dd8f1ab67d7bd407d4633764 [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);
Davide Pesavento0f830802018-01-16 23:58:58 -0500118 this->advanceClocks(500_ms, 7);
Junxiao Shi034c1882016-06-24 18:06:51 +0000119
120 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
121 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_TIMEOUT);
122}
123
124BOOST_AUTO_TEST_CASE(DataHasNoSegment)
125{
126 controller.fetch<FaceDataset>(
127 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000128 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500129 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000130
131 face.receive(*makeData("/localhost/nfd/faces/list/%FD%00"));
Davide Pesavento0f830802018-01-16 23:58:58 -0500132 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000133
134 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
135 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
136}
137
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000138BOOST_AUTO_TEST_CASE(ValidationFailure)
139{
140 this->setValidationResult(false);
141
142 controller.fetch<FaceDataset>(
143 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000144 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500145 this->advanceClocks(500_ms);
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000146
147 FaceStatus payload;
148 payload.setFaceId(5744);
149 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500150 this->advanceClocks(500_ms);
Junxiao Shi0f3f0b42016-07-14 13:26:37 +0000151
152 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
153 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_VALIDATION);
154}
155
Junxiao Shi034c1882016-06-24 18:06:51 +0000156BOOST_AUTO_TEST_CASE(Nack)
157{
158 controller.fetch<FaceDataset>(
159 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000160 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500161 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000162
163 BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
164 face.receive(lp::Nack(face.sentInterests.back()));
Davide Pesavento0f830802018-01-16 23:58:58 -0500165 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000166
167 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
168 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_NACK);
169}
170
171BOOST_AUTO_TEST_CASE(ParseError1)
172{
173 controller.fetch<FaceDataset>(
174 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000175 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500176 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000177
178 Name payload; // Name is not valid FaceStatus
179 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500180 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000181
182 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
183 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
184}
185
186BOOST_AUTO_TEST_CASE(ParseError2)
187{
188 controller.fetch<FaceDataset>(
189 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000190 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500191 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000192
193 FaceStatus payload1;
194 payload1.setFaceId(10930);
195 Name payload2; // Name is not valid FaceStatus
196 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500197 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000198
199 BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
200 BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER);
201}
202
203BOOST_AUTO_TEST_SUITE_END() // Failures
204
Junxiao Shi600f7112016-07-16 11:57:18 +0000205BOOST_AUTO_TEST_SUITE(NoCallback)
206
207BOOST_AUTO_TEST_CASE(Success)
208{
209 controller.fetch<FaceDataset>(
210 nullptr,
Junxiao Shie7c7f152016-08-20 22:36:22 +0000211 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500212 this->advanceClocks(500_ms);
Junxiao Shi600f7112016-07-16 11:57:18 +0000213
214 FaceStatus payload;
215 payload.setFaceId(2577);
216 this->sendDataset("/localhost/nfd/faces/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500217 BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms));
Junxiao Shi600f7112016-07-16 11:57:18 +0000218
219 BOOST_CHECK_EQUAL(failCodes.size(), 0);
220}
221
222BOOST_AUTO_TEST_CASE(Failure)
223{
224 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500225 options.setTimeout(3000_ms);
Junxiao Shi600f7112016-07-16 11:57:18 +0000226 controller.fetch<FaceDataset>(
227 [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
228 nullptr,
229 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500230 BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms, 7));
Junxiao Shi600f7112016-07-16 11:57:18 +0000231}
232
233BOOST_AUTO_TEST_SUITE_END() // NoCallback
234
Junxiao Shi034c1882016-06-24 18:06:51 +0000235BOOST_AUTO_TEST_SUITE(Datasets)
236
237BOOST_AUTO_TEST_CASE(StatusGeneral)
238{
239 bool hasResult = false;
240 controller.fetch<ForwarderGeneralStatusDataset>(
241 [&hasResult] (const ForwarderStatus& result) {
242 hasResult = true;
243 BOOST_CHECK_EQUAL(result.getNfdVersion(), "0.4.2");
244 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000245 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500246 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000247
248 ForwarderStatus payload;
249 payload.setNfdVersion("0.4.2");
250 this->sendDataset("/localhost/nfd/status/general", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500251 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000252
253 BOOST_CHECK(hasResult);
254 BOOST_CHECK_EQUAL(failCodes.size(), 0);
255}
256
257BOOST_AUTO_TEST_CASE(FaceList)
258{
259 bool hasResult = false;
260 controller.fetch<FaceDataset>(
261 [&hasResult] (const std::vector<FaceStatus>& result) {
262 hasResult = true;
263 BOOST_CHECK_EQUAL(result.size(), 2);
264 BOOST_CHECK_EQUAL(result.front().getFaceId(), 24485);
265 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000266 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500267 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000268
269 FaceStatus payload1;
270 payload1.setFaceId(24485);
271 FaceStatus payload2;
272 payload2.setFaceId(12987);
273 this->sendDataset("/localhost/nfd/faces/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500274 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000275
276 BOOST_CHECK(hasResult);
277 BOOST_CHECK_EQUAL(failCodes.size(), 0);
278}
279
280BOOST_AUTO_TEST_CASE(FaceQuery)
281{
282 FaceQueryFilter filter;
283 filter.setUriScheme("udp4");
284 bool hasResult = false;
285 controller.fetch<FaceQueryDataset>(
286 filter,
287 [&hasResult] (const std::vector<FaceStatus>& result) {
288 hasResult = true;
289 BOOST_CHECK_EQUAL(result.size(), 1);
290 BOOST_CHECK_EQUAL(result.front().getFaceId(), 8795);
291 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000292 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500293 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000294
295 Name prefix("/localhost/nfd/faces/query");
296 prefix.append(filter.wireEncode());
297 FaceStatus payload;
298 payload.setFaceId(8795);
299 this->sendDataset(prefix, payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500300 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000301
302 BOOST_CHECK(hasResult);
303 BOOST_CHECK_EQUAL(failCodes.size(), 0);
304}
305
306BOOST_AUTO_TEST_CASE(FaceQueryWithOptions)
307{
308 FaceQueryFilter filter;
309 filter.setUriScheme("udp4");
310 CommandOptions options;
Davide Pesavento0f830802018-01-16 23:58:58 -0500311 options.setTimeout(3000_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000312 bool hasResult = false;
313 controller.fetch<FaceQueryDataset>(
314 filter,
315 [&hasResult] (const std::vector<FaceStatus>& result) {
316 hasResult = true;
317 BOOST_CHECK_EQUAL(result.size(), 1);
318 BOOST_CHECK_EQUAL(result.front().getFaceId(), 14022);
319 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000320 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000321 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500322 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000323
324 Name prefix("/localhost/nfd/faces/query");
325 prefix.append(filter.wireEncode());
326 FaceStatus payload;
327 payload.setFaceId(14022);
328 this->sendDataset(prefix, payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500329 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000330
331 BOOST_CHECK(hasResult);
332 BOOST_CHECK_EQUAL(failCodes.size(), 0);
333}
334
Junxiao Shi1eacb972016-07-07 22:51:07 +0000335BOOST_AUTO_TEST_CASE(FaceChannels)
336{
337 bool hasResult = false;
338 controller.fetch<ChannelDataset>(
339 [&hasResult] (const std::vector<ChannelStatus>& result) {
340 hasResult = true;
341 BOOST_CHECK_EQUAL(result.size(), 2);
342 BOOST_CHECK_EQUAL(result.front().getLocalUri(), "tcp4://192.0.2.1:6363");
343 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000344 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500345 this->advanceClocks(500_ms);
Junxiao Shi1eacb972016-07-07 22:51:07 +0000346
347 ChannelStatus payload1;
348 payload1.setLocalUri("tcp4://192.0.2.1:6363");
349 ChannelStatus payload2;
350 payload2.setLocalUri("udp4://192.0.2.1:6363");
351 this->sendDataset("/localhost/nfd/faces/channels", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500352 this->advanceClocks(500_ms);
Junxiao Shi1eacb972016-07-07 22:51:07 +0000353
354 BOOST_CHECK(hasResult);
355 BOOST_CHECK_EQUAL(failCodes.size(), 0);
356}
357
Junxiao Shi034c1882016-06-24 18:06:51 +0000358BOOST_AUTO_TEST_CASE(FibList)
359{
360 bool hasResult = false;
361 controller.fetch<FibDataset>(
362 [&hasResult] (const std::vector<FibEntry>& result) {
363 hasResult = true;
364 BOOST_CHECK_EQUAL(result.size(), 2);
365 BOOST_CHECK_EQUAL(result.front().getPrefix(), "/wYs7fzYcfG");
366 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000367 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500368 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000369
370 FibEntry payload1;
371 payload1.setPrefix("/wYs7fzYcfG");
372 FibEntry payload2;
373 payload2.setPrefix("/LKvmnzY5S");
374 this->sendDataset("/localhost/nfd/fib/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500375 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000376
377 BOOST_CHECK(hasResult);
378 BOOST_CHECK_EQUAL(failCodes.size(), 0);
379}
380
Junxiao Shi7f012472017-12-07 20:40:47 +0000381BOOST_AUTO_TEST_CASE(CsInfo)
382{
383 using ndn::nfd::CsInfo;
384
385 bool hasResult = false;
386 controller.fetch<CsInfoDataset>(
387 [&hasResult] (const CsInfo& result) {
388 hasResult = true;
389 BOOST_CHECK_EQUAL(result.getNHits(), 4539);
390 },
391 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500392 this->advanceClocks(500_ms);
Junxiao Shi7f012472017-12-07 20:40:47 +0000393
394 CsInfo payload;
395 payload.setNHits(4539);
396 this->sendDataset("/localhost/nfd/cs/info", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500397 this->advanceClocks(500_ms);
Junxiao Shi7f012472017-12-07 20:40:47 +0000398
399 BOOST_CHECK(hasResult);
400 BOOST_CHECK_EQUAL(failCodes.size(), 0);
401}
402
Junxiao Shi034c1882016-06-24 18:06:51 +0000403BOOST_AUTO_TEST_CASE(StrategyChoiceList)
404{
405 bool hasResult = false;
406 controller.fetch<StrategyChoiceDataset>(
407 [&hasResult] (const std::vector<StrategyChoice>& result) {
408 hasResult = true;
409 BOOST_CHECK_EQUAL(result.size(), 2);
410 BOOST_CHECK_EQUAL(result.front().getName(), "/8MLz6N3B");
411 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000412 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500413 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000414
415 StrategyChoice payload1;
416 payload1.setName("/8MLz6N3B");
417 StrategyChoice payload2;
418 payload2.setName("/svqcBu0YwU");
419 this->sendDataset("/localhost/nfd/strategy-choice/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500420 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000421
422 BOOST_CHECK(hasResult);
423 BOOST_CHECK_EQUAL(failCodes.size(), 0);
424}
425
426BOOST_AUTO_TEST_CASE(RibList)
427{
428 bool hasResult = false;
429 controller.fetch<RibDataset>(
430 [&hasResult] (const std::vector<RibEntry>& result) {
431 hasResult = true;
432 BOOST_CHECK_EQUAL(result.size(), 2);
433 BOOST_CHECK_EQUAL(result.front().getName(), "/zXxBth97ee");
434 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000435 datasetFailCallback);
Davide Pesavento0f830802018-01-16 23:58:58 -0500436 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000437
438 RibEntry payload1;
439 payload1.setName("/zXxBth97ee");
440 RibEntry payload2;
441 payload2.setName("/rJ8CvUpr4G");
442 this->sendDataset("/localhost/nfd/rib/list", payload1, payload2);
Davide Pesavento0f830802018-01-16 23:58:58 -0500443 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000444
445 BOOST_CHECK(hasResult);
446 BOOST_CHECK_EQUAL(failCodes.size(), 0);
447}
448
449BOOST_AUTO_TEST_CASE(RibListWithOptions)
450{
451 CommandOptions options;
452 options.setPrefix("/localhop/nfd");
453 bool hasResult = false;
454 controller.fetch<RibDataset>(
455 [&hasResult] (const std::vector<RibEntry>& result) {
456 hasResult = true;
457 BOOST_CHECK_EQUAL(result.size(), 1);
458 BOOST_CHECK_EQUAL(result.front().getName(), "/e6L5K4ascd");
459 },
Junxiao Shie7c7f152016-08-20 22:36:22 +0000460 datasetFailCallback,
Junxiao Shi034c1882016-06-24 18:06:51 +0000461 options);
Davide Pesavento0f830802018-01-16 23:58:58 -0500462 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000463
464 RibEntry payload;
465 payload.setName("/e6L5K4ascd");
466 this->sendDataset("/localhop/nfd/rib/list", payload);
Davide Pesavento0f830802018-01-16 23:58:58 -0500467 this->advanceClocks(500_ms);
Junxiao Shi034c1882016-06-24 18:06:51 +0000468
469 BOOST_CHECK(hasResult);
470 BOOST_CHECK_EQUAL(failCodes.size(), 0);
471}
472
473BOOST_AUTO_TEST_SUITE_END() // Datasets
474
Junxiao Shi7357ef22016-09-07 02:39:37 +0000475BOOST_AUTO_TEST_SUITE_END() // TestStatusDataset
476BOOST_AUTO_TEST_SUITE_END() // Nfd
477BOOST_AUTO_TEST_SUITE_END() // Mgmt
Junxiao Shi034c1882016-06-24 18:06:51 +0000478
479} // namespace tests
480} // namespace nfd
481} // namespace ndn