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