diff options
author | Michal 'vorner' Vaner <michal.vaner@nic.cz> | 2013-02-22 11:16:30 +0100 |
---|---|---|
committer | Michal 'vorner' Vaner <michal.vaner@nic.cz> | 2013-02-22 11:22:04 +0100 |
commit | 83966d1e3ede61d6e71a26d179e2d2d30b4655df (patch) | |
tree | 5eae7a3763bb1d779ad66ce5ba64d753cbf15398 /src/lib | |
parent | [2768] Output seq of message waited for (diff) | |
download | kea-83966d1e3ede61d6e71a26d179e2d2d30b4655df.tar.xz kea-83966d1e3ede61d6e71a26d179e2d2d30b4655df.zip |
[2768] Make sure the rpcCall asks for answer
Add tests for the fact and fix it. Also, add log from the rpcCall
itself, so it can be seen in logs.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/config/ccsession.cc | 8 | ||||
-rw-r--r-- | src/lib/config/ccsession.h | 6 | ||||
-rw-r--r-- | src/lib/config/config_messages.mes | 4 | ||||
-rw-r--r-- | src/lib/config/tests/ccsession_unittests.cc | 2 | ||||
-rw-r--r-- | src/lib/config/tests/fake_session.cc | 9 | ||||
-rw-r--r-- | src/lib/config/tests/fake_session.h | 3 |
6 files changed, 22 insertions, 10 deletions
diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc index cd01603f4a..bf250509d5 100644 --- a/src/lib/config/ccsession.cc +++ b/src/lib/config/ccsession.cc @@ -32,7 +32,7 @@ #include <boost/foreach.hpp> #include <cc/data.h> -#include <module_spec.h> +#include <config/module_spec.h> #include <cc/session.h> #include <exceptions/exceptions.h> @@ -863,9 +863,11 @@ ModuleCCSession::rpcCall(const std::string &command, const std::string &group, const ConstElementPtr ¶ms) { const ConstElementPtr &command_el(createCommand(command, params)); - const int seq = session_.group_sendmsg(command_el, group, instance, to); + const int seq = groupSendMsg(command_el, group, instance, to, true); ConstElementPtr env, answer; - session_.group_recvmsg(env, answer, false, seq); + LOG_DEBUG(config_logger, DBGLVL_TRACE_DETAIL, CONFIG_RPC_SEQ).arg(command). + arg(group).arg(seq); + groupRecvMsg(env, answer, true, seq); int rcode; const ConstElementPtr &result(parseAnswer(rcode, answer)); if (rcode == isc::cc::CC_REPLY_NO_RECPT) { diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h index c9a6ffe2b7..c429d7a0cc 100644 --- a/src/lib/config/ccsession.h +++ b/src/lib/config/ccsession.h @@ -363,13 +363,15 @@ public: * \param group see isc::cc::Session::group_sendmsg() * \param instance see isc::cc::Session::group_sendmsg() * \param to see isc::cc::Session::group_sendmsg() + * \param want_answer see isc::cc::Session::group_sendmsg() * \return see isc::cc::Session::group_sendmsg() */ int groupSendMsg(isc::data::ConstElementPtr msg, std::string group, std::string instance = "*", - std::string to = "*") { - return (session_.group_sendmsg(msg, group, instance, to)); + std::string to = "*", + bool want_answer = false) { + return (session_.group_sendmsg(msg, group, instance, to, want_answer)); }; /** diff --git a/src/lib/config/config_messages.mes b/src/lib/config/config_messages.mes index 552256c300..6735b16c4c 100644 --- a/src/lib/config/config_messages.mes +++ b/src/lib/config/config_messages.mes @@ -94,3 +94,7 @@ manager. % CONFIG_OPEN_FAIL error opening %1: %2 There was an error opening the given file. The reason for the failure is included in the message. + +% CONFIG_RPC_SEQ RPC call %1 to %2 with seq %3 +Debug message, saying there's a RPC call of given command to given module. It +has internal sequence number as listed in the message. diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc index 824125b7c0..b7b126746c 100644 --- a/src/lib/config/tests/ccsession_unittests.cc +++ b/src/lib/config/tests/ccsession_unittests.cc @@ -71,7 +71,7 @@ protected: " \"command\": [\"test\", {" " \"param1\": \"Param 1\"," " \"param2\": \"Param 2\"" - "}]}, -1]")); + "}]}, -1, true]")); // The 0th one is from the initialization, to ConfigManager. // our is the 1st. EXPECT_TRUE(request->equals(*session.getMsgQueue()->get(1))) << diff --git a/src/lib/config/tests/fake_session.cc b/src/lib/config/tests/fake_session.cc index 56a30d42f5..a5d81cffa0 100644 --- a/src/lib/config/tests/fake_session.cc +++ b/src/lib/config/tests/fake_session.cc @@ -183,12 +183,12 @@ FakeSession::unsubscribe(std::string group, std::string instance) { int FakeSession::group_sendmsg(ConstElementPtr msg, std::string group, - std::string to, std::string, bool) + std::string to, std::string, bool want_answer) { if (throw_on_send_) { isc_throw(Exception, "Throw on send is set in FakeSession"); } - addMessage(msg, group, to); + addMessage(msg, group, to, -1, want_answer); return (1); } @@ -231,13 +231,16 @@ FakeSession::getFirstMessage(std::string& group, std::string& to) const { void FakeSession::addMessage(ConstElementPtr msg, const std::string& group, - const std::string& to, int seq) + const std::string& to, int seq, bool want_answer) { ElementPtr m_el = Element::createList(); m_el->add(Element::create(group)); m_el->add(Element::create(to)); m_el->add(msg); m_el->add(Element::create(seq)); + if (want_answer) { + m_el->add(Element::create(want_answer)); + } if (!msg_queue_) { msg_queue_ = Element::createList(); } diff --git a/src/lib/config/tests/fake_session.h b/src/lib/config/tests/fake_session.h index 0dbaadb93a..8a564a8021 100644 --- a/src/lib/config/tests/fake_session.h +++ b/src/lib/config/tests/fake_session.h @@ -75,7 +75,8 @@ public: isc::data::ConstElementPtr getFirstMessage(std::string& group, std::string& to) const; void addMessage(isc::data::ConstElementPtr, const std::string& group, - const std::string& to, int seq = -1); + const std::string& to, int seq = -1, + bool want_answer = false); bool haveSubscription(const std::string& group, const std::string& instance); bool haveSubscription(const isc::data::ConstElementPtr group, |