blob: 45ddc1f1730a151d1f5cf47ae360681471a22f35 [file] [log] [blame]
Yanbiao Li73860e32015-08-19 16:30:16 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi60286192017-07-26 01:07:48 +00002/*
Davide Pesaventoe422f9e2022-06-03 01:30:23 -04003 * Copyright (c) 2014-2022, Regents of the University of California,
Yanbiao Li73860e32015-08-19 16:30:16 -07004 * 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
Eric Newberry812d6152018-06-06 15:06:01 -070026#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
27#define BOOST_MPL_LIMIT_VECTOR_SIZE 40
28
Yanbiao Li58ba3f92017-02-15 14:27:18 +000029#include "mgmt/face-manager.hpp"
Eric Newberry0c3e57b2018-01-25 20:54:46 -070030#include "face/generic-link-service.hpp"
Eric Newberry42602412016-08-27 09:33:18 -070031#include "face-manager-command-fixture.hpp"
Junxiao Shib84e6742016-07-19 13:16:22 +000032
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040033namespace nfd::tests {
Yanbiao Li73860e32015-08-19 16:30:16 -070034
Yanbiao Li73860e32015-08-19 16:30:16 -070035BOOST_AUTO_TEST_SUITE(Mgmt)
36BOOST_AUTO_TEST_SUITE(TestFaceManager)
37
Davide Pesaventocf7db2f2019-03-24 23:17:28 -040038BOOST_FIXTURE_TEST_SUITE(CreateFace, GlobalIoFixture)
Yanbiao Li73860e32015-08-19 16:30:16 -070039
Yanbiao Li73860e32015-08-19 16:30:16 -070040class TcpFaceOnDemand
41{
42public:
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -040043 static ControlParameters
Yanbiao Li73860e32015-08-19 16:30:16 -070044 getParameters()
45 {
46 return ControlParameters()
47 .setUri("tcp4://127.0.0.1:26363")
48 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND);
49 }
50};
51
52class TcpFacePersistent
53{
54public:
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -040055 static ControlParameters
Yanbiao Li73860e32015-08-19 16:30:16 -070056 getParameters()
57 {
58 return ControlParameters()
59 .setUri("tcp4://127.0.0.1:26363")
60 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
61 }
62};
63
64class TcpFacePermanent
65{
66public:
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -040067 static ControlParameters
Yanbiao Li73860e32015-08-19 16:30:16 -070068 getParameters()
69 {
70 return ControlParameters()
71 .setUri("tcp4://127.0.0.1:26363")
72 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERMANENT);
73 }
74};
75
76class UdpFaceOnDemand
77{
78public:
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -040079 static ControlParameters
Yanbiao Li73860e32015-08-19 16:30:16 -070080 getParameters()
81 {
82 return ControlParameters()
83 .setUri("udp4://127.0.0.1:26363")
84 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND);
85 }
86};
87
Yanbiao Li73860e32015-08-19 16:30:16 -070088class UdpFacePersistent
89{
90public:
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -040091 static ControlParameters
Yanbiao Li73860e32015-08-19 16:30:16 -070092 getParameters()
93 {
94 return ControlParameters()
95 .setUri("udp4://127.0.0.1:26363")
96 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT);
97 }
98};
99
100class UdpFacePermanent
101{
102public:
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400103 static ControlParameters
Yanbiao Li73860e32015-08-19 16:30:16 -0700104 getParameters()
105 {
106 return ControlParameters()
107 .setUri("udp4://127.0.0.1:26363")
108 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERMANENT);
109 }
110};
111
Eric Newberryf40551a2016-09-05 15:41:16 -0700112class LocalTcpFaceLocalFieldsEnabled
113{
114public:
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400115 static ControlParameters
Eric Newberryf40551a2016-09-05 15:41:16 -0700116 getParameters()
117 {
118 return ControlParameters()
119 .setUri("tcp4://127.0.0.1:26363")
120 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
121 .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, true);
122 }
123};
124
125class LocalTcpFaceLocalFieldsDisabled
126{
127public:
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400128 static ControlParameters
Eric Newberryf40551a2016-09-05 15:41:16 -0700129 getParameters()
130 {
131 return ControlParameters()
132 .setUri("tcp4://127.0.0.1:26363")
133 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
134 .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, false);
135 }
136};
137
138class NonLocalUdpFaceLocalFieldsEnabled // won't work because non-local scope
139{
140public:
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400141 static ControlParameters
Eric Newberryf40551a2016-09-05 15:41:16 -0700142 getParameters()
143 {
144 return ControlParameters()
145 .setUri("udp4://127.0.0.1:26363")
146 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
147 .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, true);
148 }
149};
150
151class NonLocalUdpFaceLocalFieldsDisabled
152{
153public:
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400154 static ControlParameters
Eric Newberryf40551a2016-09-05 15:41:16 -0700155 getParameters()
156 {
157 return ControlParameters()
158 .setUri("udp4://127.0.0.1:26363")
159 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
160 .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, false);
161 }
162};
163
Eric Newberry2642cd22017-07-13 21:34:53 -0400164class TcpFaceLpReliabilityEnabled
165{
166public:
167 static ControlParameters
168 getParameters()
169 {
170 return ControlParameters()
171 .setUri("tcp4://127.0.0.1:26363")
172 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
173 .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true);
174 }
175};
176
177class TcpFaceLpReliabilityDisabled
178{
179public:
180 static ControlParameters
181 getParameters()
182 {
183 return ControlParameters()
184 .setUri("tcp4://127.0.0.1:26363")
185 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
186 .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, false);
187 }
188};
189
190class UdpFaceLpReliabilityEnabled
191{
192public:
193 static ControlParameters
194 getParameters()
195 {
196 return ControlParameters()
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700197 .setUri("udp4://127.0.0.1:26363")
Eric Newberry2642cd22017-07-13 21:34:53 -0400198 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
199 .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true);
200 }
201};
202
203class UdpFaceLpReliabilityDisabled
204{
205public:
206 static ControlParameters
207 getParameters()
208 {
209 return ControlParameters()
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700210 .setUri("udp4://127.0.0.1:26363")
Eric Newberry2642cd22017-07-13 21:34:53 -0400211 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
212 .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, false);
213 }
214};
215
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700216class TcpFaceCongestionMarkingEnabled
217{
218public:
219 static ControlParameters
220 getParameters()
221 {
222 return ControlParameters()
223 .setUri("tcp4://127.0.0.1:26363")
224 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
225 .setBaseCongestionMarkingInterval(50_ms)
226 .setDefaultCongestionThreshold(1000)
227 .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, true);
228 }
229};
230
231class TcpFaceCongestionMarkingDisabled
232{
233public:
234 static ControlParameters
235 getParameters()
236 {
237 return ControlParameters()
238 .setUri("tcp4://127.0.0.1:26363")
239 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
240 .setBaseCongestionMarkingInterval(50_ms)
241 .setDefaultCongestionThreshold(1000)
242 .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, false);
243 }
244};
245
Eric Newberry812d6152018-06-06 15:06:01 -0700246class TcpFaceMtuOverride
247{
248public:
249 static ControlParameters
250 getParameters()
251 {
252 return ControlParameters()
253 .setUri("tcp4://127.0.0.1:26363")
254 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
255 .setMtu(1000);
256 }
257};
258
259class UdpFaceMtuOverride
260{
261public:
262 static ControlParameters
263 getParameters()
264 {
265 return ControlParameters()
266 .setUri("udp4://127.0.0.1:26363")
267 .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
268 .setMtu(1000);
269 }
270};
271
Junxiao Shi38c7d9e2017-04-13 14:22:50 +0000272class FaceUriMalformed
273{
274public:
275 static ControlParameters
276 getParameters()
277 {
278 return ControlParameters()
279 .setUri("tcp4://127.0.0.1:not-a-port");
280 }
281};
282
283class FaceUriNonCanonical
284{
285public:
286 static ControlParameters
287 getParameters()
288 {
289 return ControlParameters()
290 .setUri("udp://localhost");
291 }
292};
293
294class FaceUriUnsupportedScheme
295{
296public:
297 static ControlParameters
298 getParameters()
299 {
300 return ControlParameters()
301 .setUri("dev://eth0");
302 }
303};
304
Yanbiao Li73860e32015-08-19 16:30:16 -0700305namespace mpl = boost::mpl;
306
Eric Newberry42602412016-08-27 09:33:18 -0700307// pairs of CreateCommand and Success/Failure status
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400308using TestCases = mpl::vector<
309 mpl::pair<TcpFaceOnDemand, CommandFailure<406>>,
Eric Newberryb5aa7f52016-09-03 20:36:12 -0700310 mpl::pair<TcpFacePersistent, CommandSuccess>,
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400311 mpl::pair<TcpFacePermanent, CommandSuccess>,
Eric Newberryb5aa7f52016-09-03 20:36:12 -0700312 mpl::pair<UdpFaceOnDemand, CommandFailure<406>>,
313 mpl::pair<UdpFacePersistent, CommandSuccess>,
314 mpl::pair<UdpFacePermanent, CommandSuccess>,
Eric Newberryf40551a2016-09-05 15:41:16 -0700315 mpl::pair<LocalTcpFaceLocalFieldsEnabled, CommandSuccess>,
316 mpl::pair<LocalTcpFaceLocalFieldsDisabled, CommandSuccess>,
317 mpl::pair<NonLocalUdpFaceLocalFieldsEnabled, CommandFailure<406>>,
Junxiao Shi38c7d9e2017-04-13 14:22:50 +0000318 mpl::pair<NonLocalUdpFaceLocalFieldsDisabled, CommandSuccess>,
Eric Newberry2642cd22017-07-13 21:34:53 -0400319 mpl::pair<TcpFaceLpReliabilityEnabled, CommandSuccess>,
320 mpl::pair<TcpFaceLpReliabilityDisabled, CommandSuccess>,
321 mpl::pair<UdpFaceLpReliabilityEnabled, CommandSuccess>,
322 mpl::pair<UdpFaceLpReliabilityDisabled, CommandSuccess>,
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700323 mpl::pair<TcpFaceCongestionMarkingEnabled, CommandSuccess>,
324 mpl::pair<TcpFaceCongestionMarkingDisabled, CommandSuccess>,
Eric Newberry812d6152018-06-06 15:06:01 -0700325 mpl::pair<TcpFaceMtuOverride, CommandFailure<406>>,
326 mpl::pair<UdpFaceMtuOverride, CommandSuccess>,
Junxiao Shi38c7d9e2017-04-13 14:22:50 +0000327 mpl::pair<FaceUriMalformed, CommandFailure<400>>,
328 mpl::pair<FaceUriNonCanonical, CommandFailure<400>>,
329 mpl::pair<FaceUriUnsupportedScheme, CommandFailure<406>>>;
Yanbiao Li73860e32015-08-19 16:30:16 -0700330
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400331BOOST_FIXTURE_TEST_CASE_TEMPLATE(NewFace, T, TestCases, FaceManagerCommandFixture)
Yanbiao Li73860e32015-08-19 16:30:16 -0700332{
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400333 using FaceType = typename T::first;
334 using CreateResult = typename T::second;
Yanbiao Li73860e32015-08-19 16:30:16 -0700335
Junxiao Shi8a1f1702017-07-03 00:05:08 +0000336 Interest req = makeControlCommandRequest("/localhost/nfd/faces/create", FaceType::getParameters());
Yanbiao Li73860e32015-08-19 16:30:16 -0700337
338 bool hasCallbackFired = false;
Junxiao Shi8a1f1702017-07-03 00:05:08 +0000339 this->node1.face.onSendData.connect([this, req, &hasCallbackFired] (const Data& response) {
340 if (!req.getName().isPrefixOf(response.getName())) {
Eric Newberry42602412016-08-27 09:33:18 -0700341 return;
342 }
Yanbiao Li73860e32015-08-19 16:30:16 -0700343
Eric Newberry42602412016-08-27 09:33:18 -0700344 ControlResponse actual(response.getContent().blockFromValue());
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400345 ControlResponse expected(CreateResult::getExpected());
Eric Newberry42602412016-08-27 09:33:18 -0700346 BOOST_TEST_MESSAGE(actual.getText());
Yanbiao Li58ba3f92017-02-15 14:27:18 +0000347 BOOST_CHECK_EQUAL(expected.getCode(), actual.getCode());
Yanbiao Li73860e32015-08-19 16:30:16 -0700348
Eric Newberry42602412016-08-27 09:33:18 -0700349 if (actual.getBody().hasWire()) {
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400350 ControlParameters expectedParams(FaceType::getParameters());
Eric Newberry42602412016-08-27 09:33:18 -0700351 ControlParameters actualParams(actual.getBody());
Yanbiao Li73860e32015-08-19 16:30:16 -0700352
Eric Newberry42602412016-08-27 09:33:18 -0700353 BOOST_CHECK(actualParams.hasFaceId());
354 BOOST_CHECK_EQUAL(expectedParams.getFacePersistency(), actualParams.getFacePersistency());
355
Eric Newberryb5aa7f52016-09-03 20:36:12 -0700356 if (actual.getCode() == 200) {
357 if (expectedParams.hasFlags()) {
Eric Newberryf40551a2016-09-05 15:41:16 -0700358 BOOST_CHECK_EQUAL(expectedParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED),
359 actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED));
Eric Newberry2642cd22017-07-13 21:34:53 -0400360 BOOST_CHECK_EQUAL(expectedParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED),
361 actualParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED));
Eric Newberry17d18492018-02-10 22:50:06 -0700362 if (expectedParams.hasFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)) {
363 BOOST_CHECK_EQUAL(expectedParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED),
364 actualParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED));
365 }
366 else {
367 BOOST_CHECK(actualParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED));
368 }
Eric Newberryb5aa7f52016-09-03 20:36:12 -0700369 }
370 else {
Eric Newberry17d18492018-02-10 22:50:06 -0700371 // local fields and LpReliability are disabled by default, congestion marking is enabled
372 // by default on TCP, UDP, and Unix stream
373 BOOST_CHECK(!actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED));
374 BOOST_CHECK(!actualParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED));
375 BOOST_CHECK(actualParams.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED));
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700376 }
377
378 if (expectedParams.hasBaseCongestionMarkingInterval()) {
379 BOOST_CHECK_EQUAL(expectedParams.getBaseCongestionMarkingInterval(),
380 actualParams.getBaseCongestionMarkingInterval());
381 }
382 else {
383 BOOST_CHECK_EQUAL(actualParams.getBaseCongestionMarkingInterval(), 100_ms);
384 }
385
386 if (expectedParams.hasDefaultCongestionThreshold()) {
387 BOOST_CHECK_EQUAL(expectedParams.getDefaultCongestionThreshold(),
388 actualParams.getDefaultCongestionThreshold());
389 }
390 else {
391 BOOST_CHECK_EQUAL(actualParams.getDefaultCongestionThreshold(), 65536);
Eric Newberryb5aa7f52016-09-03 20:36:12 -0700392 }
Eric Newberry812d6152018-06-06 15:06:01 -0700393
394 if (expectedParams.hasMtu()) {
395 BOOST_CHECK_EQUAL(expectedParams.getMtu(), actualParams.getMtu());
396 }
Eric Newberryb5aa7f52016-09-03 20:36:12 -0700397 }
398 else {
Yanbiao Li73860e32015-08-19 16:30:16 -0700399 BOOST_CHECK_EQUAL(expectedParams.getUri(), actualParams.getUri());
Yanbiao Li73860e32015-08-19 16:30:16 -0700400 }
Eric Newberry42602412016-08-27 09:33:18 -0700401 }
Eric Newberryb5aa7f52016-09-03 20:36:12 -0700402
403 if (actual.getCode() != 200) {
Junxiao Shi38c7d9e2017-04-13 14:22:50 +0000404 FaceUri uri;
405 if (uri.parse(FaceType::getParameters().getUri())) {
406 // ensure face not created
Davide Pesaventob5eee202017-09-21 23:59:22 -0400407 const auto& faceTable = this->node1.faceTable;
Junxiao Shi38c7d9e2017-04-13 14:22:50 +0000408 BOOST_CHECK(std::none_of(faceTable.begin(), faceTable.end(), [uri] (Face& face) {
409 return face.getRemoteUri() == uri;
410 }));
411 }
412 else {
413 // do not check malformed FaceUri
414 }
Eric Newberryb5aa7f52016-09-03 20:36:12 -0700415 }
416
Eric Newberry42602412016-08-27 09:33:18 -0700417 hasCallbackFired = true;
418 });
Yanbiao Li73860e32015-08-19 16:30:16 -0700419
Junxiao Shi8a1f1702017-07-03 00:05:08 +0000420 this->node1.face.receive(req);
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700421 this->advanceClocks(1_ms, 5);
Yanbiao Li73860e32015-08-19 16:30:16 -0700422
423 BOOST_CHECK(hasCallbackFired);
424}
425
Yanbiao Li58ba3f92017-02-15 14:27:18 +0000426BOOST_FIXTURE_TEST_CASE(ExistingFace, FaceManagerCommandFixture)
Yanbiao Li73860e32015-08-19 16:30:16 -0700427{
Yanbiao Li58ba3f92017-02-15 14:27:18 +0000428 using FaceType = UdpFacePersistent;
Yanbiao Li73860e32015-08-19 16:30:16 -0700429
430 {
431 // create face
Junxiao Shi8a1f1702017-07-03 00:05:08 +0000432 Interest req = makeControlCommandRequest("/localhost/nfd/faces/create", FaceType::getParameters());
433 this->node1.face.receive(req);
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700434 this->advanceClocks(1_ms, 5);
Yanbiao Li73860e32015-08-19 16:30:16 -0700435 }
436
Yanbiao Li58ba3f92017-02-15 14:27:18 +0000437 // find the created face
Davide Pesaventoa3c9ddb2017-04-10 22:15:24 -0400438 auto foundFace = this->node1.findFaceByUri(FaceType::getParameters().getUri());
Yanbiao Li58ba3f92017-02-15 14:27:18 +0000439 BOOST_REQUIRE(foundFace != nullptr);
Yanbiao Li73860e32015-08-19 16:30:16 -0700440
441 {
Yanbiao Li58ba3f92017-02-15 14:27:18 +0000442 // re-create face
Junxiao Shi8a1f1702017-07-03 00:05:08 +0000443 Interest req = makeControlCommandRequest("/localhost/nfd/faces/create", FaceType::getParameters());
Yanbiao Li73860e32015-08-19 16:30:16 -0700444
445 bool hasCallbackFired = false;
Junxiao Shib84e6742016-07-19 13:16:22 +0000446 this->node1.face.onSendData.connect(
Davide Pesaventoac238f22017-09-12 15:19:40 -0400447 [req, foundFace, &hasCallbackFired] (const Data& response) {
Junxiao Shi8a1f1702017-07-03 00:05:08 +0000448 if (!req.getName().isPrefixOf(response.getName())) {
Yanbiao Li73860e32015-08-19 16:30:16 -0700449 return;
450 }
451
452 ControlResponse actual(response.getContent().blockFromValue());
Yanbiao Li58ba3f92017-02-15 14:27:18 +0000453 BOOST_REQUIRE_EQUAL(actual.getCode(), 409);
Yanbiao Li73860e32015-08-19 16:30:16 -0700454
Yanbiao Li73860e32015-08-19 16:30:16 -0700455 ControlParameters actualParams(actual.getBody());
Yanbiao Li58ba3f92017-02-15 14:27:18 +0000456 BOOST_CHECK_EQUAL(foundFace->getId(), actualParams.getFaceId());
457 BOOST_CHECK_EQUAL(foundFace->getRemoteUri().toString(), actualParams.getUri());
458 BOOST_CHECK_EQUAL(foundFace->getPersistency(), actualParams.getFacePersistency());
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700459 auto linkService = dynamic_cast<face::GenericLinkService*>(foundFace->getLinkService());
460 BOOST_CHECK_EQUAL(linkService->getOptions().baseCongestionMarkingInterval,
461 actualParams.getBaseCongestionMarkingInterval());
462 BOOST_CHECK_EQUAL(linkService->getOptions().defaultCongestionThreshold,
463 actualParams.getDefaultCongestionThreshold());
Yanbiao Li73860e32015-08-19 16:30:16 -0700464
465 hasCallbackFired = true;
466 });
467
Junxiao Shi8a1f1702017-07-03 00:05:08 +0000468 this->node1.face.receive(req);
Eric Newberry0c3e57b2018-01-25 20:54:46 -0700469 this->advanceClocks(1_ms, 5);
Yanbiao Li73860e32015-08-19 16:30:16 -0700470
471 BOOST_CHECK(hasCallbackFired);
472 }
473}
474
475BOOST_AUTO_TEST_SUITE_END() // CreateFace
476BOOST_AUTO_TEST_SUITE_END() // TestFaceManager
477BOOST_AUTO_TEST_SUITE_END() // Mgmt
478
Davide Pesaventoe422f9e2022-06-03 01:30:23 -0400479} // namespace nfd::tests