fw: optimize FwNccStrategy/FavorRespondingUpstream test case
This test case previously relies on precise timing, and the slack is 3ms
in the worst case. Failure rate is high if system is slow.
This commit optimizes this tests case with several operation-limited
io runs, so that it doesn't rely on precise timing.
refs #2037
Change-Id: I80b87d830dcf8d87fce511e79eb9349f75c1c34d
diff --git a/tests/daemon/fw/ncc-strategy.cpp b/tests/daemon/fw/ncc-strategy.cpp
index d8e1ef1..ef89bb1 100644
--- a/tests/daemon/fw/ncc-strategy.cpp
+++ b/tests/daemon/fw/ncc-strategy.cpp
@@ -75,12 +75,12 @@
strategy->afterReceiveInterest(*face3, interest1, fibEntry, pitEntry1);
// forwards to face1 because routing says it's best
- limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(1));
+ // (no io run here: afterReceiveInterest has already sent the Interest)
BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 1);
BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[0].get<1>(), face1);
// forwards to face2 because face1 doesn't respond
- limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(500));
+ limitedIo.run(1, time::milliseconds(500));
BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 2);
BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[1].get<1>(), face2);
@@ -88,7 +88,7 @@
shared_ptr<Data> data1p = makeData("ndn:/0Jm1ajrW/%00");
Data& data1 = *data1p;
strategy->beforeSatisfyInterest(pitEntry1, *face2, data1);
- limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(500));
+ limitedIo.defer(time::milliseconds(500));
// second Interest: strategy knows face2 is best
shared_ptr<Interest> interest2p = makeInterest("ndn:/0Jm1ajrW/%00%01");
@@ -100,7 +100,7 @@
strategy->afterReceiveInterest(*face3, interest2, fibEntry, pitEntry2);
// forwards to face2 because it responds previously
- limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(1));
+ limitedIo.defer(time::milliseconds(1));
BOOST_REQUIRE_GE(strategy->m_sendInterestHistory.size(), 3);
BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[2].get<1>(), face2);
}