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