rib: move RibManager to mgmt
Refs: #4528
Change-Id: Idff4ce8fe28b48163794cd12f0d185f8ca4233e3
diff --git a/tests/daemon/rib/sl-announce.t.cpp b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
similarity index 92%
rename from tests/daemon/rib/sl-announce.t.cpp
rename to tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
index 86b6025..06e3d5e 100644
--- a/tests/daemon/rib/sl-announce.t.cpp
+++ b/tests/daemon/mgmt/rib-manager-sl-announce.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -23,17 +23,17 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "rib/rib-manager.hpp"
+#include "mgmt/rib-manager.hpp"
+#include "rib/fib-updater.hpp"
#include "tests/identity-management-fixture.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace nfd {
-namespace rib {
namespace tests {
-using namespace nfd::tests;
+using rib::Route;
class RibManagerSlAnnounceFixture : public IdentityManagementTimeFixture
{
@@ -49,7 +49,7 @@
, m_trustedSigner(m_keyChain.createIdentity("/trusted", ndn::RsaKeyParams()))
, m_untrustedSigner(m_keyChain.createIdentity("/untrusted", ndn::RsaKeyParams()))
{
- rib.mockFibResponse = [] (const RibUpdateBatch&) { return true; };
+ rib.mockFibResponse = [] (const auto&) { return true; };
rib.wantMockFibResponseOnce = false;
// Face, Controller, Dispatcher are irrelevant to SlAnnounce functions but required by
@@ -62,16 +62,16 @@
template<typename ...T>
ndn::PrefixAnnouncement
- makeTrustedAnn(const T&... args)
+ makeTrustedAnn(T&&... args)
{
- return signPrefixAnn(makePrefixAnn(args...), m_keyChain, m_trustedSigner);
+ return signPrefixAnn(makePrefixAnn(std::forward<T>(args)...), m_keyChain, m_trustedSigner);
}
template<typename ...T>
ndn::PrefixAnnouncement
- makeUntrustedAnn(const T&... args)
+ makeUntrustedAnn(T&&... args)
{
- return signPrefixAnn(makePrefixAnn(args...), m_keyChain, m_untrustedSigner);
+ return signPrefixAnn(makePrefixAnn(std::forward<T>(args)...), m_keyChain, m_untrustedSigner);
}
/** \brief Invoke manager->slAnnounce and wait for result.
@@ -158,7 +158,7 @@
}
public:
- Rib rib;
+ rib::Rib rib;
unique_ptr<RibManager> manager;
private:
@@ -166,13 +166,15 @@
ndn::util::Scheduler m_scheduler;
ndn::nfd::Controller m_nfdController;
ndn::mgmt::Dispatcher m_dispatcher;
- FibUpdater m_fibUpdater;
+ rib::FibUpdater m_fibUpdater;
ndn::security::SigningInfo m_trustedSigner;
ndn::security::SigningInfo m_untrustedSigner;
};
-BOOST_FIXTURE_TEST_SUITE(TestSlAnnounce, RibManagerSlAnnounceFixture)
+BOOST_AUTO_TEST_SUITE(Mgmt)
+BOOST_AUTO_TEST_SUITE(TestRibManager)
+BOOST_FIXTURE_TEST_SUITE(SlAnnounce, RibManagerSlAnnounceFixture)
BOOST_AUTO_TEST_CASE(AnnounceUnconfigured)
{
@@ -327,8 +329,9 @@
BOOST_CHECK(!pa);
}
-BOOST_AUTO_TEST_SUITE_END() // TestSlAnnounce
+BOOST_AUTO_TEST_SUITE_END() // SlAnnounce
+BOOST_AUTO_TEST_SUITE_END() // TestRibManager
+BOOST_AUTO_TEST_SUITE_END() // Mgmt
} // namespace tests
-} // namespace rib
} // namespace nfd
diff --git a/tests/daemon/rib/rib-manager.t.cpp b/tests/daemon/mgmt/rib-manager.t.cpp
similarity index 93%
rename from tests/daemon/rib/rib-manager.t.cpp
rename to tests/daemon/mgmt/rib-manager.t.cpp
index be59ca5..46da6a1 100644
--- a/tests/daemon/rib/rib-manager.t.cpp
+++ b/tests/daemon/mgmt/rib-manager.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018, Regents of the University of California,
+ * Copyright (c) 2014-2019, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -23,22 +23,19 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "rib/rib-manager.hpp"
+#include "mgmt/rib-manager.hpp"
#include "core/fib-max-depth.hpp"
+#include "rib/fib-updater.hpp"
#include "tests/manager-common-fixture.hpp"
#include <ndn-cxx/lp/tags.hpp>
-#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
#include <ndn-cxx/mgmt/nfd/face-status.hpp>
#include <ndn-cxx/mgmt/nfd/rib-entry.hpp>
namespace nfd {
-namespace rib {
namespace tests {
-using namespace nfd::tests;
-
struct ConfigurationStatus
{
bool isLocalhostConfigured;
@@ -65,7 +62,7 @@
, m_fibUpdater(m_rib, m_nfdController)
, m_manager(m_rib, m_face, m_keyChain, m_nfdController, m_dispatcher, m_scheduler)
{
- m_rib.mockFibResponse = [] (const RibUpdateBatch& batch) {
+ m_rib.mockFibResponse = [] (const rib::RibUpdateBatch& batch) {
BOOST_CHECK(batch.begin() != batch.end());
return true;
};
@@ -93,7 +90,7 @@
registerWithNfd()
{
m_manager.registerWithNfd();
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
auto replyFibAddCommand = [this] (const Interest& interest) {
nfd::ControlParameters params(interest.getName().get(-5).blockFromValue());
@@ -114,7 +111,7 @@
for (const auto& command : m_commands) {
if (commandPrefix.isPrefixOf(command.getName())) {
replyFibAddCommand(command);
- advanceClocks(time::milliseconds(1));
+ advanceClocks(1_ms);
}
}
@@ -210,8 +207,8 @@
ndn::util::Scheduler m_scheduler;
ndn::nfd::Controller m_nfdController;
- Rib m_rib;
- FibUpdater m_fibUpdater;
+ rib::Rib m_rib;
+ rib::FibUpdater m_fibUpdater;
RibManager m_manager;
};
@@ -240,6 +237,7 @@
return os << static_cast<int>(result);
}
+BOOST_AUTO_TEST_SUITE(Mgmt)
BOOST_AUTO_TEST_SUITE(TestRibManager)
class AddTopPrefixFixture : public RibManagerFixture
@@ -389,20 +387,20 @@
BOOST_AUTO_TEST_CASE(Expiration)
{
- auto paramsRegister = makeRegisterParameters("/test-expiry", 9527, time::milliseconds(50));
+ auto paramsRegister = makeRegisterParameters("/test-expiry", 9527, 50_ms);
auto paramsUnregister = makeRegisterParameters("/test-expiry", 9527);
receiveInterest(makeControlCommandRequest("/localhost/nfd/rib/register", paramsRegister));
- advanceClocks(time::milliseconds(55));
+ advanceClocks(55_ms);
BOOST_REQUIRE_EQUAL(m_commands.size(), 2); // the registered route has expired
BOOST_CHECK_EQUAL(checkCommand(0, "add-nexthop", paramsRegister), CheckCommandResult::OK);
BOOST_CHECK_EQUAL(checkCommand(1, "remove-nexthop", paramsUnregister), CheckCommandResult::OK);
m_commands.clear();
- paramsRegister.setExpirationPeriod(time::milliseconds(100));
+ paramsRegister.setExpirationPeriod(100_ms);
receiveInterest(makeControlCommandRequest("/localhost/nfd/rib/register", paramsRegister));
- advanceClocks(time::milliseconds(55));
+ advanceClocks(55_ms);
BOOST_REQUIRE_EQUAL(m_commands.size(), 1); // the registered route is still active
BOOST_CHECK_EQUAL(checkCommand(0, "add-nexthop", paramsRegister), CheckCommandResult::OK);
}
@@ -431,8 +429,8 @@
BOOST_FIXTURE_TEST_CASE(RibDataset, UnauthorizedRibManagerFixture)
{
uint64_t faceId = 0;
- auto generateRoute = [&faceId] () -> Route {
- Route route;
+ auto generateRoute = [&faceId] () -> rib::Route {
+ rib::Route route;
route.faceId = ++faceId;
route.cost = route.faceId * 10;
route.expires = nullopt;
@@ -491,7 +489,7 @@
{
BOOST_CHECK_EQUAL(m_commands.size(), 0);
- advanceClocks(time::seconds(301)); // RibManager::ACTIVE_FACE_FETCH_INTERVAL = 300s
+ advanceClocks(301_s); // RibManager::ACTIVE_FACE_FETCH_INTERVAL = 300s
BOOST_REQUIRE_EQUAL(m_commands.size(), 2);
BOOST_CHECK_EQUAL(m_commands[0].getName(), "/localhost/nfd/faces/events");
BOOST_CHECK_EQUAL(m_commands[1].getName(), "/localhost/nfd/faces/list");
@@ -512,7 +510,7 @@
activeFaces.push_back(status);
m_manager.removeInvalidFaces(activeFaces);
- advanceClocks(time::milliseconds(100));
+ advanceClocks(100_ms);
BOOST_REQUIRE_EQUAL(m_rib.size(), 1);
auto it1 = m_rib.find("/test-remove-invalid-faces-1");
@@ -531,24 +529,23 @@
receiveInterest(makeControlCommandRequest("/localhost/nfd/rib/register", parameters2));
BOOST_REQUIRE_EQUAL(m_rib.size(), 2);
- auto makeNotification = [] (ndn::nfd::FaceEventKind eventKind, uint64_t faceId) -> ndn::nfd::FaceEventNotification {
- ndn::nfd::FaceEventNotification notification;
- notification.setKind(eventKind).setFaceId(faceId);
- return notification;
+ auto makeNotification = [] (ndn::nfd::FaceEventKind kind, uint64_t faceId) {
+ return ndn::nfd::FaceEventNotification().setKind(kind).setFaceId(faceId);
};
m_manager.onNotification(makeNotification(ndn::nfd::FaceEventKind::FACE_EVENT_DESTROYED, 1));
- advanceClocks(time::milliseconds(100));
+ advanceClocks(100_ms);
BOOST_CHECK_EQUAL(m_rib.size(), 0);
m_manager.onNotification(makeNotification(ndn::nfd::FaceEventKind::FACE_EVENT_CREATED, 2));
- advanceClocks(time::milliseconds(100));
+ advanceClocks(100_ms);
BOOST_CHECK_EQUAL(m_rib.size(), 0);
}
BOOST_AUTO_TEST_SUITE_END() // FaceMonitor
+
BOOST_AUTO_TEST_SUITE_END() // TestRibManager
+BOOST_AUTO_TEST_SUITE_END() // Mgmt
} // namespace tests
-} // namespace rib
} // namespace nfd