Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
ashiqopu | 3ad49db | 2018-10-20 22:38:47 +0000 | [diff] [blame] | 2 | /* |
Alexander Afanasyev | 4400e42 | 2021-02-17 11:17:33 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2021, Regents of the University of California, |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [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 | |
| 26 | /** \file |
| 27 | * This test suite tests localhost and localhop scope control in strategies. |
| 28 | */ |
| 29 | |
| 30 | // Strategies implementing namespace-based scope control, sorted alphabetically. |
| 31 | #include "fw/access-strategy.hpp" |
Ashlesh Gawande | 2a73f35 | 2016-12-01 15:37:03 +0000 | [diff] [blame] | 32 | #include "fw/asf-strategy.hpp" |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 33 | #include "fw/best-route-strategy.hpp" |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 34 | #include "fw/best-route-strategy2.hpp" |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 35 | #include "fw/multicast-strategy.hpp" |
Klaus Schneider | cf1d0c0 | 2019-08-31 19:05:40 -0700 | [diff] [blame] | 36 | #include "fw/random-strategy.hpp" |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 37 | |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 38 | #include "tests/test-common.hpp" |
| 39 | #include "tests/daemon/face/dummy-face.hpp" |
Junxiao Shi | 0e4a1f1 | 2016-12-24 02:39:01 +0000 | [diff] [blame] | 40 | #include "choose-strategy.hpp" |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 41 | #include "strategy-tester.hpp" |
Davide Pesavento | 3dade00 | 2019-03-19 11:29:56 -0600 | [diff] [blame] | 42 | |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 43 | #include <boost/mpl/vector.hpp> |
| 44 | |
| 45 | namespace nfd { |
| 46 | namespace fw { |
| 47 | namespace tests { |
| 48 | |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 49 | template<typename S> |
Davide Pesavento | cf7db2f | 2019-03-24 23:17:28 -0400 | [diff] [blame] | 50 | class StrategyScopeControlFixture : public GlobalIoTimeFixture |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 51 | { |
| 52 | public: |
| 53 | StrategyScopeControlFixture() |
| 54 | : limitedIo(this) |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 55 | , forwarder(faceTable) |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 56 | , strategy(choose<StrategyTester<S>>(forwarder)) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 57 | , fib(forwarder.getFib()) |
| 58 | , pit(forwarder.getPit()) |
| 59 | , nonLocalFace1(make_shared<DummyFace>("dummy://1", "dummy://1", ndn::nfd::FACE_SCOPE_NON_LOCAL)) |
| 60 | , nonLocalFace2(make_shared<DummyFace>("dummy://2", "dummy://2", ndn::nfd::FACE_SCOPE_NON_LOCAL)) |
| 61 | , localFace3(make_shared<DummyFace>("dummy://3", "dummy://3", ndn::nfd::FACE_SCOPE_LOCAL)) |
| 62 | , localFace4(make_shared<DummyFace>("dummy://4", "dummy://4", ndn::nfd::FACE_SCOPE_LOCAL)) |
| 63 | { |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 64 | faceTable.add(nonLocalFace1); |
| 65 | faceTable.add(nonLocalFace2); |
| 66 | faceTable.add(localFace3); |
| 67 | faceTable.add(localFace4); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 68 | } |
| 69 | |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 70 | public: |
| 71 | LimitedIo limitedIo; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 72 | |
Davide Pesavento | a4abfb0 | 2019-10-06 16:02:56 -0400 | [diff] [blame] | 73 | FaceTable faceTable; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 74 | Forwarder forwarder; |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 75 | StrategyTester<S>& strategy; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 76 | Fib& fib; |
| 77 | Pit& pit; |
| 78 | |
| 79 | shared_ptr<Face> nonLocalFace1; |
| 80 | shared_ptr<Face> nonLocalFace2; |
| 81 | shared_ptr<Face> localFace3; |
| 82 | shared_ptr<Face> localFace4; |
| 83 | }; |
| 84 | |
| 85 | BOOST_AUTO_TEST_SUITE(Fw) |
| 86 | BOOST_AUTO_TEST_SUITE(TestStrategyScopeControl) |
| 87 | |
Davide Pesavento | 29abf4c | 2021-03-05 18:40:01 -0500 | [diff] [blame^] | 88 | template<typename S, bool WillSendNackNoRoute, bool CanProcessNack, bool WillRejectPitEntry> |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 89 | class Test |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 90 | { |
| 91 | public: |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 92 | using Strategy = S; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 93 | |
| 94 | static bool |
Alexander Afanasyev | 4400e42 | 2021-02-17 11:17:33 -0500 | [diff] [blame] | 95 | willRejectPitEntry() |
| 96 | { |
| 97 | return WillRejectPitEntry; |
| 98 | } |
| 99 | |
| 100 | static bool |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 101 | willSendNackNoRoute() |
| 102 | { |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 103 | return WillSendNackNoRoute; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | static bool |
| 107 | canProcessNack() |
| 108 | { |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 109 | return CanProcessNack; |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 110 | } |
| 111 | }; |
| 112 | |
| 113 | using Tests = boost::mpl::vector< |
Davide Pesavento | 29abf4c | 2021-03-05 18:40:01 -0500 | [diff] [blame^] | 114 | Test<AccessStrategy, false, false, true>, |
| 115 | Test<AsfStrategy, true, false, true>, |
| 116 | Test<BestRouteStrategy, false, false, true>, |
| 117 | Test<BestRouteStrategy2, true, true, true>, |
Alexander Afanasyev | 4400e42 | 2021-02-17 11:17:33 -0500 | [diff] [blame] | 118 | Test<MulticastStrategy, false, false, false>, |
Davide Pesavento | 29abf4c | 2021-03-05 18:40:01 -0500 | [diff] [blame^] | 119 | Test<RandomStrategy, true, true, true> |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 120 | >; |
| 121 | |
| 122 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostInterestToLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 123 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 124 | { |
| 125 | fib::Entry* fibEntry = this->fib.insert("/localhost/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 126 | this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 10); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 127 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 128 | auto interest = makeInterest("/localhost/A/1"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 129 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 130 | pitEntry->insertOrUpdateInRecord(*this->localFace3, *interest); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 131 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 132 | BOOST_REQUIRE(this->strategy.waitForAction( |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 133 | [&] { this->strategy.afterReceiveInterest(FaceEndpoint(*this->localFace3, 0), *interest, pitEntry); }, |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 134 | this->limitedIo)); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 135 | |
| 136 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 1); |
| 137 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); |
| 138 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.size(), 0); |
| 139 | } |
| 140 | |
| 141 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostInterestToNonLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 142 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 143 | { |
| 144 | fib::Entry* fibEntry = this->fib.insert("/localhost/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 145 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 10); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 146 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 147 | auto interest = makeInterest("/localhost/A/1"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 148 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 149 | pitEntry->insertOrUpdateInRecord(*this->localFace3, *interest); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 150 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 151 | BOOST_REQUIRE(this->strategy.waitForAction( |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 152 | [&] { this->strategy.afterReceiveInterest(FaceEndpoint(*this->localFace3, 0), *interest, pitEntry); }, |
Alexander Afanasyev | 4400e42 | 2021-02-17 11:17:33 -0500 | [diff] [blame] | 153 | this->limitedIo, T::willRejectPitEntry() + T::willSendNackNoRoute())); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 154 | |
| 155 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); |
Alexander Afanasyev | 4400e42 | 2021-02-17 11:17:33 -0500 | [diff] [blame] | 156 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), T::willRejectPitEntry()); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 157 | if (T::willSendNackNoRoute()) { |
| 158 | BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); |
| 159 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostInterestToLocalAndNonLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 164 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 165 | { |
| 166 | fib::Entry* fibEntry = this->fib.insert("/localhost/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 167 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 10); |
| 168 | this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 20); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 169 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 170 | auto interest = makeInterest("/localhost/A/1"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 171 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 172 | pitEntry->insertOrUpdateInRecord(*this->localFace3, *interest); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 173 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 174 | BOOST_REQUIRE(this->strategy.waitForAction( |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 175 | [&] { this->strategy.afterReceiveInterest(FaceEndpoint(*this->localFace3, 0), *interest, pitEntry); }, |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 176 | this->limitedIo)); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 177 | |
| 178 | BOOST_REQUIRE_EQUAL(this->strategy.sendInterestHistory.size(), 1); |
| 179 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.back().outFaceId, this->localFace4->getId()); |
| 180 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); |
| 181 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.size(), 0); |
| 182 | } |
| 183 | |
| 184 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopInterestToNonLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 185 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 186 | { |
| 187 | fib::Entry* fibEntry = this->fib.insert("/localhop/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 188 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 10); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 189 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 190 | auto interest = makeInterest("/localhop/A/1"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 191 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 192 | pitEntry->insertOrUpdateInRecord(*this->nonLocalFace1, *interest); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 193 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 194 | BOOST_REQUIRE(this->strategy.waitForAction( |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 195 | [&] { this->strategy.afterReceiveInterest(FaceEndpoint(*this->nonLocalFace1, 0), *interest, pitEntry); }, |
Alexander Afanasyev | 4400e42 | 2021-02-17 11:17:33 -0500 | [diff] [blame] | 196 | this->limitedIo, T::willRejectPitEntry() + T::willSendNackNoRoute())); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 197 | |
| 198 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); |
Alexander Afanasyev | 4400e42 | 2021-02-17 11:17:33 -0500 | [diff] [blame] | 199 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), T::willRejectPitEntry()); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 200 | if (T::willSendNackNoRoute()) { |
| 201 | BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); |
| 202 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopInterestToNonLocalAndLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 207 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 208 | { |
| 209 | fib::Entry* fibEntry = this->fib.insert("/localhop/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 210 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 10); |
| 211 | this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 20); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 212 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 213 | auto interest = makeInterest("/localhop/A/1"); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 214 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 215 | pitEntry->insertOrUpdateInRecord(*this->nonLocalFace1, *interest); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 216 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 217 | BOOST_REQUIRE(this->strategy.waitForAction( |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 218 | [&] { this->strategy.afterReceiveInterest(FaceEndpoint(*this->nonLocalFace1, 0), *interest, pitEntry); }, |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 219 | this->limitedIo)); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 220 | |
| 221 | BOOST_REQUIRE_EQUAL(this->strategy.sendInterestHistory.size(), 1); |
| 222 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.back().outFaceId, this->localFace4->getId()); |
| 223 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); |
| 224 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.size(), 0); |
| 225 | } |
| 226 | |
| 227 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhostNackToNonLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 228 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 229 | { |
| 230 | fib::Entry* fibEntry = this->fib.insert("/localhost/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 231 | this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 10); |
| 232 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 20); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 233 | |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 234 | auto interest = makeInterest("/localhost/A/1", false, nullopt, 1460); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 235 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 236 | pitEntry->insertOrUpdateInRecord(*this->localFace3, *interest); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 237 | lp::Nack nack = makeNack(*interest, lp::NackReason::NO_ROUTE); |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 238 | pitEntry->insertOrUpdateOutRecord(*this->localFace4, *interest)->setIncomingNack(nack); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 239 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 240 | BOOST_REQUIRE(this->strategy.waitForAction( |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 241 | [&] { this->strategy.afterReceiveNack(FaceEndpoint(*this->localFace4, 0), nack, pitEntry); }, |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 242 | this->limitedIo, T::canProcessNack())); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 243 | |
| 244 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); |
| 245 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); |
| 246 | if (T::canProcessNack()) { |
| 247 | BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); |
| 248 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | BOOST_FIXTURE_TEST_CASE_TEMPLATE(LocalhopNackToNonLocal, |
Junxiao Shi | e21b3f3 | 2016-11-24 14:13:46 +0000 | [diff] [blame] | 253 | T, Tests, StrategyScopeControlFixture<typename T::Strategy>) |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 254 | { |
| 255 | fib::Entry* fibEntry = this->fib.insert("/localhop/A").first; |
Ju Pan | d8315bf | 2019-07-31 06:59:07 +0000 | [diff] [blame] | 256 | this->fib.addOrUpdateNextHop(*fibEntry, *this->localFace4, 10); |
| 257 | this->fib.addOrUpdateNextHop(*fibEntry, *this->nonLocalFace2, 20); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 258 | |
Davide Pesavento | 29abf4c | 2021-03-05 18:40:01 -0500 | [diff] [blame^] | 259 | auto interest = makeInterest("/localhop/A/1", false, nullopt, 1377); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 260 | shared_ptr<pit::Entry> pitEntry = this->pit.insert(*interest).first; |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 261 | pitEntry->insertOrUpdateInRecord(*this->nonLocalFace1, *interest); |
Junxiao Shi | 9d72785 | 2019-05-14 13:44:22 -0600 | [diff] [blame] | 262 | lp::Nack nack = makeNack(*interest, lp::NackReason::NO_ROUTE); |
Md Ashiqur Rahman | c88d2d4 | 2019-08-28 20:19:47 +0000 | [diff] [blame] | 263 | pitEntry->insertOrUpdateOutRecord(*this->localFace4, *interest)->setIncomingNack(nack); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 264 | |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 265 | BOOST_REQUIRE(this->strategy.waitForAction( |
ashiqopu | c707948 | 2019-02-20 05:34:37 +0000 | [diff] [blame] | 266 | [&] { this->strategy.afterReceiveNack(FaceEndpoint(*this->localFace4, 0), nack, pitEntry); }, |
Junxiao Shi | 9954007 | 2017-01-27 19:57:33 +0000 | [diff] [blame] | 267 | this->limitedIo, T::canProcessNack())); |
Junxiao Shi | a7f9a29 | 2016-11-22 16:31:38 +0000 | [diff] [blame] | 268 | |
| 269 | BOOST_CHECK_EQUAL(this->strategy.sendInterestHistory.size(), 0); |
| 270 | BOOST_CHECK_EQUAL(this->strategy.rejectPendingInterestHistory.size(), 0); |
| 271 | if (T::canProcessNack()) { |
| 272 | BOOST_REQUIRE_EQUAL(this->strategy.sendNackHistory.size(), 1); |
| 273 | BOOST_CHECK_EQUAL(this->strategy.sendNackHistory.back().header.getReason(), lp::NackReason::NO_ROUTE); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | BOOST_AUTO_TEST_SUITE_END() // TestStrategyScopeControl |
| 278 | BOOST_AUTO_TEST_SUITE_END() // Fw |
| 279 | |
| 280 | } // namespace tests |
| 281 | } // namespace fw |
| 282 | } // namespace nfd |