mgmt: support LpReliability flag in faces/create and faces/update
refs #4003
Change-Id: Iddf94ea55c630b038187c2503783591b118230ec
diff --git a/tests/daemon/mgmt/face-manager-create-face.t.cpp b/tests/daemon/mgmt/face-manager-create-face.t.cpp
index 5a39ddb..19a10c7 100644
--- a/tests/daemon/mgmt/face-manager-create-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-create-face.t.cpp
@@ -159,6 +159,58 @@
}
};
+class TcpFaceLpReliabilityEnabled
+{
+public:
+ static ControlParameters
+ getParameters()
+ {
+ return ControlParameters()
+ .setUri("tcp4://127.0.0.1:26363")
+ .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true);
+ }
+};
+
+class TcpFaceLpReliabilityDisabled
+{
+public:
+ static ControlParameters
+ getParameters()
+ {
+ return ControlParameters()
+ .setUri("tcp4://127.0.0.1:26363")
+ .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, false);
+ }
+};
+
+class UdpFaceLpReliabilityEnabled
+{
+public:
+ static ControlParameters
+ getParameters()
+ {
+ return ControlParameters()
+ .setUri("tcp4://127.0.0.1:26363")
+ .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true);
+ }
+};
+
+class UdpFaceLpReliabilityDisabled
+{
+public:
+ static ControlParameters
+ getParameters()
+ {
+ return ControlParameters()
+ .setUri("tcp4://127.0.0.1:26363")
+ .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT)
+ .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, false);
+ }
+};
+
class FaceUriMalformed
{
public:
@@ -206,6 +258,10 @@
mpl::pair<LocalTcpFaceLocalFieldsDisabled, CommandSuccess>,
mpl::pair<NonLocalUdpFaceLocalFieldsEnabled, CommandFailure<406>>,
mpl::pair<NonLocalUdpFaceLocalFieldsDisabled, CommandSuccess>,
+ mpl::pair<TcpFaceLpReliabilityEnabled, CommandSuccess>,
+ mpl::pair<TcpFaceLpReliabilityDisabled, CommandSuccess>,
+ mpl::pair<UdpFaceLpReliabilityEnabled, CommandSuccess>,
+ mpl::pair<UdpFaceLpReliabilityDisabled, CommandSuccess>,
mpl::pair<FaceUriMalformed, CommandFailure<400>>,
mpl::pair<FaceUriNonCanonical, CommandFailure<400>>,
mpl::pair<FaceUriUnsupportedScheme, CommandFailure<406>>>;
@@ -239,10 +295,13 @@
if (expectedParams.hasFlags()) {
BOOST_CHECK_EQUAL(expectedParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED),
actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED));
+ BOOST_CHECK_EQUAL(expectedParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED),
+ actualParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED));
}
else {
// local fields are disabled by default
BOOST_CHECK_EQUAL(actualParams.getFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED), false);
+ BOOST_CHECK_EQUAL(actualParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED), false);
}
}
else {
diff --git a/tests/daemon/mgmt/face-manager-update-face.t.cpp b/tests/daemon/mgmt/face-manager-update-face.t.cpp
index e81e3be..1d647fc 100644
--- a/tests/daemon/mgmt/face-manager-update-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-update-face.t.cpp
@@ -1,5 +1,5 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
* Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
@@ -54,12 +54,14 @@
void
createFace(const std::string& uri = "tcp4://127.0.0.1:26363",
ndn::nfd::FacePersistency persistency = ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- bool enableLocalFields = false)
+ bool enableLocalFields = false,
+ bool enableReliability = false)
{
ControlParameters params;
params.setUri(uri);
params.setFacePersistency(persistency);
params.setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, enableLocalFields);
+ params.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, enableReliability);
createFace(params);
}
@@ -548,6 +550,57 @@
});
}
+BOOST_AUTO_TEST_CASE(UpdateReliabilityEnableDisable)
+{
+ createFace("udp4://127.0.0.1:26363");
+
+ ControlParameters enableParams;
+ enableParams.setFaceId(faceId);
+ enableParams.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true);
+
+ ControlParameters disableParams;
+ disableParams.setFaceId(faceId);
+ disableParams.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, false);
+
+ updateFace(enableParams, false, [] (const ControlResponse& actual) {
+ ControlResponse expected(200, "OK");
+ BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode());
+ BOOST_TEST_MESSAGE(actual.getText());
+
+ if (actual.getBody().hasWire()) {
+ ControlParameters actualParams(actual.getBody());
+
+ BOOST_CHECK(actualParams.hasFaceId());
+ BOOST_CHECK(actualParams.hasFacePersistency());
+ BOOST_REQUIRE(actualParams.hasFlags());
+ // Check if flags indicate reliability enabled
+ BOOST_CHECK(actualParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED));
+ }
+ else {
+ BOOST_ERROR("Enable: Response does not contain ControlParameters");
+ }
+ });
+
+ updateFace(disableParams, false, [] (const ControlResponse& actual) {
+ ControlResponse expected(200, "OK");
+ BOOST_CHECK_EQUAL(actual.getCode(), expected.getCode());
+ BOOST_TEST_MESSAGE(actual.getText());
+
+ if (actual.getBody().hasWire()) {
+ ControlParameters actualParams(actual.getBody());
+
+ BOOST_CHECK(actualParams.hasFaceId());
+ BOOST_CHECK(actualParams.hasFacePersistency());
+ BOOST_REQUIRE(actualParams.hasFlags());
+ // Check if flags indicate reliability disabled
+ BOOST_CHECK(!actualParams.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED));
+ }
+ else {
+ BOOST_ERROR("Disable: Response does not contain ControlParameters");
+ }
+ });
+}
+
BOOST_AUTO_TEST_CASE(SelfUpdating)
{
createFace();