Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | 2bea5c4 | 2017-08-14 20:10:32 +0000 | [diff] [blame] | 2 | /* |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 3 | * Copyright (c) 2013-2018 Regents of the University of California. |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 4 | * |
| 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 Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 22 | #include "mgmt/nfd/status-dataset.hpp" |
| 23 | #include "mgmt/nfd/controller.hpp" |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 24 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 25 | #include "controller-fixture.hpp" |
Junxiao Shi | 2bea5c4 | 2017-08-14 20:10:32 +0000 | [diff] [blame] | 26 | #include "make-interest-data.hpp" |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 27 | |
| 28 | namespace ndn { |
| 29 | namespace nfd { |
| 30 | namespace tests { |
| 31 | |
Junxiao Shi | 85d9083 | 2016-08-04 03:19:46 +0000 | [diff] [blame] | 32 | using namespace ndn::tests; |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 33 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 34 | BOOST_AUTO_TEST_SUITE(Mgmt) |
| 35 | BOOST_AUTO_TEST_SUITE(Nfd) |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 36 | |
| 37 | class ControllerStatusDatasetFixture : public ControllerFixture |
| 38 | { |
| 39 | protected: |
| 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 | |
| 82 | private: |
| 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 Shi | ebfe4a2 | 2018-04-01 23:53:40 +0000 | [diff] [blame] | 101 | data->setFinalBlock(name[-1]); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 102 | return data; |
| 103 | } |
| 104 | }; |
| 105 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 106 | BOOST_FIXTURE_TEST_SUITE(TestStatusDataset, ControllerStatusDatasetFixture) |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 107 | |
| 108 | BOOST_AUTO_TEST_SUITE(Failures) |
| 109 | |
| 110 | BOOST_AUTO_TEST_CASE(Timeout) |
| 111 | { |
| 112 | CommandOptions options; |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 113 | options.setTimeout(3000_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 114 | controller.fetch<FaceDataset>( |
| 115 | [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); }, |
Junxiao Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 116 | datasetFailCallback, |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 117 | options); |
Ashlesh Gawande | 3e3a989 | 2018-11-16 20:26:15 -0600 | [diff] [blame] | 118 | this->advanceClocks(500_ms); |
| 119 | BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 1); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 120 | |
Ashlesh Gawande | 3e3a989 | 2018-11-16 20:26:15 -0600 | [diff] [blame] | 121 | this->advanceClocks(500_ms, 6); |
| 122 | BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 0); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 123 | BOOST_REQUIRE_EQUAL(failCodes.size(), 1); |
| 124 | BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_TIMEOUT); |
| 125 | } |
| 126 | |
| 127 | BOOST_AUTO_TEST_CASE(DataHasNoSegment) |
| 128 | { |
| 129 | controller.fetch<FaceDataset>( |
| 130 | [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); }, |
Junxiao Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 131 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 132 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 133 | |
| 134 | face.receive(*makeData("/localhost/nfd/faces/list/%FD%00")); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 135 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 136 | |
| 137 | BOOST_REQUIRE_EQUAL(failCodes.size(), 1); |
| 138 | BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER); |
| 139 | } |
| 140 | |
Junxiao Shi | 0f3f0b4 | 2016-07-14 13:26:37 +0000 | [diff] [blame] | 141 | BOOST_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 Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 147 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 148 | this->advanceClocks(500_ms); |
Junxiao Shi | 0f3f0b4 | 2016-07-14 13:26:37 +0000 | [diff] [blame] | 149 | |
| 150 | FaceStatus payload; |
| 151 | payload.setFaceId(5744); |
| 152 | this->sendDataset("/localhost/nfd/faces/list", payload); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 153 | this->advanceClocks(500_ms); |
Junxiao Shi | 0f3f0b4 | 2016-07-14 13:26:37 +0000 | [diff] [blame] | 154 | |
| 155 | BOOST_REQUIRE_EQUAL(failCodes.size(), 1); |
| 156 | BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_VALIDATION); |
| 157 | } |
| 158 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 159 | BOOST_AUTO_TEST_CASE(Nack) |
| 160 | { |
| 161 | controller.fetch<FaceDataset>( |
| 162 | [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); }, |
Junxiao Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 163 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 164 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 165 | |
| 166 | BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1); |
| 167 | face.receive(lp::Nack(face.sentInterests.back())); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 168 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 169 | |
| 170 | BOOST_REQUIRE_EQUAL(failCodes.size(), 1); |
| 171 | BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_NACK); |
| 172 | } |
| 173 | |
| 174 | BOOST_AUTO_TEST_CASE(ParseError1) |
| 175 | { |
| 176 | controller.fetch<FaceDataset>( |
| 177 | [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); }, |
Junxiao Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 178 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 179 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 180 | |
| 181 | Name payload; // Name is not valid FaceStatus |
| 182 | this->sendDataset("/localhost/nfd/faces/list", payload); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 183 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 184 | |
| 185 | BOOST_REQUIRE_EQUAL(failCodes.size(), 1); |
| 186 | BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER); |
| 187 | } |
| 188 | |
| 189 | BOOST_AUTO_TEST_CASE(ParseError2) |
| 190 | { |
| 191 | controller.fetch<FaceDataset>( |
| 192 | [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); }, |
Junxiao Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 193 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 194 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 195 | |
| 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 Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 200 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 201 | |
| 202 | BOOST_REQUIRE_EQUAL(failCodes.size(), 1); |
| 203 | BOOST_CHECK_EQUAL(failCodes.back(), Controller::ERROR_SERVER); |
| 204 | } |
| 205 | |
| 206 | BOOST_AUTO_TEST_SUITE_END() // Failures |
| 207 | |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame] | 208 | BOOST_AUTO_TEST_SUITE(NoCallback) |
| 209 | |
| 210 | BOOST_AUTO_TEST_CASE(Success) |
| 211 | { |
| 212 | controller.fetch<FaceDataset>( |
| 213 | nullptr, |
Junxiao Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 214 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 215 | this->advanceClocks(500_ms); |
Ashlesh Gawande | 3e3a989 | 2018-11-16 20:26:15 -0600 | [diff] [blame] | 216 | BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 1); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame] | 217 | |
| 218 | FaceStatus payload; |
| 219 | payload.setFaceId(2577); |
| 220 | this->sendDataset("/localhost/nfd/faces/list", payload); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 221 | BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms)); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame] | 222 | |
| 223 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
Ashlesh Gawande | 3e3a989 | 2018-11-16 20:26:15 -0600 | [diff] [blame] | 224 | BOOST_CHECK_EQUAL(controller.m_fetchers.size(), 0); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | BOOST_AUTO_TEST_CASE(Failure) |
| 228 | { |
| 229 | CommandOptions options; |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 230 | options.setTimeout(3000_ms); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame] | 231 | controller.fetch<FaceDataset>( |
| 232 | [] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); }, |
| 233 | nullptr, |
| 234 | options); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 235 | BOOST_CHECK_NO_THROW(this->advanceClocks(500_ms, 7)); |
Junxiao Shi | 600f711 | 2016-07-16 11:57:18 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | BOOST_AUTO_TEST_SUITE_END() // NoCallback |
| 239 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 240 | BOOST_AUTO_TEST_SUITE(Datasets) |
| 241 | |
| 242 | BOOST_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 Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 250 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 251 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 252 | |
| 253 | ForwarderStatus payload; |
| 254 | payload.setNfdVersion("0.4.2"); |
| 255 | this->sendDataset("/localhost/nfd/status/general", payload); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 256 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 257 | |
| 258 | BOOST_CHECK(hasResult); |
| 259 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 260 | } |
| 261 | |
| 262 | BOOST_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 Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 271 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 272 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 273 | |
| 274 | FaceStatus payload1; |
| 275 | payload1.setFaceId(24485); |
| 276 | FaceStatus payload2; |
| 277 | payload2.setFaceId(12987); |
| 278 | this->sendDataset("/localhost/nfd/faces/list", payload1, payload2); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 279 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 280 | |
| 281 | BOOST_CHECK(hasResult); |
| 282 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 283 | } |
| 284 | |
| 285 | BOOST_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 Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 297 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 298 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 299 | |
| 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 Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 305 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 306 | |
| 307 | BOOST_CHECK(hasResult); |
| 308 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 309 | } |
| 310 | |
| 311 | BOOST_AUTO_TEST_CASE(FaceQueryWithOptions) |
| 312 | { |
| 313 | FaceQueryFilter filter; |
| 314 | filter.setUriScheme("udp4"); |
| 315 | CommandOptions options; |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 316 | options.setTimeout(3000_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 317 | 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 Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 325 | datasetFailCallback, |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 326 | options); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 327 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 328 | |
| 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 Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 334 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 335 | |
| 336 | BOOST_CHECK(hasResult); |
| 337 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 338 | } |
| 339 | |
Junxiao Shi | 1eacb97 | 2016-07-07 22:51:07 +0000 | [diff] [blame] | 340 | BOOST_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 Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 349 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 350 | this->advanceClocks(500_ms); |
Junxiao Shi | 1eacb97 | 2016-07-07 22:51:07 +0000 | [diff] [blame] | 351 | |
| 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 Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 357 | this->advanceClocks(500_ms); |
Junxiao Shi | 1eacb97 | 2016-07-07 22:51:07 +0000 | [diff] [blame] | 358 | |
| 359 | BOOST_CHECK(hasResult); |
| 360 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 361 | } |
| 362 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 363 | BOOST_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 Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 372 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 373 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 374 | |
| 375 | FibEntry payload1; |
| 376 | payload1.setPrefix("/wYs7fzYcfG"); |
| 377 | FibEntry payload2; |
| 378 | payload2.setPrefix("/LKvmnzY5S"); |
| 379 | this->sendDataset("/localhost/nfd/fib/list", payload1, payload2); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 380 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 381 | |
| 382 | BOOST_CHECK(hasResult); |
| 383 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 384 | } |
| 385 | |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 386 | BOOST_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 Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 397 | this->advanceClocks(500_ms); |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 398 | |
| 399 | CsInfo payload; |
| 400 | payload.setNHits(4539); |
| 401 | this->sendDataset("/localhost/nfd/cs/info", payload); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 402 | this->advanceClocks(500_ms); |
Junxiao Shi | 7f01247 | 2017-12-07 20:40:47 +0000 | [diff] [blame] | 403 | |
| 404 | BOOST_CHECK(hasResult); |
| 405 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 406 | } |
| 407 | |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 408 | BOOST_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 Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 417 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 418 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 419 | |
| 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 Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 425 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 426 | |
| 427 | BOOST_CHECK(hasResult); |
| 428 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 429 | } |
| 430 | |
| 431 | BOOST_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 Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 440 | datasetFailCallback); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 441 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 442 | |
| 443 | RibEntry payload1; |
| 444 | payload1.setName("/zXxBth97ee"); |
| 445 | RibEntry payload2; |
| 446 | payload2.setName("/rJ8CvUpr4G"); |
| 447 | this->sendDataset("/localhost/nfd/rib/list", payload1, payload2); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 448 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 449 | |
| 450 | BOOST_CHECK(hasResult); |
| 451 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 452 | } |
| 453 | |
| 454 | BOOST_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 Shi | e7c7f15 | 2016-08-20 22:36:22 +0000 | [diff] [blame] | 465 | datasetFailCallback, |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 466 | options); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 467 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 468 | |
| 469 | RibEntry payload; |
| 470 | payload.setName("/e6L5K4ascd"); |
| 471 | this->sendDataset("/localhop/nfd/rib/list", payload); |
Davide Pesavento | 0f83080 | 2018-01-16 23:58:58 -0500 | [diff] [blame] | 472 | this->advanceClocks(500_ms); |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 473 | |
| 474 | BOOST_CHECK(hasResult); |
| 475 | BOOST_CHECK_EQUAL(failCodes.size(), 0); |
| 476 | } |
| 477 | |
| 478 | BOOST_AUTO_TEST_SUITE_END() // Datasets |
| 479 | |
Junxiao Shi | 7357ef2 | 2016-09-07 02:39:37 +0000 | [diff] [blame] | 480 | BOOST_AUTO_TEST_SUITE_END() // TestStatusDataset |
| 481 | BOOST_AUTO_TEST_SUITE_END() // Nfd |
| 482 | BOOST_AUTO_TEST_SUITE_END() // Mgmt |
Junxiao Shi | 034c188 | 2016-06-24 18:06:51 +0000 | [diff] [blame] | 483 | |
| 484 | } // namespace tests |
| 485 | } // namespace nfd |
| 486 | } // namespace ndn |