| /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| /* |
| * Copyright (c) 2014-2022, Regents of the University of California, |
| * Arizona Board of Regents, |
| * Colorado State University, |
| * University Pierre & Marie Curie, Sorbonne University, |
| * Washington University in St. Louis, |
| * Beijing Institute of Technology, |
| * The University of Memphis. |
| * |
| * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| * See AUTHORS.md for complete list of NFD authors and contributors. |
| * |
| * NFD is free software: you can redistribute it and/or modify it under the terms |
| * of the GNU General Public License as published by the Free Software Foundation, |
| * either version 3 of the License, or (at your option) any later version. |
| * |
| * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| * PURPOSE. See the GNU General Public License for more details. |
| * |
| * You should have received a copy of the GNU General Public License along with |
| * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| */ |
| |
| #include "nfdc/face-module.hpp" |
| |
| #include "execute-command-fixture.hpp" |
| #include "status-fixture.hpp" |
| |
| namespace nfd::tools::nfdc::tests { |
| |
| using ndn::nfd::FaceQueryFilter; |
| |
| BOOST_AUTO_TEST_SUITE(Nfdc) |
| BOOST_AUTO_TEST_SUITE(TestFaceModule) |
| |
| BOOST_FIXTURE_TEST_SUITE(ListCommand, ExecuteCommandFixture) |
| |
| const std::string NONQUERY_OUTPUT = |
| "faceid=134 remote=udp4://233.252.0.4:6363 local=udp4://192.0.2.1:6363" |
| " congestion={base-marking-interval=12345ms default-threshold=54321B} mtu=1024" |
| " counters={in={22562i 22031d 63n 2522915B} out={30121i 20940d 1218n 1353592B}}" |
| " flags={non-local permanent multi-access}\n" |
| "faceid=745 remote=fd://75 local=unix:///var/run/nfd.sock" |
| " congestion={base-marking-interval=100ms default-threshold=65536B} mtu=8800" |
| " counters={in={18998i 26701d 147n 4672308B} out={34779i 17028d 1176n 8957187B}}" |
| " flags={local on-demand point-to-point local-fields lp-reliability congestion-marking}\n"; |
| |
| BOOST_AUTO_TEST_CASE(NormalNonQuery) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| FaceStatus payload1; |
| payload1.setFaceId(134) |
| .setRemoteUri("udp4://233.252.0.4:6363") |
| .setLocalUri("udp4://192.0.2.1:6363") |
| .setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL) |
| .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERMANENT) |
| .setLinkType(ndn::nfd::LINK_TYPE_MULTI_ACCESS) |
| .setBaseCongestionMarkingInterval(12345_ms) |
| .setDefaultCongestionThreshold(54321) |
| .setMtu(1024) |
| .setNInInterests(22562) |
| .setNInData(22031) |
| .setNInNacks(63) |
| .setNOutInterests(30121) |
| .setNOutData(20940) |
| .setNOutNacks(1218) |
| .setNInBytes(2522915) |
| .setNOutBytes(1353592); |
| FaceStatus payload2; |
| payload2.setFaceId(745) |
| .setRemoteUri("fd://75") |
| .setLocalUri("unix:///var/run/nfd.sock") |
| .setFaceScope(ndn::nfd::FACE_SCOPE_LOCAL) |
| .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) |
| .setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT) |
| .setBaseCongestionMarkingInterval(100_ms) |
| .setDefaultCongestionThreshold(65536) |
| .setMtu(8800) |
| .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, true) |
| .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true) |
| .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, true) |
| .setNInInterests(18998) |
| .setNInData(26701) |
| .setNInNacks(147) |
| .setNOutInterests(34779) |
| .setNOutData(17028) |
| .setNOutNacks(1176) |
| .setNInBytes(4672308) |
| .setNOutBytes(8957187); |
| this->sendDataset("/localhost/nfd/faces/list", payload1, payload2); |
| }; |
| |
| this->execute("face list"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal(NONQUERY_OUTPUT)); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| const std::string QUERY_OUTPUT = |
| "faceid=177 remote=tcp4://53.239.9.114:6363 local=tcp4://164.0.31.106:20396" |
| " congestion={base-marking-interval=555ms default-threshold=10000B} mtu=2000" |
| " counters={in={2325i 1110d 79n 4716834B} out={2278i 485d 841n 308108B}}" |
| " flags={non-local persistent point-to-point}\n"; |
| |
| BOOST_AUTO_TEST_CASE(NormalQuery) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| BOOST_CHECK(Name("/localhost/nfd/faces/query").isPrefixOf(interest.getName())); |
| BOOST_CHECK_EQUAL(interest.getName().size(), 5); |
| FaceQueryFilter filter(interest.getName().at(4).blockFromValue()); |
| FaceQueryFilter expectedFilter; |
| expectedFilter.setRemoteUri("tcp4://53.239.9.114:6363") |
| .setLocalUri("tcp4://164.0.31.106:20396") |
| .setUriScheme("tcp4"); |
| BOOST_CHECK_EQUAL(filter, expectedFilter); |
| |
| FaceStatus payload; |
| payload.setFaceId(177) |
| .setRemoteUri("tcp4://53.239.9.114:6363") |
| .setLocalUri("tcp4://164.0.31.106:20396") |
| .setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL) |
| .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERSISTENT) |
| .setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT) |
| .setBaseCongestionMarkingInterval(555_ms) |
| .setDefaultCongestionThreshold(10000) |
| .setMtu(2000) |
| .setNInInterests(2325) |
| .setNInData(1110) |
| .setNInNacks(79) |
| .setNOutInterests(2278) |
| .setNOutData(485) |
| .setNOutNacks(841) |
| .setNInBytes(4716834) |
| .setNOutBytes(308108); |
| this->sendDataset(interest.getName(), payload); |
| }; |
| |
| this->execute("face list tcp://53.239.9.114 scheme tcp4 local tcp://164.0.31.106:20396"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal(QUERY_OUTPUT)); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(NotFound) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| this->sendEmptyDataset(interest.getName()); |
| }; |
| |
| this->execute("face list scheme udp6"); |
| BOOST_CHECK_EQUAL(exitCode, 3); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Face not found\n")); |
| } |
| |
| BOOST_AUTO_TEST_CASE(Error) |
| { |
| this->processInterest = nullptr; // no response |
| |
| this->execute("face list local udp4://31.67.17.2:6363"); |
| BOOST_CHECK_EQUAL(exitCode, 1); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Error 10060 when querying face: Timeout exceeded\n")); |
| } |
| |
| BOOST_AUTO_TEST_SUITE_END() // ListCommand |
| |
| BOOST_FIXTURE_TEST_SUITE(ShowCommand, ExecuteCommandFixture) |
| |
| const std::string NORMAL_ALL_CONGESTION_OUTPUT = std::string(R"TEXT( |
| faceid=256 |
| remote=udp4://84.67.35.111:6363 |
| local=udp4://79.91.49.215:6363 |
| congestion={base-marking-interval=123ms default-threshold=10000B} |
| mtu=4000 |
| counters={in={28975i 28232d 212n 13307258B} out={19525i 30993d 1038n 6231946B}} |
| flags={non-local on-demand point-to-point} |
| )TEXT").substr(1); |
| |
| BOOST_AUTO_TEST_CASE(NormalAllCongestionParams) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| BOOST_CHECK(Name("/localhost/nfd/faces/query").isPrefixOf(interest.getName())); |
| BOOST_CHECK_EQUAL(interest.getName().size(), 5); |
| FaceQueryFilter filter(interest.getName().at(4).blockFromValue()); |
| BOOST_CHECK_EQUAL(filter, FaceQueryFilter().setFaceId(256)); |
| |
| FaceStatus payload; |
| payload.setFaceId(256) |
| .setRemoteUri("udp4://84.67.35.111:6363") |
| .setLocalUri("udp4://79.91.49.215:6363") |
| .setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL) |
| .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) |
| .setMtu(4000) |
| .setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT) |
| .setBaseCongestionMarkingInterval(123_ms) |
| .setDefaultCongestionThreshold(10000) |
| .setNInInterests(28975) |
| .setNInData(28232) |
| .setNInNacks(212) |
| .setNOutInterests(19525) |
| .setNOutData(30993) |
| .setNOutNacks(1038) |
| .setNInBytes(13307258) |
| .setNOutBytes(6231946); |
| |
| this->sendDataset(interest.getName(), payload); |
| }; |
| |
| this->execute("face show 256"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal(NORMAL_ALL_CONGESTION_OUTPUT)); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| const std::string NORMAL_INTERVAL_CONGESTION_OUTPUT = std::string(R"TEXT( |
| faceid=256 |
| remote=udp4://84.67.35.111:6363 |
| local=udp4://79.91.49.215:6363 |
| congestion={base-marking-interval=123ms} |
| mtu=3000 |
| counters={in={28975i 28232d 212n 13307258B} out={19525i 30993d 1038n 6231946B}} |
| flags={non-local on-demand point-to-point} |
| )TEXT").substr(1); |
| |
| BOOST_AUTO_TEST_CASE(NormalIntervalCongestionParams) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| BOOST_CHECK(Name("/localhost/nfd/faces/query").isPrefixOf(interest.getName())); |
| BOOST_CHECK_EQUAL(interest.getName().size(), 5); |
| FaceQueryFilter filter(interest.getName().at(4).blockFromValue()); |
| BOOST_CHECK_EQUAL(filter, FaceQueryFilter().setFaceId(256)); |
| |
| FaceStatus payload; |
| payload.setFaceId(256) |
| .setRemoteUri("udp4://84.67.35.111:6363") |
| .setLocalUri("udp4://79.91.49.215:6363") |
| .setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL) |
| .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) |
| .setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT) |
| .setBaseCongestionMarkingInterval(123_ms) |
| .setMtu(3000) |
| .setNInInterests(28975) |
| .setNInData(28232) |
| .setNInNacks(212) |
| .setNOutInterests(19525) |
| .setNOutData(30993) |
| .setNOutNacks(1038) |
| .setNInBytes(13307258) |
| .setNOutBytes(6231946); |
| |
| this->sendDataset(interest.getName(), payload); |
| }; |
| |
| this->execute("face show 256"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal(NORMAL_INTERVAL_CONGESTION_OUTPUT)); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| const std::string NORMAL_THRESHOLD_CONGESTION_OUTPUT = std::string(R"TEXT( |
| faceid=256 |
| remote=udp4://84.67.35.111:6363 |
| local=udp4://79.91.49.215:6363 |
| congestion={default-threshold=10000B} |
| mtu=5000 |
| counters={in={28975i 28232d 212n 13307258B} out={19525i 30993d 1038n 6231946B}} |
| flags={non-local on-demand point-to-point} |
| )TEXT").substr(1); |
| |
| BOOST_AUTO_TEST_CASE(NormalThresholdCongestionParams) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| BOOST_CHECK(Name("/localhost/nfd/faces/query").isPrefixOf(interest.getName())); |
| BOOST_CHECK_EQUAL(interest.getName().size(), 5); |
| FaceQueryFilter filter(interest.getName().at(4).blockFromValue()); |
| BOOST_CHECK_EQUAL(filter, FaceQueryFilter().setFaceId(256)); |
| |
| FaceStatus payload; |
| payload.setFaceId(256) |
| .setRemoteUri("udp4://84.67.35.111:6363") |
| .setLocalUri("udp4://79.91.49.215:6363") |
| .setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL) |
| .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) |
| .setMtu(5000) |
| .setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT) |
| .setDefaultCongestionThreshold(10000) |
| .setNInInterests(28975) |
| .setNInData(28232) |
| .setNInNacks(212) |
| .setNOutInterests(19525) |
| .setNOutData(30993) |
| .setNOutNacks(1038) |
| .setNInBytes(13307258) |
| .setNOutBytes(6231946); |
| |
| this->sendDataset(interest.getName(), payload); |
| }; |
| |
| this->execute("face show 256"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal(NORMAL_THRESHOLD_CONGESTION_OUTPUT)); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| const std::string NORMAL_NO_CONGESTION_OUTPUT = std::string(R"TEXT( |
| faceid=256 |
| remote=udp4://84.67.35.111:6363 |
| local=udp4://79.91.49.215:6363 |
| mtu=6000 |
| counters={in={28975i 28232d 212n 13307258B} out={19525i 30993d 1038n 6231946B}} |
| flags={non-local on-demand point-to-point} |
| )TEXT").substr(1); |
| |
| BOOST_AUTO_TEST_CASE(NormalNoCongestionParams) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| BOOST_CHECK(Name("/localhost/nfd/faces/query").isPrefixOf(interest.getName())); |
| BOOST_CHECK_EQUAL(interest.getName().size(), 5); |
| FaceQueryFilter filter(interest.getName().at(4).blockFromValue()); |
| BOOST_CHECK_EQUAL(filter, FaceQueryFilter().setFaceId(256)); |
| |
| FaceStatus payload; |
| payload.setFaceId(256) |
| .setRemoteUri("udp4://84.67.35.111:6363") |
| .setLocalUri("udp4://79.91.49.215:6363") |
| .setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL) |
| .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) |
| .setMtu(6000) |
| .setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT) |
| .setNInInterests(28975) |
| .setNInData(28232) |
| .setNInNacks(212) |
| .setNOutInterests(19525) |
| .setNOutData(30993) |
| .setNOutNacks(1038) |
| .setNInBytes(13307258) |
| .setNOutBytes(6231946); |
| |
| this->sendDataset(interest.getName(), payload); |
| }; |
| |
| this->execute("face show 256"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal(NORMAL_NO_CONGESTION_OUTPUT)); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(NotFound) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| this->sendEmptyDataset(interest.getName()); |
| }; |
| |
| this->execute("face show 256"); |
| BOOST_CHECK_EQUAL(exitCode, 3); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Face not found\n")); |
| } |
| |
| BOOST_AUTO_TEST_CASE(Error) |
| { |
| this->processInterest = nullptr; // no response |
| |
| this->execute("face show 256"); |
| BOOST_CHECK_EQUAL(exitCode, 1); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Error 10060 when querying face: Timeout exceeded\n")); |
| } |
| |
| BOOST_AUTO_TEST_SUITE_END() // ShowCommand |
| |
| class ExecuteFaceCreateCommandFixture : public ExecuteCommandFixture |
| { |
| protected: |
| void |
| respond409(const Interest& interest, FacePersistency persistency, |
| std::optional<uint64_t> mtu = std::nullopt, |
| bool enableLpReliability = false, |
| bool enableCongestionMarking = false) |
| { |
| MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/create"); |
| ControlParameters body; |
| body.setFaceId(1172) |
| .setUri("udp4://100.77.30.65:6363") |
| .setLocalUri("udp4://68.62.26.57:24087") |
| .setFacePersistency(persistency) |
| .setFlags(0); |
| if (mtu) { |
| body.setMtu(*mtu); |
| } |
| if (enableLpReliability) { |
| body.setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true, false); |
| } |
| if (enableCongestionMarking) { |
| body.setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, true, false); |
| } |
| this->failCommand(interest, 409, "conflict-409", body); |
| } |
| }; |
| |
| BOOST_FIXTURE_TEST_SUITE(CreateCommand, ExecuteFaceCreateCommandFixture) |
| |
| BOOST_AUTO_TEST_CASE(Creating) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/create"); |
| BOOST_REQUIRE(req.hasUri()); |
| BOOST_CHECK_EQUAL(req.getUri(), "udp4://159.242.33.78:6363"); |
| BOOST_CHECK(!req.hasLocalUri()); |
| BOOST_REQUIRE(req.hasFacePersistency()); |
| BOOST_CHECK_EQUAL(req.getFacePersistency(), FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| |
| ControlParameters resp; |
| resp.setFaceId(2130) |
| .setUri("udp4://159.242.33.78:6363") |
| .setLocalUri("udp4://179.63.153.45:28835") |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setFlags(0); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://159.242.33.78"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-created id=2130 local=udp4://179.63.153.45:28835 " |
| "remote=udp4://159.242.33.78:6363 persistency=persistent " |
| "reliability=off congestion-marking=off\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(CreatingWithParams) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/create"); |
| BOOST_REQUIRE(req.hasUri()); |
| BOOST_CHECK_EQUAL(req.getUri(), "udp4://22.91.89.51:19903"); |
| BOOST_REQUIRE(req.hasLocalUri()); |
| BOOST_CHECK_EQUAL(req.getLocalUri(), "udp4://98.68.23.71:6363"); |
| BOOST_REQUIRE(req.hasFacePersistency()); |
| BOOST_CHECK_EQUAL(req.getFacePersistency(), FacePersistency::FACE_PERSISTENCY_PERMANENT); |
| BOOST_REQUIRE(req.hasBaseCongestionMarkingInterval()); |
| BOOST_CHECK_EQUAL(req.getBaseCongestionMarkingInterval(), 100_ms); |
| BOOST_REQUIRE(req.hasDefaultCongestionThreshold()); |
| BOOST_CHECK_EQUAL(req.getDefaultCongestionThreshold(), 65536); |
| BOOST_REQUIRE(req.hasMtu()); |
| BOOST_CHECK_EQUAL(req.getMtu(), 10000); |
| BOOST_CHECK(req.hasFlags()); |
| BOOST_CHECK(req.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)); |
| |
| ControlParameters resp; |
| resp.setFaceId(301) |
| .setUri("udp4://22.91.89.51:19903") |
| .setLocalUri("udp4://98.68.23.71:6363") |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERMANENT) |
| .setBaseCongestionMarkingInterval(100_ms) |
| .setDefaultCongestionThreshold(65536) |
| .setMtu(8800) |
| .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true, false) |
| .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, true, false); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://22.91.89.51:19903 permanent local udp://98.68.23.71 reliability on " |
| "congestion-marking on congestion-marking-interval 100 " |
| "default-congestion-threshold 65536 mtu 10000"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-created id=301 local=udp4://98.68.23.71:6363 " |
| "remote=udp4://22.91.89.51:19903 persistency=permanent " |
| "reliability=on congestion-marking=on " |
| "congestion-marking-interval=100ms default-congestion-threshold=65536B " |
| "mtu=8800\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(ChangingMtu) |
| { |
| bool hasUpdateCommand = false; |
| this->processInterest = [this, &hasUpdateCommand] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_PERSISTENT, 5000); |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| hasUpdateCommand = true; |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 1172); |
| BOOST_CHECK(!req.hasFacePersistency()); |
| BOOST_REQUIRE(req.hasMtu()); |
| BOOST_CHECK_EQUAL(req.getMtu(), 4000); |
| BOOST_CHECK(!req.hasFlags()); |
| |
| ControlParameters resp; |
| resp.setFaceId(1172) |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setMtu(4000) |
| .setFlags(0); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://100.77.30.65 mtu 4000"); |
| BOOST_CHECK(hasUpdateCommand); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-updated id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=off congestion-marking=off mtu=4000\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(AutoMtu) |
| { |
| bool hasUpdateCommand = false; |
| this->processInterest = [this, &hasUpdateCommand] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_PERSISTENT, 5000); |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| hasUpdateCommand = true; |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 1172); |
| BOOST_CHECK(!req.hasFacePersistency()); |
| BOOST_REQUIRE(req.hasMtu()); |
| BOOST_CHECK_EQUAL(req.getMtu(), std::numeric_limits<uint64_t>::max()); |
| BOOST_CHECK(!req.hasFlags()); |
| |
| ControlParameters resp; |
| resp.setFaceId(1172) |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setMtu(ndn::MAX_NDN_PACKET_SIZE) |
| .setFlags(0); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://100.77.30.65 mtu auto"); |
| BOOST_CHECK(hasUpdateCommand); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-updated id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=off congestion-marking=off mtu=8800\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(UpgradingPersistency) |
| { |
| bool hasUpdateCommand = false; |
| this->processInterest = [this, &hasUpdateCommand] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_ON_DEMAND); |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| hasUpdateCommand = true; |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 1172); |
| BOOST_REQUIRE(req.hasFacePersistency()); |
| BOOST_CHECK_EQUAL(req.getFacePersistency(), FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| BOOST_CHECK(!req.hasFlags()); |
| |
| ControlParameters resp; |
| resp.setFaceId(1172) |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setMtu(1024) |
| .setFlags(0); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://100.77.30.65"); |
| BOOST_CHECK(hasUpdateCommand); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-updated id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=off congestion-marking=off mtu=1024\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(UpgradingPersistencySameMtu) |
| { |
| bool hasUpdateCommand = false; |
| this->processInterest = [this, &hasUpdateCommand] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_ON_DEMAND, 8800); |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| hasUpdateCommand = true; |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 1172); |
| BOOST_REQUIRE(req.hasFacePersistency()); |
| BOOST_CHECK_EQUAL(req.getFacePersistency(), FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| BOOST_CHECK(!req.hasMtu()); |
| BOOST_CHECK(!req.hasFlags()); |
| |
| ControlParameters resp; |
| resp.setFaceId(1172) |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setMtu(8800) |
| .setFlags(0); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://100.77.30.65 mtu 8800"); |
| BOOST_CHECK(hasUpdateCommand); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-updated id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=off congestion-marking=off mtu=8800\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(NotDowngradingPersistency) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_PERMANENT); |
| // no command other than faces/create is expected |
| }; |
| |
| this->execute("face create udp://100.77.30.65"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-exists id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=permanent " |
| "reliability=off congestion-marking=off\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(SamePersistency) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| // no command other than faces/create is expected |
| }; |
| |
| this->execute("face create udp://100.77.30.65"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-exists id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=off congestion-marking=off\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(EnablingReliability) |
| { |
| bool hasUpdateCommand = false; |
| this->processInterest = [this, &hasUpdateCommand] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| hasUpdateCommand = true; |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 1172); |
| BOOST_CHECK(req.hasFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)); |
| BOOST_CHECK(req.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)); |
| |
| ControlParameters resp; |
| resp.setFaceId(1172) |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setMtu(4000) |
| .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true, false); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://100.77.30.65 reliability on"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-updated id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=on congestion-marking=off mtu=4000\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(DisablingReliability) |
| { |
| bool hasUpdateCommand = false; |
| this->processInterest = [this, &hasUpdateCommand] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_PERSISTENT, {}, true); |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| hasUpdateCommand = true; |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 1172); |
| BOOST_CHECK(req.hasFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)); |
| BOOST_CHECK(!req.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)); |
| |
| ControlParameters resp; |
| resp.setFaceId(1172) |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setMtu(4000) |
| .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, false, false); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://100.77.30.65 reliability off"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-updated id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=off congestion-marking=off mtu=4000\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(EnablingCongestionMarking) |
| { |
| bool hasUpdateCommand = false; |
| this->processInterest = [this, &hasUpdateCommand] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| hasUpdateCommand = true; |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 1172); |
| BOOST_CHECK(req.hasFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)); |
| BOOST_CHECK(req.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)); |
| BOOST_CHECK(!req.hasBaseCongestionMarkingInterval()); |
| BOOST_CHECK(!req.hasDefaultCongestionThreshold()); |
| |
| ControlParameters resp; |
| resp.setFaceId(1172) |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setBaseCongestionMarkingInterval(100_ms) |
| .setDefaultCongestionThreshold(65536) |
| .setMtu(4000) |
| .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, true, false); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://100.77.30.65 congestion-marking on"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-updated id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=off congestion-marking=on " |
| "congestion-marking-interval=100ms default-congestion-threshold=65536B " |
| "mtu=4000\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(DisablingCongestionMarking) |
| { |
| bool hasUpdateCommand = false; |
| this->processInterest = [this, &hasUpdateCommand] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_PERSISTENT, {}, false, true); |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| hasUpdateCommand = true; |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 1172); |
| BOOST_CHECK(req.hasFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)); |
| BOOST_CHECK(!req.getFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED)); |
| BOOST_CHECK(!req.hasBaseCongestionMarkingInterval()); |
| BOOST_CHECK(!req.hasDefaultCongestionThreshold()); |
| |
| ControlParameters resp; |
| resp.setFaceId(1172) |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setBaseCongestionMarkingInterval(100_ms) |
| .setDefaultCongestionThreshold(65536) |
| .setMtu(4000) |
| .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, false, false); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://100.77.30.65 congestion-marking off"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-updated id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=off congestion-marking=off " |
| "congestion-marking-interval=100ms default-congestion-threshold=65536B " |
| "mtu=4000\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(UpgradingPersistencyChangeMtu) |
| { |
| bool hasUpdateCommand = false; |
| this->processInterest = [this, &hasUpdateCommand] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_ON_DEMAND, 8800); |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| hasUpdateCommand = true; |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 1172); |
| BOOST_REQUIRE(req.hasFacePersistency()); |
| BOOST_CHECK_EQUAL(req.getFacePersistency(), FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| BOOST_REQUIRE(req.hasMtu()); |
| BOOST_CHECK_EQUAL(req.getMtu(), 4000); |
| BOOST_CHECK(!req.hasFlags()); |
| |
| ControlParameters resp; |
| resp.setFaceId(1172) |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setMtu(4000) |
| .setFlags(0); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://100.77.30.65 mtu 4000"); |
| BOOST_CHECK(hasUpdateCommand); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-updated id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=off congestion-marking=off mtu=4000\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(UpgradingPersistencyChangeMtuAndFlags) |
| { |
| bool hasUpdateCommand = false; |
| this->processInterest = [this, &hasUpdateCommand] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_ON_DEMAND, 8800); |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| hasUpdateCommand = true; |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 1172); |
| BOOST_REQUIRE(req.hasFacePersistency()); |
| BOOST_CHECK_EQUAL(req.getFacePersistency(), FacePersistency::FACE_PERSISTENCY_PERSISTENT); |
| BOOST_REQUIRE(req.hasMtu()); |
| BOOST_CHECK_EQUAL(req.getMtu(), 4000); |
| BOOST_CHECK(req.hasFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)); |
| BOOST_CHECK(req.getFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED)); |
| |
| ControlParameters resp; |
| resp.setFaceId(1172) |
| .setFacePersistency(FacePersistency::FACE_PERSISTENCY_PERSISTENT) |
| .setMtu(4000) |
| .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true, false); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face create udp://100.77.30.65 mtu 4000 reliability on"); |
| BOOST_CHECK(hasUpdateCommand); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-updated id=1172 local=udp4://68.62.26.57:24087 " |
| "remote=udp4://100.77.30.65:6363 persistency=persistent " |
| "reliability=on congestion-marking=off mtu=4000\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(ErrorCanonizeRemote) |
| { |
| this->execute("face create invalid://"); |
| BOOST_CHECK_EQUAL(exitCode, 4); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Error during canonization of remote FaceUri 'invalid://': " |
| "scheme not supported\n")); |
| } |
| |
| BOOST_AUTO_TEST_CASE(ErrorCanonizeLocal) |
| { |
| this->execute("face create udp4://24.37.20.47:6363 local invalid://"); |
| BOOST_CHECK_EQUAL(exitCode, 4); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Error during canonization of local FaceUri 'invalid://': " |
| "scheme not supported\n")); |
| } |
| |
| BOOST_AUTO_TEST_CASE(ErrorCreate) |
| { |
| this->processInterest = nullptr; // no response |
| |
| this->execute("face create udp://159.242.33.78"); |
| BOOST_CHECK_EQUAL(exitCode, 1); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Error 10060 when creating face: request timed out\n")); |
| } |
| |
| BOOST_AUTO_TEST_CASE(ErrorConflict) |
| { |
| // Current NFD will not report a 409-conflict with a different remote FaceUri, but this is |
| // allowed by FaceMgmt protocol and nfdc should not attempt to upgrade persistency in this case. |
| |
| this->processInterest = [this] (const Interest& interest) { |
| // conflict with udp4://100.77.30.65:6363 |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_ON_DEMAND); |
| }; |
| |
| this->execute("face create udp://20.53.73.45"); |
| BOOST_CHECK_EQUAL(exitCode, 1); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Error 409 when creating face: conflict-409\n")); |
| } |
| |
| BOOST_AUTO_TEST_CASE(ErrorUpdate) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| if (parseCommand(interest, "/localhost/nfd/faces/create")) { |
| this->respond409(interest, FacePersistency::FACE_PERSISTENCY_ON_DEMAND); |
| return; |
| } |
| |
| MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/update"); |
| // no response to faces/update |
| }; |
| |
| this->execute("face create udp://100.77.30.65"); |
| BOOST_CHECK_EQUAL(exitCode, 1); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Error 10060 when updating face: request timed out\n")); |
| } |
| |
| BOOST_AUTO_TEST_SUITE_END() // CreateCommand |
| |
| BOOST_FIXTURE_TEST_SUITE(DestroyCommand, ExecuteCommandFixture) |
| |
| BOOST_AUTO_TEST_CASE(NormalByFaceId) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| if (this->respondFaceQuery(interest)) { |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/destroy"); |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 10156); |
| |
| ControlParameters resp; |
| resp.setFaceId(10156); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face destroy 10156"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-destroyed id=10156 local=tcp4://151.26.163.27:22967 " |
| "remote=tcp4://198.57.27.40:6363 persistency=persistent " |
| "reliability=off congestion-marking=off\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(NormalByFaceUri) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| if (this->respondFaceQuery(interest)) { |
| return; |
| } |
| |
| ControlParameters req = MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/destroy"); |
| BOOST_REQUIRE(req.hasFaceId()); |
| BOOST_CHECK_EQUAL(req.getFaceId(), 2249); |
| |
| ControlParameters resp; |
| resp.setFaceId(2249); |
| this->succeedCommand(interest, resp); |
| }; |
| |
| this->execute("face destroy tcp://32.121.182.82"); |
| BOOST_CHECK_EQUAL(exitCode, 0); |
| BOOST_CHECK(out.is_equal("face-destroyed id=2249 local=tcp4://30.99.87.98:31414 " |
| "remote=tcp4://32.121.182.82:6363 persistency=persistent " |
| "reliability=off congestion-marking=off\n")); |
| BOOST_CHECK(err.is_empty()); |
| } |
| |
| BOOST_AUTO_TEST_CASE(FaceNotExist) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| BOOST_CHECK(this->respondFaceQuery(interest)); |
| }; |
| |
| this->execute("face destroy 23728"); |
| BOOST_CHECK_EQUAL(exitCode, 3); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Face not found\n")); |
| } |
| |
| BOOST_AUTO_TEST_CASE(Ambiguous) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| BOOST_CHECK(this->respondFaceQuery(interest)); |
| }; |
| |
| this->execute("face destroy udp4://225.131.75.231:56363"); |
| BOOST_CHECK_EQUAL(exitCode, 5); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Multiple faces match specified remote FaceUri. " |
| "Re-run the command with a FaceId: " |
| "6720 (local=udp4://202.83.168.28:56363), " |
| "31066 (local=udp4://25.90.26.32:56363)\n")); |
| } |
| |
| BOOST_AUTO_TEST_CASE(ErrorCanonization) |
| { |
| this->execute("face destroy udp6://32.38.164.64:10445"); |
| BOOST_CHECK_EQUAL(exitCode, 4); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Error during canonization of 'udp6://32.38.164.64:10445': " |
| "IPv4/v6 mismatch\n")); |
| } |
| |
| BOOST_AUTO_TEST_CASE(ErrorDataset) |
| { |
| this->processInterest = nullptr; // no response to dataset or command |
| |
| this->execute("face destroy udp://159.242.33.78"); |
| BOOST_CHECK_EQUAL(exitCode, 1); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Error 10060 when querying face: Timeout exceeded\n")); |
| } |
| |
| BOOST_AUTO_TEST_CASE(ErrorCommand) |
| { |
| this->processInterest = [this] (const Interest& interest) { |
| if (this->respondFaceQuery(interest)) { |
| return; |
| } |
| |
| MOCK_NFD_MGMT_REQUIRE_COMMAND_IS("/localhost/nfd/faces/destroy"); |
| // no response to command |
| }; |
| |
| this->execute("face destroy 10156"); |
| BOOST_CHECK_EQUAL(exitCode, 1); |
| BOOST_CHECK(out.is_empty()); |
| BOOST_CHECK(err.is_equal("Error 10060 when destroying face: request timed out\n")); |
| } |
| |
| BOOST_AUTO_TEST_SUITE_END() // DestroyCommand |
| |
| const std::string STATUS_XML = stripXmlSpaces(R"XML( |
| <faces> |
| <face> |
| <faceId>134</faceId> |
| <remoteUri>udp4://233.252.0.4:6363</remoteUri> |
| <localUri>udp4://192.0.2.1:6363</localUri> |
| <faceScope>non-local</faceScope> |
| <facePersistency>permanent</facePersistency> |
| <linkType>multi-access</linkType> |
| <congestion/> |
| <flags/> |
| <packetCounters> |
| <incomingPackets> |
| <nInterests>22562</nInterests> |
| <nData>22031</nData> |
| <nNacks>63</nNacks> |
| </incomingPackets> |
| <outgoingPackets> |
| <nInterests>30121</nInterests> |
| <nData>20940</nData> |
| <nNacks>1218</nNacks> |
| </outgoingPackets> |
| </packetCounters> |
| <byteCounters> |
| <incomingBytes>2522915</incomingBytes> |
| <outgoingBytes>1353592</outgoingBytes> |
| </byteCounters> |
| </face> |
| <face> |
| <faceId>745</faceId> |
| <remoteUri>fd://75</remoteUri> |
| <localUri>unix:///var/run/nfd.sock</localUri> |
| <faceScope>local</faceScope> |
| <facePersistency>on-demand</facePersistency> |
| <linkType>point-to-point</linkType> |
| <congestion> |
| <baseMarkingInterval>PT0.100S</baseMarkingInterval> |
| <defaultThreshold>65536</defaultThreshold> |
| </congestion> |
| <mtu>8800</mtu> |
| <flags> |
| <localFieldsEnabled/> |
| <lpReliabilityEnabled/> |
| <congestionMarkingEnabled/> |
| </flags> |
| <packetCounters> |
| <incomingPackets> |
| <nInterests>18998</nInterests> |
| <nData>26701</nData> |
| <nNacks>147</nNacks> |
| </incomingPackets> |
| <outgoingPackets> |
| <nInterests>34779</nInterests> |
| <nData>17028</nData> |
| <nNacks>1176</nNacks> |
| </outgoingPackets> |
| </packetCounters> |
| <byteCounters> |
| <incomingBytes>4672308</incomingBytes> |
| <outgoingBytes>8957187</outgoingBytes> |
| </byteCounters> |
| </face> |
| </faces> |
| )XML"); |
| |
| const std::string STATUS_TEXT = |
| "Faces:\n" |
| " faceid=134 remote=udp4://233.252.0.4:6363 local=udp4://192.0.2.1:6363" |
| " counters={in={22562i 22031d 63n 2522915B} out={30121i 20940d 1218n 1353592B}}" |
| " flags={non-local permanent multi-access}\n" |
| " faceid=745 remote=fd://75 local=unix:///var/run/nfd.sock" |
| " congestion={base-marking-interval=100ms default-threshold=65536B} mtu=8800" |
| " counters={in={18998i 26701d 147n 4672308B} out={34779i 17028d 1176n 8957187B}}" |
| " flags={local on-demand point-to-point local-fields lp-reliability congestion-marking}\n"; |
| |
| BOOST_FIXTURE_TEST_CASE(Status, StatusFixture<FaceModule>) |
| { |
| this->fetchStatus(); |
| FaceStatus payload1; |
| payload1.setFaceId(134) |
| .setRemoteUri("udp4://233.252.0.4:6363") |
| .setLocalUri("udp4://192.0.2.1:6363") |
| .setFaceScope(ndn::nfd::FACE_SCOPE_NON_LOCAL) |
| .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_PERMANENT) |
| .setLinkType(ndn::nfd::LINK_TYPE_MULTI_ACCESS) |
| .setNInInterests(22562) |
| .setNInData(22031) |
| .setNInNacks(63) |
| .setNOutInterests(30121) |
| .setNOutData(20940) |
| .setNOutNacks(1218) |
| .setNInBytes(2522915) |
| .setNOutBytes(1353592); |
| FaceStatus payload2; |
| payload2.setFaceId(745) |
| .setRemoteUri("fd://75") |
| .setLocalUri("unix:///var/run/nfd.sock") |
| .setFaceScope(ndn::nfd::FACE_SCOPE_LOCAL) |
| .setFacePersistency(ndn::nfd::FACE_PERSISTENCY_ON_DEMAND) |
| .setLinkType(ndn::nfd::LINK_TYPE_POINT_TO_POINT) |
| .setBaseCongestionMarkingInterval(100_ms) |
| .setDefaultCongestionThreshold(65536) |
| .setMtu(8800) |
| .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, true) |
| .setFlagBit(ndn::nfd::BIT_LP_RELIABILITY_ENABLED, true) |
| .setFlagBit(ndn::nfd::BIT_CONGESTION_MARKING_ENABLED, true) |
| .setNInInterests(18998) |
| .setNInData(26701) |
| .setNInNacks(147) |
| .setNOutInterests(34779) |
| .setNOutData(17028) |
| .setNOutNacks(1176) |
| .setNInBytes(4672308) |
| .setNOutBytes(8957187); |
| this->sendDataset("/localhost/nfd/faces/list", payload1, payload2); |
| this->prepareStatusOutput(); |
| |
| BOOST_CHECK(statusXml.is_equal(STATUS_XML)); |
| BOOST_CHECK(statusText.is_equal(STATUS_TEXT)); |
| } |
| |
| BOOST_AUTO_TEST_SUITE_END() // TestFaceModule |
| BOOST_AUTO_TEST_SUITE_END() // Nfdc |
| |
| } // namespace nfd::tools::nfdc::tests |