Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Eric Newberry | 2642cd2 | 2017-07-13 21:34:53 -0400 | [diff] [blame] | 2 | /* |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2022, Regents of the University of California, |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 26 | #include "mgmt/face-manager.hpp" |
| 27 | #include "face/generic-link-service.hpp" |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 28 | |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 29 | #include "face-manager-command-fixture.hpp" |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 30 | #include "tests/daemon/face/dummy-transport.hpp" |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 31 | |
Junxiao Shi | cbc8e94 | 2016-09-06 03:17:45 +0000 | [diff] [blame] | 32 | #include <ndn-cxx/lp/tags.hpp> |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 33 | |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 34 | #include <thread> |
| 35 | |
Eric Newberry | 0c3e57b | 2018-01-25 20:54:46 -0700 | [diff] [blame] | 36 | #include <boost/logic/tribool.hpp> |
| 37 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 38 | namespace nfd::tests { |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 39 | |
| 40 | BOOST_AUTO_TEST_SUITE(Mgmt) |
| 41 | BOOST_AUTO_TEST_SUITE(TestFaceManager) |
| 42 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 43 | namespace mpl = boost::mpl; |
| 44 | |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 45 | class FaceManagerUpdateFixture : public FaceManagerCommandFixture |
| 46 | { |
| 47 | public: |
Davide Pesavento | 2208536 | 2021-03-18 22:08:03 -0400 | [diff] [blame] | 48 | ~FaceManagerUpdateFixture() override |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 49 | { |
| 50 | destroyFace(); |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | createFace(const std::string& uri = "tcp4://127.0.0.1:26363", |
| 55 | ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT, |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 56 | std::optional<time::nanoseconds> baseCongestionMarkingInterval = std::nullopt, |
| 57 | std::optional<uint64_t> defaultCongestionThreshold = std::nullopt, |
Eric Newberry | 2642cd2 | 2017-07-13 21:34:53 -0400 | [diff] [blame] | 58 | bool enableLocalFields = false, |
Eric Newberry | 0c3e57b | 2018-01-25 20:54:46 -0700 | [diff] [blame] | 59 | bool enableReliability = false, |
| 60 | boost::logic::tribool enableCongestionMarking = boost::logic::indeterminate) |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 61 | { |
| 62 | ControlParameters params; |
| 63 | params.setUri(uri); |
| 64 | params.setFacePersistency(persistency); |
Eric Newberry | 0c3e57b | 2018-01-25 20:54:46 -0700 | [diff] [blame] | 65 | |
| 66 | if (baseCongestionMarkingInterval) { |
| 67 | params.setBaseCongestionMarkingInterval(*baseCongestionMarkingInterval); |
| 68 | } |
| 69 | |
| 70 | if (defaultCongestionThreshold) { |
| 71 | params.setDefaultCongestionThreshold(*defaultCongestionThreshold); |
| 72 | } |
| 73 | |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 74 | params.setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, enableLocalFields); |
Eric Newberry | 2642cd2 | 2017-07-13 21:34:53 -0400 | [diff] [blame] | 75 | params.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, enableReliability); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 76 | |
Eric Newberry | 0c3e57b | 2018-01-25 20:54:46 -0700 | [diff] [blame] | 77 | if (!boost::logic::indeterminate(enableCongestionMarking)) { |
Davide Pesavento | fa2aa50 | 2019-03-22 13:30:02 -0400 | [diff] [blame] | 78 | params.setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, bool(enableCongestionMarking)); |
Eric Newberry | 0c3e57b | 2018-01-25 20:54:46 -0700 | [diff] [blame] | 79 | } |
| 80 | |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 81 | createFace(params); |
| 82 | } |
| 83 | |
| 84 | void |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 85 | createFace(const ControlParameters& createParams, bool isForOnDemandFace = false) |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 86 | { |
Junxiao Shi | 8a1f170 | 2017-07-03 00:05:08 +0000 | [diff] [blame] | 87 | Interest req = makeControlCommandRequest("/localhost/nfd/faces/create", createParams); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 88 | |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 89 | // if this creation if for on-demand face then create it on node2 |
| 90 | FaceManagerCommandNode& target = isForOnDemandFace ? this->node2 : this->node1; |
| 91 | |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 92 | bool hasCallbackFired = false; |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 93 | signal::ScopedConnection connection = target.face.onSendData.connect( |
Junxiao Shi | 8a1f170 | 2017-07-03 00:05:08 +0000 | [diff] [blame] | 94 | [&, req, isForOnDemandFace, this] (const Data& response) { |
| 95 | if (!req.getName().isPrefixOf(response.getName())) { |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 96 | return; |
| 97 | } |
| 98 | |
| 99 | ControlResponse create(response.getContent().blockFromValue()); |
| 100 | BOOST_REQUIRE_EQUAL(create.getCode(), 200); |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 101 | BOOST_REQUIRE(create.getBody().hasWire()); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 102 | |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 103 | ControlParameters faceParams(create.getBody()); |
| 104 | BOOST_REQUIRE(faceParams.hasFaceId()); |
| 105 | this->faceId = faceParams.getFaceId(); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 106 | |
| 107 | hasCallbackFired = true; |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 108 | |
| 109 | if (isForOnDemandFace) { |
| 110 | auto face = target.faceTable.get(static_cast<FaceId>(this->faceId)); |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 111 | // to force creation of on-demand face |
Davide Pesavento | 2208536 | 2021-03-18 22:08:03 -0400 | [diff] [blame] | 112 | face->sendInterest(*makeInterest("/hello/world")); |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 113 | } |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 114 | }); |
| 115 | |
Junxiao Shi | 8a1f170 | 2017-07-03 00:05:08 +0000 | [diff] [blame] | 116 | target.face.receive(req); |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 117 | advanceClocks(1_ms, 5); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 118 | |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 119 | if (isForOnDemandFace) { |
| 120 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); // allow wallclock time for socket IO |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 121 | advanceClocks(1_ms, 5); // let node1 accept Interest and create on-demand face |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 124 | BOOST_REQUIRE(hasCallbackFired); |
| 125 | } |
| 126 | |
| 127 | void |
| 128 | updateFace(const ControlParameters& requestParams, |
| 129 | bool isSelfUpdating, |
Davide Pesavento | 87fc0f8 | 2018-04-11 23:43:51 -0400 | [diff] [blame] | 130 | const std::function<void(const ControlResponse& resp)>& checkResp) |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 131 | { |
Junxiao Shi | 8a1f170 | 2017-07-03 00:05:08 +0000 | [diff] [blame] | 132 | Interest req = makeControlCommandRequest("/localhost/nfd/faces/update", requestParams); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 133 | if (isSelfUpdating) { |
| 134 | // Attach IncomingFaceIdTag to interest |
Junxiao Shi | 8a1f170 | 2017-07-03 00:05:08 +0000 | [diff] [blame] | 135 | req.setTag(make_shared<lp::IncomingFaceIdTag>(faceId)); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 136 | } |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 137 | |
| 138 | bool hasCallbackFired = false; |
| 139 | signal::ScopedConnection connection = this->node1.face.onSendData.connect( |
Davide Pesavento | ac238f2 | 2017-09-12 15:19:40 -0400 | [diff] [blame] | 140 | [req, &hasCallbackFired, &checkResp] (const Data& response) { |
Junxiao Shi | 8a1f170 | 2017-07-03 00:05:08 +0000 | [diff] [blame] | 141 | if (!req.getName().isPrefixOf(response.getName())) { |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 142 | return; |
| 143 | } |
| 144 | |
| 145 | ControlResponse actual(response.getContent().blockFromValue()); |
| 146 | checkResp(actual); |
| 147 | |
| 148 | hasCallbackFired = true; |
| 149 | }); |
| 150 | |
Junxiao Shi | 8a1f170 | 2017-07-03 00:05:08 +0000 | [diff] [blame] | 151 | this->node1.face.receive(req); |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 152 | advanceClocks(1_ms, 5); |
| 153 | BOOST_REQUIRE(hasCallbackFired); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | private: |
| 157 | void |
| 158 | destroyFace() |
| 159 | { |
| 160 | if (faceId == 0) { |
| 161 | return; |
| 162 | } |
| 163 | |
| 164 | ControlParameters params; |
| 165 | params.setFaceId(faceId); |
Junxiao Shi | 8a1f170 | 2017-07-03 00:05:08 +0000 | [diff] [blame] | 166 | Interest req = makeControlCommandRequest("/localhost/nfd/faces/destroy", params); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 167 | |
| 168 | bool hasCallbackFired = false; |
| 169 | signal::ScopedConnection connection = this->node1.face.onSendData.connect( |
Junxiao Shi | 8a1f170 | 2017-07-03 00:05:08 +0000 | [diff] [blame] | 170 | [this, req, &hasCallbackFired] (const Data& response) { |
| 171 | if (!req.getName().isPrefixOf(response.getName())) { |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 172 | return; |
| 173 | } |
| 174 | |
| 175 | ControlResponse destroy(response.getContent().blockFromValue()); |
| 176 | BOOST_CHECK_EQUAL(destroy.getCode(), 200); |
| 177 | |
| 178 | faceId = 0; |
| 179 | hasCallbackFired = true; |
| 180 | }); |
| 181 | |
Junxiao Shi | 8a1f170 | 2017-07-03 00:05:08 +0000 | [diff] [blame] | 182 | this->node1.face.receive(req); |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 183 | advanceClocks(1_ms, 5); |
| 184 | BOOST_REQUIRE(hasCallbackFired); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 187 | protected: |
| 188 | FaceId faceId = 0; |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 189 | }; |
| 190 | |
| 191 | BOOST_FIXTURE_TEST_SUITE(UpdateFace, FaceManagerUpdateFixture) |
| 192 | |
| 193 | BOOST_AUTO_TEST_CASE(FaceDoesNotExist) |
| 194 | { |
| 195 | ControlParameters requestParams; |
| 196 | requestParams.setFaceId(65535); |
| 197 | |
| 198 | updateFace(requestParams, false, [] (const ControlResponse& actual) { |
| 199 | ControlResponse expected(404, "Specified face does not exist"); |
| 200 | BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode()); |
| 201 | BOOST_TEST_MESSAGE(actual.getText()); |
| 202 | }); |
| 203 | } |
| 204 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 205 | using UpdatePersistencyTests = mpl::vector< |
Davide Pesavento | 16916ae | 2019-03-29 23:53:26 -0400 | [diff] [blame] | 206 | mpl::pair<DummyTransportBase<true>, CommandSuccess>, |
| 207 | mpl::pair<DummyTransportBase<false>, CommandFailure<409>> |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 208 | >; |
Yanbiao Li | 58ba3f9 | 2017-02-15 14:27:18 +0000 | [diff] [blame] | 209 | |
| 210 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(UpdatePersistency, T, UpdatePersistencyTests, FaceManagerUpdateFixture) |
| 211 | { |
| 212 | using TransportType = typename T::first; |
| 213 | using ResultType = typename T::second; |
| 214 | |
| 215 | auto face = make_shared<face::Face>(make_unique<face::GenericLinkService>(), |
| 216 | make_unique<TransportType>()); |
| 217 | this->node1.faceTable.add(face); |
| 218 | |
| 219 | auto parameters = ControlParameters() |
| 220 | .setFaceId(face->getId()) |
| 221 | .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERMANENT); |
| 222 | |
| 223 | updateFace(parameters, false, [] (const ControlResponse& actual) { |
| 224 | BOOST_TEST_MESSAGE(actual.getText()); |
| 225 | BOOST_CHECK_EQUAL(actual.getCode(), ResultType::getExpected().getCode()); |
| 226 | |
| 227 | // the response for either 200 or 409 will have a content body |
| 228 | BOOST_REQUIRE(actual.getBody().hasWire()); |
| 229 | |
| 230 | ControlParameters resp; |
| 231 | resp.wireDecode(actual.getBody()); |
| 232 | BOOST_CHECK_EQUAL(resp.getFacePersistency(), ndn::nfd::FACE_PERSISTENCY_PERMANENT); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 233 | }); |
| 234 | } |
| 235 | |
Eric Newberry | 13ff259 | 2020-03-06 17:32:29 -0800 | [diff] [blame] | 236 | BOOST_AUTO_TEST_CASE(UpdateMtu) |
| 237 | { |
| 238 | createFace("udp4://127.0.0.1:26363"); |
| 239 | |
| 240 | ControlParameters validParams; |
| 241 | validParams.setFaceId(faceId); |
| 242 | validParams.setMtu(4000); |
| 243 | |
| 244 | ControlParameters mtuTooLow; |
| 245 | mtuTooLow.setFaceId(faceId); |
| 246 | mtuTooLow.setMtu(63); |
| 247 | |
| 248 | updateFace(validParams, false, [] (const ControlResponse& actual) { |
| 249 | BOOST_CHECK_EQUAL(actual.getCode(), 200); |
| 250 | BOOST_TEST_MESSAGE(actual.getText()); |
| 251 | |
| 252 | if (actual.getBody().hasWire()) { |
| 253 | ControlParameters actualParams(actual.getBody()); |
| 254 | |
| 255 | BOOST_CHECK(actualParams.hasFaceId()); |
| 256 | BOOST_REQUIRE(actualParams.hasMtu()); |
| 257 | // Check for changed MTU |
| 258 | BOOST_CHECK_EQUAL(actualParams.getMtu(), 4000); |
| 259 | } |
| 260 | else { |
| 261 | BOOST_ERROR("Valid: Response does not contain ControlParameters"); |
| 262 | } |
| 263 | }); |
| 264 | |
| 265 | updateFace(mtuTooLow, false, [] (const ControlResponse& actual) { |
| 266 | BOOST_CHECK_EQUAL(actual.getCode(), 409); |
| 267 | BOOST_TEST_MESSAGE(actual.getText()); |
| 268 | |
| 269 | if (actual.getBody().hasWire()) { |
| 270 | ControlParameters actualParams(actual.getBody()); |
| 271 | |
| 272 | BOOST_CHECK(!actualParams.hasFaceId()); |
| 273 | BOOST_REQUIRE(actualParams.hasMtu()); |
| 274 | // Check for returned invalid parameter |
| 275 | BOOST_CHECK_EQUAL(actualParams.getMtu(), 63); |
| 276 | } |
| 277 | else { |
| 278 | BOOST_ERROR("Too low: Response does not contain ControlParameters"); |
| 279 | } |
| 280 | }); |
| 281 | } |
| 282 | |
| 283 | BOOST_AUTO_TEST_CASE(UpdateMtuUnsupportedFace) |
| 284 | { |
| 285 | createFace("tcp4://127.0.0.1:26363"); |
| 286 | |
| 287 | ControlParameters updateParams; |
| 288 | updateParams.setFaceId(faceId); |
| 289 | updateParams.setMtu(4000); |
| 290 | |
| 291 | updateFace(updateParams, false, [] (const ControlResponse& actual) { |
| 292 | BOOST_CHECK_EQUAL(actual.getCode(), 409); |
| 293 | BOOST_TEST_MESSAGE(actual.getText()); |
| 294 | |
| 295 | if (actual.getBody().hasWire()) { |
| 296 | ControlParameters actualParams(actual.getBody()); |
| 297 | |
| 298 | BOOST_CHECK(!actualParams.hasFaceId()); |
| 299 | BOOST_REQUIRE(actualParams.hasMtu()); |
| 300 | // Check for returned invalid parameter |
| 301 | BOOST_CHECK_EQUAL(actualParams.getMtu(), 4000); |
| 302 | } |
| 303 | else { |
| 304 | BOOST_ERROR("Response does not contain ControlParameters"); |
| 305 | } |
| 306 | }); |
| 307 | } |
| 308 | |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 309 | class TcpLocalFieldsEnable |
| 310 | { |
| 311 | public: |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 312 | static std::string |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 313 | getUri() |
| 314 | { |
| 315 | return "tcp4://127.0.0.1:26363"; |
| 316 | } |
| 317 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 318 | static constexpr ndn::nfd::FacePersistency |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 319 | getPersistency() |
| 320 | { |
| 321 | return ndn::nfd::FACE_PERSISTENCY_PERSISTENT; |
| 322 | } |
| 323 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 324 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 325 | getInitLocalFieldsEnabled() |
| 326 | { |
| 327 | return false; |
| 328 | } |
| 329 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 330 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 331 | getLocalFieldsEnabled() |
| 332 | { |
| 333 | return true; |
| 334 | } |
| 335 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 336 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 337 | getLocalFieldsEnabledMask() |
| 338 | { |
| 339 | return true; |
| 340 | } |
| 341 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 342 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 343 | shouldHaveWire() |
| 344 | { |
| 345 | return false; |
| 346 | } |
| 347 | }; |
| 348 | |
| 349 | class TcpLocalFieldsDisable |
| 350 | { |
| 351 | public: |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 352 | static std::string |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 353 | getUri() |
| 354 | { |
| 355 | return "tcp4://127.0.0.1:26363"; |
| 356 | } |
| 357 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 358 | static constexpr ndn::nfd::FacePersistency |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 359 | getPersistency() |
| 360 | { |
| 361 | return ndn::nfd::FACE_PERSISTENCY_PERSISTENT; |
| 362 | } |
| 363 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 364 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 365 | getInitLocalFieldsEnabled() |
| 366 | { |
| 367 | return true; |
| 368 | } |
| 369 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 370 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 371 | getLocalFieldsEnabled() |
| 372 | { |
| 373 | return false; |
| 374 | } |
| 375 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 376 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 377 | getLocalFieldsEnabledMask() |
| 378 | { |
| 379 | return true; |
| 380 | } |
| 381 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 382 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 383 | shouldHaveWire() |
| 384 | { |
| 385 | return false; |
| 386 | } |
| 387 | }; |
| 388 | |
| 389 | // UDP faces are non-local by definition |
| 390 | class UdpLocalFieldsEnable |
| 391 | { |
| 392 | public: |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 393 | static std::string |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 394 | getUri() |
| 395 | { |
| 396 | return "udp4://127.0.0.1:26363"; |
| 397 | } |
| 398 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 399 | static constexpr ndn::nfd::FacePersistency |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 400 | getPersistency() |
| 401 | { |
| 402 | return ndn::nfd::FACE_PERSISTENCY_PERSISTENT; |
| 403 | } |
| 404 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 405 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 406 | getInitLocalFieldsEnabled() |
| 407 | { |
| 408 | return false; |
| 409 | } |
| 410 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 411 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 412 | getLocalFieldsEnabled() |
| 413 | { |
| 414 | return true; |
| 415 | } |
| 416 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 417 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 418 | getLocalFieldsEnabledMask() |
| 419 | { |
| 420 | return true; |
| 421 | } |
| 422 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 423 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 424 | shouldHaveWire() |
| 425 | { |
| 426 | return true; |
| 427 | } |
| 428 | }; |
| 429 | |
| 430 | // UDP faces are non-local by definition |
| 431 | // In this test case, attempt to disable local fields on face with local fields already disabled |
| 432 | class UdpLocalFieldsDisable |
| 433 | { |
| 434 | public: |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 435 | static std::string |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 436 | getUri() |
| 437 | { |
| 438 | return "udp4://127.0.0.1:26363"; |
| 439 | } |
| 440 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 441 | static constexpr ndn::nfd::FacePersistency |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 442 | getPersistency() |
| 443 | { |
| 444 | return ndn::nfd::FACE_PERSISTENCY_PERSISTENT; |
| 445 | } |
| 446 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 447 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 448 | getInitLocalFieldsEnabled() |
| 449 | { |
| 450 | return false; |
| 451 | } |
| 452 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 453 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 454 | getLocalFieldsEnabled() |
| 455 | { |
| 456 | return false; |
| 457 | } |
| 458 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 459 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 460 | getLocalFieldsEnabledMask() |
| 461 | { |
| 462 | return true; |
| 463 | } |
| 464 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 465 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 466 | shouldHaveWire() |
| 467 | { |
| 468 | return false; |
| 469 | } |
| 470 | }; |
| 471 | |
| 472 | // In this test case, set Flags to enable local fields on non-local face, but exclude local fields |
| 473 | // from Mask. This test case will pass as no action is taken due to the missing Mask bit. |
| 474 | class UdpLocalFieldsEnableNoMaskBit |
| 475 | { |
| 476 | public: |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 477 | static std::string |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 478 | getUri() |
| 479 | { |
| 480 | return "udp4://127.0.0.1:26363"; |
| 481 | } |
| 482 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 483 | static constexpr ndn::nfd::FacePersistency |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 484 | getPersistency() |
| 485 | { |
| 486 | return ndn::nfd::FACE_PERSISTENCY_PERSISTENT; |
| 487 | } |
| 488 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 489 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 490 | getInitLocalFieldsEnabled() |
| 491 | { |
| 492 | return false; |
| 493 | } |
| 494 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 495 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 496 | getLocalFieldsEnabled() |
| 497 | { |
| 498 | return true; |
| 499 | } |
| 500 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 501 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 502 | getLocalFieldsEnabledMask() |
| 503 | { |
| 504 | return false; |
| 505 | } |
| 506 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 507 | static constexpr bool |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 508 | shouldHaveWire() |
| 509 | { |
| 510 | return false; |
| 511 | } |
| 512 | }; |
| 513 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 514 | using LocalFieldFaces = mpl::vector< |
| 515 | mpl::pair<TcpLocalFieldsEnable, CommandSuccess>, |
| 516 | mpl::pair<TcpLocalFieldsDisable, CommandSuccess>, |
| 517 | mpl::pair<UdpLocalFieldsEnable, CommandFailure<409>>, |
| 518 | mpl::pair<UdpLocalFieldsDisable, CommandSuccess>, |
| 519 | mpl::pair<UdpLocalFieldsEnableNoMaskBit, CommandSuccess> |
| 520 | >; |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 521 | |
| 522 | BOOST_AUTO_TEST_CASE_TEMPLATE(UpdateLocalFields, T, LocalFieldFaces) |
| 523 | { |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 524 | using TestType = typename T::first; |
| 525 | using ResultType = typename T::second; |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 526 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 527 | createFace(TestType::getUri(), TestType::getPersistency(), {}, {}, |
| 528 | TestType::getInitLocalFieldsEnabled()); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 529 | |
| 530 | ControlParameters requestParams; |
| 531 | requestParams.setFaceId(faceId); |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 532 | requestParams.setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, TestType::getLocalFieldsEnabled()); |
| 533 | if (!TestType::getLocalFieldsEnabledMask()) { |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 534 | requestParams.unsetFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED); |
| 535 | } |
| 536 | |
| 537 | updateFace(requestParams, false, [] (const ControlResponse& actual) { |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 538 | ControlResponse expected(ResultType::getExpected()); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 539 | BOOST_TEST_MESSAGE(actual.getText()); |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 540 | BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode()); |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 541 | |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 542 | if (TestType::shouldHaveWire() && actual.getBody().hasWire()) { |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 543 | ControlParameters actualParams(actual.getBody()); |
| 544 | |
| 545 | BOOST_CHECK(!actualParams.hasFacePersistency()); |
| 546 | BOOST_CHECK(actualParams.hasFlags()); |
| 547 | BOOST_CHECK(actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED)); |
| 548 | BOOST_CHECK(actualParams.hasFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED)); |
| 549 | } |
| 550 | }); |
| 551 | } |
| 552 | |
| 553 | BOOST_AUTO_TEST_CASE(UpdateLocalFieldsEnableDisable) |
| 554 | { |
| 555 | createFace(); |
| 556 | |
| 557 | ControlParameters enableParams; |
| 558 | enableParams.setFaceId(faceId); |
| 559 | enableParams.setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, true); |
| 560 | |
| 561 | ControlParameters disableParams; |
| 562 | disableParams.setFaceId(faceId); |
| 563 | disableParams.setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, false); |
| 564 | |
| 565 | updateFace(enableParams, false, [] (const ControlResponse& actual) { |
| 566 | ControlResponse expected(200, "OK"); |
| 567 | BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode()); |
| 568 | BOOST_TEST_MESSAGE(actual.getText()); |
| 569 | |
| 570 | if (actual.getBody().hasWire()) { |
| 571 | ControlParameters actualParams(actual.getBody()); |
| 572 | |
| 573 | BOOST_CHECK(actualParams.hasFaceId()); |
| 574 | BOOST_CHECK(actualParams.hasFacePersistency()); |
| 575 | BOOST_REQUIRE(actualParams.hasFlags()); |
| 576 | // Check if flags indicate local fields enabled |
| 577 | BOOST_CHECK(actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED)); |
| 578 | } |
| 579 | else { |
| 580 | BOOST_ERROR("Enable: Response does not contain ControlParameters"); |
| 581 | } |
| 582 | }); |
| 583 | |
| 584 | updateFace(disableParams, false, [] (const ControlResponse& actual) { |
| 585 | ControlResponse expected(200, "OK"); |
| 586 | BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode()); |
| 587 | BOOST_TEST_MESSAGE(actual.getText()); |
| 588 | |
| 589 | if (actual.getBody().hasWire()) { |
| 590 | ControlParameters actualParams(actual.getBody()); |
| 591 | |
| 592 | BOOST_CHECK(actualParams.hasFaceId()); |
| 593 | BOOST_CHECK(actualParams.hasFacePersistency()); |
| 594 | BOOST_REQUIRE(actualParams.hasFlags()); |
| 595 | // Check if flags indicate local fields disabled |
| 596 | BOOST_CHECK(!actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED)); |
| 597 | } |
| 598 | else { |
| 599 | BOOST_ERROR("Disable: Response does not contain ControlParameters"); |
| 600 | } |
| 601 | }); |
| 602 | } |
| 603 | |
Eric Newberry | 2642cd2 | 2017-07-13 21:34:53 -0400 | [diff] [blame] | 604 | BOOST_AUTO_TEST_CASE(UpdateReliabilityEnableDisable) |
| 605 | { |
| 606 | createFace("udp4://127.0.0.1:26363"); |
| 607 | |
| 608 | ControlParameters enableParams; |
| 609 | enableParams.setFaceId(faceId); |
| 610 | enableParams.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true); |
| 611 | |
| 612 | ControlParameters disableParams; |
| 613 | disableParams.setFaceId(faceId); |
| 614 | disableParams.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, false); |
| 615 | |
| 616 | updateFace(enableParams, false, [] (const ControlResponse& actual) { |
| 617 | ControlResponse expected(200, "OK"); |
| 618 | BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode()); |
| 619 | BOOST_TEST_MESSAGE(actual.getText()); |
| 620 | |
| 621 | if (actual.getBody().hasWire()) { |
| 622 | ControlParameters actualParams(actual.getBody()); |
| 623 | |
| 624 | BOOST_CHECK(actualParams.hasFaceId()); |
| 625 | BOOST_CHECK(actualParams.hasFacePersistency()); |
| 626 | BOOST_REQUIRE(actualParams.hasFlags()); |
| 627 | // Check if flags indicate reliability enabled |
| 628 | BOOST_CHECK(actualParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)); |
| 629 | } |
| 630 | else { |
| 631 | BOOST_ERROR("Enable: Response does not contain ControlParameters"); |
| 632 | } |
| 633 | }); |
| 634 | |
| 635 | updateFace(disableParams, false, [] (const ControlResponse& actual) { |
| 636 | ControlResponse expected(200, "OK"); |
| 637 | BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode()); |
| 638 | BOOST_TEST_MESSAGE(actual.getText()); |
| 639 | |
| 640 | if (actual.getBody().hasWire()) { |
| 641 | ControlParameters actualParams(actual.getBody()); |
| 642 | |
| 643 | BOOST_CHECK(actualParams.hasFaceId()); |
| 644 | BOOST_CHECK(actualParams.hasFacePersistency()); |
| 645 | BOOST_REQUIRE(actualParams.hasFlags()); |
| 646 | // Check if flags indicate reliability disabled |
| 647 | BOOST_CHECK(!actualParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)); |
| 648 | } |
| 649 | else { |
| 650 | BOOST_ERROR("Disable: Response does not contain ControlParameters"); |
| 651 | } |
| 652 | }); |
| 653 | } |
| 654 | |
Eric Newberry | 0c3e57b | 2018-01-25 20:54:46 -0700 | [diff] [blame] | 655 | BOOST_AUTO_TEST_CASE(UpdateCongestionMarkingEnableDisable) |
| 656 | { |
| 657 | createFace("udp4://127.0.0.1:26363"); |
| 658 | |
| 659 | ControlParameters enableParams; |
| 660 | enableParams.setFaceId(faceId); |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 661 | enableParams.setBaseCongestionMarkingInterval(50_ms); |
Eric Newberry | 0c3e57b | 2018-01-25 20:54:46 -0700 | [diff] [blame] | 662 | enableParams.setDefaultCongestionThreshold(10000); |
| 663 | enableParams.setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, true); |
| 664 | |
| 665 | ControlParameters disableParams; |
| 666 | disableParams.setFaceId(faceId); |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 667 | disableParams.setBaseCongestionMarkingInterval(70_ms); |
Eric Newberry | 0c3e57b | 2018-01-25 20:54:46 -0700 | [diff] [blame] | 668 | disableParams.setDefaultCongestionThreshold(5000); |
| 669 | disableParams.setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, false); |
| 670 | |
| 671 | updateFace(enableParams, false, [] (const ControlResponse& actual) { |
| 672 | ControlResponse expected(200, "OK"); |
| 673 | BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode()); |
| 674 | BOOST_TEST_MESSAGE(actual.getText()); |
| 675 | |
| 676 | if (actual.getBody().hasWire()) { |
| 677 | ControlParameters actualParams(actual.getBody()); |
| 678 | |
| 679 | BOOST_CHECK(actualParams.hasFaceId()); |
| 680 | BOOST_CHECK(actualParams.hasFacePersistency()); |
| 681 | // Check that congestion marking parameters changed |
| 682 | BOOST_REQUIRE(actualParams.hasBaseCongestionMarkingInterval()); |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 683 | BOOST_CHECK_EQUAL(actualParams.getBaseCongestionMarkingInterval(), 50_ms); |
Eric Newberry | 0c3e57b | 2018-01-25 20:54:46 -0700 | [diff] [blame] | 684 | BOOST_REQUIRE(actualParams.hasDefaultCongestionThreshold()); |
| 685 | BOOST_CHECK_EQUAL(actualParams.getDefaultCongestionThreshold(), 10000); |
| 686 | BOOST_REQUIRE(actualParams.hasFlags()); |
| 687 | // Check if flags indicate congestion marking enabled |
| 688 | BOOST_CHECK(actualParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)); |
| 689 | } |
| 690 | else { |
| 691 | BOOST_ERROR("Enable: Response does not contain ControlParameters"); |
| 692 | } |
| 693 | }); |
| 694 | |
| 695 | updateFace(disableParams, false, [] (const ControlResponse& actual) { |
| 696 | ControlResponse expected(200, "OK"); |
| 697 | BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode()); |
| 698 | BOOST_TEST_MESSAGE(actual.getText()); |
| 699 | |
| 700 | if (actual.getBody().hasWire()) { |
| 701 | ControlParameters actualParams(actual.getBody()); |
| 702 | |
| 703 | BOOST_CHECK(actualParams.hasFaceId()); |
| 704 | BOOST_CHECK(actualParams.hasFacePersistency()); |
| 705 | // Check that congestion marking parameters changed, even though feature disabled |
| 706 | BOOST_REQUIRE(actualParams.hasBaseCongestionMarkingInterval()); |
Davide Pesavento | 3cf75dc | 2018-03-17 00:38:03 -0400 | [diff] [blame] | 707 | BOOST_CHECK_EQUAL(actualParams.getBaseCongestionMarkingInterval(), 70_ms); |
Eric Newberry | 0c3e57b | 2018-01-25 20:54:46 -0700 | [diff] [blame] | 708 | BOOST_REQUIRE(actualParams.hasDefaultCongestionThreshold()); |
| 709 | BOOST_CHECK_EQUAL(actualParams.getDefaultCongestionThreshold(), 5000); |
| 710 | BOOST_REQUIRE(actualParams.hasFlags()); |
| 711 | // Check if flags indicate marking disabled |
| 712 | BOOST_CHECK(!actualParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)); |
| 713 | } |
| 714 | else { |
| 715 | BOOST_ERROR("Disable: Response does not contain ControlParameters"); |
| 716 | } |
| 717 | }); |
| 718 | } |
| 719 | |
Eric Newberry | b5aa7f5 | 2016-09-03 20:36:12 -0700 | [diff] [blame] | 720 | BOOST_AUTO_TEST_CASE(SelfUpdating) |
| 721 | { |
| 722 | createFace(); |
| 723 | |
| 724 | // Send a command that does nothing (will return 200) and does not contain a FaceId |
| 725 | ControlParameters sentParams; |
| 726 | |
| 727 | updateFace(sentParams, true, [] (const ControlResponse& actual) { |
| 728 | ControlResponse expected(200, "OK"); |
| 729 | BOOST_REQUIRE_EQUAL(actual.getCode(), expected.getCode()); |
| 730 | BOOST_TEST_MESSAGE(actual.getText()); |
| 731 | }); |
| 732 | } |
| 733 | |
| 734 | BOOST_AUTO_TEST_SUITE_END() // UpdateFace |
| 735 | BOOST_AUTO_TEST_SUITE_END() // TestFaceManager |
| 736 | BOOST_AUTO_TEST_SUITE_END() // Mgmt |
| 737 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 738 | } // namespace nfd::tests |