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