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