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