management: Controller::CommandFailCallback exposes ControlResponse
refs #3739
Change-Id: Ib4b66cd99647ab930450fc3b472be565084be160
diff --git a/tests/unit-tests/management/nfd-controller-fixture.hpp b/tests/unit-tests/management/nfd-controller-fixture.hpp
index 492cbc2..d722dda 100644
--- a/tests/unit-tests/management/nfd-controller-fixture.hpp
+++ b/tests/unit-tests/management/nfd-controller-fixture.hpp
@@ -41,7 +41,8 @@
ControllerFixture()
: face(io, m_keyChain)
, controller(face, m_keyChain, m_validator)
- , failCallback(bind(&ControllerFixture::fail, this, _1, _2))
+ , commandFailCallback(bind(&ControllerFixture::recordCommandFail, this, _1))
+ , datasetFailCallback(bind(&ControllerFixture::recordDatasetFail, this, _1, _2))
{
Name identityName("/localhost/ControllerFixture");
if (this->addIdentity(identityName)) {
@@ -65,7 +66,13 @@
private:
void
- fail(uint32_t code, const std::string& reason)
+ recordCommandFail(const ControlResponse& response)
+ {
+ failCodes.push_back(response.getCode());
+ }
+
+ void
+ recordDatasetFail(uint32_t code, const std::string& reason)
{
failCodes.push_back(code);
}
@@ -73,7 +80,8 @@
protected:
ndn::util::DummyClientFace face;
Controller controller;
- Controller::CommandFailCallback failCallback;
+ Controller::CommandFailCallback commandFailCallback;
+ Controller::DatasetFailCallback datasetFailCallback;
std::vector<uint32_t> failCodes;
private:
diff --git a/tests/unit-tests/management/nfd-controller.t.cpp b/tests/unit-tests/management/nfd-controller.t.cpp
index 8a944f8..13031fb 100644
--- a/tests/unit-tests/management/nfd-controller.t.cpp
+++ b/tests/unit-tests/management/nfd-controller.t.cpp
@@ -66,7 +66,7 @@
parameters.setUri("tcp4://192.0.2.1:6363");
BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>(
- parameters, succeedCallback, failCallback));
+ parameters, succeedCallback, commandFailCallback));
this->advanceClocks(time::milliseconds(1));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -107,7 +107,7 @@
ControlParameters parameters;
parameters.setUri("tcp4://192.0.2.1:6363");
- controller.start<FaceCreateCommand>(parameters, nullptr, failCallback);
+ controller.start<FaceCreateCommand>(parameters, nullptr, commandFailCallback);
this->advanceClocks(time::milliseconds(1));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -139,7 +139,7 @@
options.setPrefix("/localhop/net/example/router1/nfd");
BOOST_CHECK_NO_THROW(controller.start<RibRegisterCommand>(
- parameters, succeedCallback, failCallback, options));
+ parameters, succeedCallback, commandFailCallback, options));
this->advanceClocks(time::milliseconds(1));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -157,7 +157,7 @@
// Uri is missing
BOOST_CHECK_THROW(controller.start<FaceCreateCommand>(
- parameters, succeedCallback, failCallback),
+ parameters, succeedCallback, commandFailCallback),
ControlCommand::ArgumentError);
}
@@ -169,7 +169,7 @@
parameters.setUri("tcp4://192.0.2.1:6363");
BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>(
- parameters, succeedCallback, failCallback));
+ parameters, succeedCallback, commandFailCallback));
this->advanceClocks(time::milliseconds(1));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -198,7 +198,7 @@
parameters.setUri("tcp4://192.0.2.1:6363");
BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>(
- parameters, succeedCallback, failCallback));
+ parameters, succeedCallback, commandFailCallback));
this->advanceClocks(time::milliseconds(1));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -222,7 +222,7 @@
parameters.setUri("tcp4://192.0.2.1:6363");
BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>(
- parameters, succeedCallback, failCallback));
+ parameters, succeedCallback, commandFailCallback));
this->advanceClocks(time::milliseconds(1));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -250,7 +250,7 @@
parameters.setUri("tcp4://192.0.2.1:6363");
BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>(
- parameters, succeedCallback, failCallback));
+ parameters, succeedCallback, commandFailCallback));
this->advanceClocks(time::milliseconds(1));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -273,7 +273,7 @@
options.setTimeout(time::milliseconds(50));
BOOST_CHECK_NO_THROW(controller.start<FaceCreateCommand>(
- parameters, succeedCallback, failCallback, options));
+ parameters, succeedCallback, commandFailCallback, options));
this->advanceClocks(time::milliseconds(1), 101); // Face's PIT granularity is 100ms
BOOST_REQUIRE_EQUAL(failCodes.size(), 1);
diff --git a/tests/unit-tests/management/nfd-status-dataset.t.cpp b/tests/unit-tests/management/nfd-status-dataset.t.cpp
index a836746..e2f62a3 100644
--- a/tests/unit-tests/management/nfd-status-dataset.t.cpp
+++ b/tests/unit-tests/management/nfd-status-dataset.t.cpp
@@ -112,7 +112,7 @@
options.setTimeout(time::milliseconds(3000));
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
- failCallback,
+ datasetFailCallback,
options);
this->advanceClocks(time::milliseconds(500), 7);
@@ -124,7 +124,7 @@
{
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
face.receive(*makeData("/localhost/nfd/faces/list/%FD%00"));
@@ -140,7 +140,7 @@
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
FaceStatus payload;
@@ -156,7 +156,7 @@
{
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -171,7 +171,7 @@
{
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
Name payload; // Name is not valid FaceStatus
@@ -186,7 +186,7 @@
{
controller.fetch<FaceDataset>(
[] (const std::vector<FaceStatus>& result) { BOOST_FAIL("fetchDataset should not succeed"); },
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
FaceStatus payload1;
@@ -207,7 +207,7 @@
{
controller.fetch<FaceDataset>(
nullptr,
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
FaceStatus payload;
@@ -241,7 +241,7 @@
hasResult = true;
BOOST_CHECK_EQUAL(result.getNfdVersion(), "0.4.2");
},
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
ForwarderStatus payload;
@@ -262,7 +262,7 @@
BOOST_CHECK_EQUAL(result.size(), 2);
BOOST_CHECK_EQUAL(result.front().getFaceId(), 24485);
},
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
FaceStatus payload1;
@@ -288,7 +288,7 @@
BOOST_CHECK_EQUAL(result.size(), 1);
BOOST_CHECK_EQUAL(result.front().getFaceId(), 8795);
},
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
Name prefix("/localhost/nfd/faces/query");
@@ -316,7 +316,7 @@
BOOST_CHECK_EQUAL(result.size(), 1);
BOOST_CHECK_EQUAL(result.front().getFaceId(), 14022);
},
- failCallback,
+ datasetFailCallback,
options);
this->advanceClocks(time::milliseconds(500));
@@ -340,7 +340,7 @@
BOOST_CHECK_EQUAL(result.size(), 2);
BOOST_CHECK_EQUAL(result.front().getLocalUri(), "tcp4://192.0.2.1:6363");
},
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
ChannelStatus payload1;
@@ -363,7 +363,7 @@
BOOST_CHECK_EQUAL(result.size(), 2);
BOOST_CHECK_EQUAL(result.front().getPrefix(), "/wYs7fzYcfG");
},
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
FibEntry payload1;
@@ -386,7 +386,7 @@
BOOST_CHECK_EQUAL(result.size(), 2);
BOOST_CHECK_EQUAL(result.front().getName(), "/8MLz6N3B");
},
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
StrategyChoice payload1;
@@ -409,7 +409,7 @@
BOOST_CHECK_EQUAL(result.size(), 2);
BOOST_CHECK_EQUAL(result.front().getName(), "/zXxBth97ee");
},
- failCallback);
+ datasetFailCallback);
this->advanceClocks(time::milliseconds(500));
RibEntry payload1;
@@ -434,7 +434,7 @@
BOOST_CHECK_EQUAL(result.size(), 1);
BOOST_CHECK_EQUAL(result.front().getName(), "/e6L5K4ascd");
},
- failCallback,
+ datasetFailCallback,
options);
this->advanceClocks(time::milliseconds(500));