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