fw: Nack in pipelines and best-route strategy
* in PIT out-record, add last incoming Nack field
* create incoming Nack pipeline
* create outgoing Nack pipeline
* modify Interest loop pipeline to send Nack upon duplicate Nonce
* in strategy API, add after receive Nack trigger and send Nack action
* in best-route strategy, send Nack-NoRoute before rejecting pending Interest
* in best-route strategy, process incoming Nack
Other changes include:
* Pit::find
* StrategyTester saved arguments structs
* TopologyTester transmit at Transport level
refs #3156
Change-Id: I7868561c0838231083d471261200aeb280cc6e9d
diff --git a/tests/daemon/table/pit.t.cpp b/tests/daemon/table/pit.t.cpp
index 7bd89fc..dd02bec 100644
--- a/tests/daemon/table/pit.t.cpp
+++ b/tests/daemon/table/pit.t.cpp
@@ -34,9 +34,12 @@
using namespace nfd::tests;
-BOOST_FIXTURE_TEST_SUITE(TablePit, BaseFixture)
+BOOST_AUTO_TEST_SUITE(Table)
+BOOST_FIXTURE_TEST_SUITE(TestPit, BaseFixture)
-BOOST_AUTO_TEST_CASE(EntryInOutRecords)
+BOOST_AUTO_TEST_SUITE(PitEntry)
+
+BOOST_AUTO_TEST_CASE(InOutRecords)
{
shared_ptr<Face> face1 = make_shared<DummyFace>();
shared_ptr<Face> face2 = make_shared<DummyFace>();
@@ -151,7 +154,7 @@
BOOST_CHECK(entry.getOutRecord(*face2) == entry.getOutRecords().end());
}
-BOOST_AUTO_TEST_CASE(EntryNonce)
+BOOST_AUTO_TEST_CASE(Nonce)
{
shared_ptr<Face> face1 = make_shared<DummyFace>();
shared_ptr<Face> face2 = make_shared<DummyFace>();
@@ -210,7 +213,7 @@
BOOST_CHECK_EQUAL(entry5.findNonce(19004, *face2), pit::DUPLICATE_NONCE_NONE);
}
-BOOST_AUTO_TEST_CASE(EntryLifetime)
+BOOST_AUTO_TEST_CASE(Lifetime)
{
shared_ptr<Interest> interest = makeInterest("ndn:/7oIEurbgy6");
// library uses -1 to indicate unset lifetime
@@ -226,7 +229,7 @@
BOOST_CHECK_GT(outIt->getExpiry(), time::steady_clock::now());
}
-BOOST_AUTO_TEST_CASE(EntryCanForwardTo)
+BOOST_AUTO_TEST_CASE(CanForwardTo)
{
shared_ptr<Interest> interest = makeInterest("ndn:/WDsuBLIMG");
pit::Entry entry(*interest);
@@ -247,6 +250,37 @@
BOOST_CHECK_EQUAL(entry.canForwardTo(*face2), true);
}
+BOOST_AUTO_TEST_CASE(OutRecordNack)
+{
+ shared_ptr<Face> face1 = make_shared<DummyFace>();
+ pit::OutRecord outR(face1);
+ BOOST_CHECK(outR.getIncomingNack() == nullptr);
+
+ shared_ptr<Interest> interest1 = makeInterest("ndn:/uWiapGjYL");
+ interest1->setNonce(165);
+ outR.update(*interest1);
+ BOOST_CHECK(outR.getIncomingNack() == nullptr);
+
+ shared_ptr<Interest> interest2 = makeInterest("ndn:/uWiapGjYL");
+ interest2->setNonce(996);
+ lp::Nack nack2(*interest2);
+ nack2.setReason(lp::NackReason::CONGESTION);
+ BOOST_CHECK_EQUAL(outR.setIncomingNack(nack2), false);
+ BOOST_CHECK(outR.getIncomingNack() == nullptr);
+
+ lp::Nack nack1(*interest1);
+ nack1.setReason(lp::NackReason::DUPLICATE);
+ BOOST_CHECK_EQUAL(outR.setIncomingNack(nack1), true);
+ BOOST_REQUIRE(outR.getIncomingNack() != nullptr);
+ BOOST_CHECK_EQUAL(outR.getIncomingNack()->getReason(), lp::NackReason::DUPLICATE);
+
+ outR.clearIncomingNack();
+ BOOST_CHECK(outR.getIncomingNack() == nullptr);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // PitEntry
+
+
BOOST_AUTO_TEST_CASE(Insert)
{
Name name1("ndn:/5vzBNnMst");
@@ -368,18 +402,21 @@
insertResult = pit.insert(*interest);
BOOST_CHECK_EQUAL(insertResult.second, true);
BOOST_CHECK_EQUAL(pit.size(), 1);
+ BOOST_CHECK(pit.find(*interest) != nullptr);
insertResult = pit.insert(*interest);
BOOST_CHECK_EQUAL(insertResult.second, false);
BOOST_CHECK_EQUAL(pit.size(), 1);
+ BOOST_CHECK(pit.find(*interest) != nullptr);
pit.erase(insertResult.first);
BOOST_CHECK_EQUAL(pit.size(), 0);
+ BOOST_CHECK(pit.find(*interest) == nullptr);
insertResult = pit.insert(*interest);
BOOST_CHECK_EQUAL(insertResult.second, true);
BOOST_CHECK_EQUAL(pit.size(), 1);
-
+ BOOST_CHECK(pit.find(*interest) != nullptr);
}
BOOST_AUTO_TEST_CASE(EraseNameTreeEntry)
@@ -496,6 +533,7 @@
}
BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END()
} // namespace tests
} // namespace pit