BIND 10 master, updated. df38cef2ce0c0856026b7dc3cb0f240fab547668 [2138] Merge branch 'master' into trac2138
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Aug 27 10:28:25 UTC 2012
The branch, master has been updated
via df38cef2ce0c0856026b7dc3cb0f240fab547668 (commit)
via b34e3313460eebc9c272ca8c1beb27297c195150 (commit)
via 5ac245450d8003d4d625d5a85842bc502e215b55 (commit)
via a8f8eafe5ed789692b1fbcda3172a7b508b50daa (commit)
via c5e8785d2cbc2e22cafa89a8d7b9c0c20dc024c1 (commit)
via 4ebfd2ae59c83f2264929a238e125c89c025b99a (commit)
via 69a1786aaeec95803c00640b7f52481b1b6bee5b (commit)
via 9463f3e4ebe36a200ef4107af976dbb2ea7a2b67 (commit)
via caa70d6b850f75119b9b8f7c71caf8e56bdc47a6 (commit)
via f02efa83ef95d63d9a0f82a4806b748340cf112c (commit)
via c286d6ae6a08691226122bee5cf5ce86aeac723e (commit)
via 72c5c183815239f785725100600a50cca9fbfc93 (commit)
via af5177603e253e05a4ca024e7cca4d33176c30b7 (commit)
via 2d85cd23b8a9e37bf365471016843110337c757d (commit)
via 63f01fe3580fe529b48504c9d8ae5b34abfe3564 (commit)
via 3cd1c7285c20f84b14bc2bb5ae1435c6e6bd1e5e (commit)
via eafad2801a680b93e2fd43df133b10e86c2b7c43 (commit)
via 8b2212d2579f61143274fdd59105d3a05e02c54b (commit)
via a580674f5afabb6c21ece9f1248d85edf64545e1 (commit)
from 86f34c57590a06696b1651a155569d9bef9c8164 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit df38cef2ce0c0856026b7dc3cb0f240fab547668
Merge: b34e331 86f34c5
Author: Kazunori Fujiwara <fujiwara at wide.ad.jp>
Date: Mon Aug 27 18:12:47 2012 +0900
[2138] Merge branch 'master' into trac2138
commit b34e3313460eebc9c272ca8c1beb27297c195150
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Thu Aug 23 13:38:19 2012 -0700
[2138] editorial fix: combine two short lines
commit 5ac245450d8003d4d625d5a85842bc502e215b55
Author: Kazunori Fujiwara <fujiwara at wide.ad.jp>
Date: Thu Aug 23 19:39:37 2012 +0900
[2138] removed unnecessary class StatisticsIntervalConfigTest
from config_unittest.cc
commit a8f8eafe5ed789692b1fbcda3172a7b508b50daa
Author: Kazunori Fujiwara <fujiwara at wide.ad.jp>
Date: Thu Aug 23 19:24:44 2012 +0900
[2138] Removed logging when auth processes "getstats" command.
commit c5e8785d2cbc2e22cafa89a8d7b9c0c20dc024c1
Author: Kazunori Fujiwara <fujiwara at wide.ad.jp>
Date: Thu Aug 23 19:01:50 2012 +0900
[2138] removed "statistics-iterval" configration from system tests
commit 4ebfd2ae59c83f2264929a238e125c89c025b99a
Author: Kazunori Fujiwara <fujiwara at wide.ad.jp>
Date: Thu Aug 23 16:11:37 2012 +0900
[2138] added changelog
commit 69a1786aaeec95803c00640b7f52481b1b6bee5b
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Tue Aug 21 11:36:44 2012 -0700
[2138] revised exceptionGuarantee test so it will actually modify state once.
commit 9463f3e4ebe36a200ef4107af976dbb2ea7a2b67
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Tue Aug 21 10:52:01 2012 -0700
[2138] made the comment for AuthCommandTest::getStats more sense.
commit caa70d6b850f75119b9b8f7c71caf8e56bdc47a6
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Tue Aug 21 10:47:14 2012 -0700
[2138] changed the return type of getStatistics to const pointer.
so we can consistently use const versions.
commit f02efa83ef95d63d9a0f82a4806b748340cf112c
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Tue Aug 21 10:38:13 2012 -0700
[2138] added suggested revised doc for AuthCommand::exec().
commit c286d6ae6a08691226122bee5cf5ce86aeac723e
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Tue Aug 21 09:49:01 2012 -0700
[2138] editorial: removed redundant spaces
commit 72c5c183815239f785725100600a50cca9fbfc93
Merge: 63f01fe af51776
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Tue Aug 21 09:46:50 2012 -0700
[2138] updates the latest branch with fixing conflict with my local changes.
commit af5177603e253e05a4ca024e7cca4d33176c30b7
Author: Kazunori Fujiwara <fujiwara at wide.ad.jp>
Date: Tue Aug 21 18:19:02 2012 +0900
[2138] bind10-gude.xml update and comment update
commit 2d85cd23b8a9e37bf365471016843110337c757d
Author: Kazunori Fujiwara <fujiwara at wide.ad.jp>
Date: Tue Aug 21 17:49:44 2012 +0900
[2138] update from jinmei's review
[2138] max number of columns (79)
[2138] recovered TEST_F(AuthConfigTest, exceptionGuarantee)
to use server.setListenAddresses().
commit 63f01fe3580fe529b48504c9d8ae5b34abfe3564
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Mon Aug 20 14:31:45 2012 -0700
[2138] style fixes: folded long lines, and adjusted brace poitns if necessary.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 15 ++--
doc/guide/bind10-guide.xml | 24 ++---
doc/guide/bind10-messages.xml | 10 ---
src/bin/auth/auth.spec.pre.in | 9 +-
src/bin/auth/auth_config.cc | 35 +-------
src/bin/auth/auth_messages.mes | 42 ---------
src/bin/auth/auth_srv.cc | 40 +--------
src/bin/auth/auth_srv.h | 56 ++----------
src/bin/auth/command.cc | 52 +++++++----
src/bin/auth/main.cc | 14 ---
src/bin/auth/statistics.cc | 81 ++++-------------
src/bin/auth/statistics.h | 44 ++-------
src/bin/auth/tests/auth_srv_unittest.cc | 2 -
src/bin/auth/tests/command_unittest.cc | 21 ++---
src/bin/auth/tests/config_unittest.cc | 72 ++++-----------
src/bin/auth/tests/statistics_unittest.cc | 95 +++++---------------
.../system/bindctl/nsx1/b10-config.db.template.in | 3 +-
tests/system/bindctl/tests.sh | 53 ++++-------
18 files changed, 146 insertions(+), 522 deletions(-)
-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 0f899fc..f9a6608 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,15 +9,15 @@
(Trac #2178, git a75ed413e8a1c8e3702beea4811a46a1bf519bbd)
468. [func]* naokikambe, fujiwara
- b10-stats polls bind10 and b10-auth for statistics data. The
- "poll-interval" parameter in b10-stats is for configuring the
- polling interval. All statistics data collected once are preserved
- while b10-stats is running. The "sendstats" command was removed
- from bind10 and b10-auth. The "statistics-interval" configuration
- item was removed from b10-auth.
+ b10-stats polls the bind10 and b10-auth with new 'getstats' command
+ to retrieve statistics data. The "poll-interval" parameter in
+ b10-stats is for configuring the polling interval. All statistics
+ data collected once are preserved while b10-stats is running.
+ The "sendstats" command was removed from bind10 and b10-auth. The
+ "statistics-interval" configuration item was removed from b10-auth.
(Trac #2136, git dcb5ce50b4b4e50d28247d5f8b5cb8d90bda942a)
(Trac #2137, git d53bb65a43f6027b15a6edc08c137951e3ce5e0e)
- (Trac #2138, git TBD)
+ (Trac #2138, git b34e3313460eebc9c272ca8c1beb27297c195150)
bind10-devel-20120816 released on August 16, 2012
@@ -81,6 +81,7 @@ bind10-devel-20120816 released on August 16, 2012
(Trac #1708, git e0d7c52a71414f4de1361b09d3c70431c96daa3f)
458. [build]* jinmei
+>>>>>>> master
BIND 10 now relies on Boost offset_ptr, which caused some new
portability issues. Such issues are detected at ./configure time.
If ./configure stops due to this, try the following workaround:
diff --git a/doc/guide/bind10-guide.xml b/doc/guide/bind10-guide.xml
index ca197bc..49cb419 100644
--- a/doc/guide/bind10-guide.xml
+++ b/doc/guide/bind10-guide.xml
@@ -1633,21 +1633,6 @@ can use various data source backends.
</simpara>
</listitem>
</varlistentry>
-
- <varlistentry>
- <term>statistics-interval</term>
- <listitem>
- <simpara>
- <varname>statistics-interval</varname> is the timer interval
- in seconds for <command>b10-auth</command> to share its
- statistics information to
- <citerefentry><refentrytitle>b10-stats</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
- Statistics updates can be disabled by setting this to 0.
- The default is 60.
- </simpara>
- </listitem>
- </varlistentry>
-
</variablelist>
</para>
@@ -1680,13 +1665,14 @@ can use various data source backends.
</varlistentry>
<varlistentry>
- <term>sendstats</term>
+ <term>getstats</term>
<listitem>
<simpara>
- <command>sendstats</command> tells <command>b10-auth</command>
+ <command>getstats</command> requests <command>b10-auth</command>
to send its statistics data to
- <citerefentry><refentrytitle>b10-stats</refentrytitle><manvolnum>8</manvolnum></citerefentry>
- immediately.
+ <citerefentry><refentrytitle>b10-stats</refentrytitle>
+ <manvolnum>8</manvolnum></citerefentry>
+ as a response of the command.
</simpara>
</listitem>
</varlistentry>
diff --git a/doc/guide/bind10-messages.xml b/doc/guide/bind10-messages.xml
index bbd6470..79dfe65 100644
--- a/doc/guide/bind10-messages.xml
+++ b/doc/guide/bind10-messages.xml
@@ -420,16 +420,6 @@ This is a debug message reporting that an incoming NOTIFY was received.
</para></listitem>
</varlistentry>
-<varlistentry id="AUTH_RECEIVED_SENDSTATS">
-<term>AUTH_RECEIVED_SENDSTATS command 'sendstats' received</term>
-<listitem><para>
-This is a debug message issued when the authoritative server has received
-a command from the statistics module to send it data. The 'sendstats'
-command is handled differently to other commands, which is why the debug
-message associated with it has its own code.
-</para></listitem>
-</varlistentry>
-
<varlistentry id="AUTH_RESPONSE_FAILURE">
<term>AUTH_RESPONSE_FAILURE exception while building response to query: %1</term>
<listitem><para>
diff --git a/src/bin/auth/auth.spec.pre.in b/src/bin/auth/auth.spec.pre.in
index a0b5a3d..b9587e6 100644
--- a/src/bin/auth/auth.spec.pre.in
+++ b/src/bin/auth/auth.spec.pre.in
@@ -56,11 +56,6 @@
}]
}
},
- { "item_name": "statistics-interval",
- "item_type": "integer",
- "item_optional": true,
- "item_default": 60
- },
{
"item_name": "listen_on",
"item_type": "list",
@@ -110,8 +105,8 @@
]
},
{
- "command_name": "sendstats",
- "command_description": "Send data to a statistics module at once",
+ "command_name": "getstats",
+ "command_description": "Retrieve statistics data",
"command_args": []
},
{
diff --git a/src/bin/auth/auth_config.cc b/src/bin/auth/auth_config.cc
index d7266e5..a67632f 100644
--- a/src/bin/auth/auth_config.cc
+++ b/src/bin/auth/auth_config.cc
@@ -53,37 +53,6 @@ public:
virtual void commit() {};
};
-/// A derived \c AuthConfigParser class for the "statistics-internal"
-/// configuration identifier.
-class StatisticsIntervalConfig : public AuthConfigParser {
-public:
- StatisticsIntervalConfig(AuthSrv& server) :
- server_(server), interval_(0)
- {}
- virtual void build(ConstElementPtr config_value) {
- const int32_t config_interval = config_value->intValue();
- if (config_interval < 0) {
- isc_throw(AuthConfigError, "Negative statistics interval value: "
- << config_interval);
- }
- if (config_interval > 86400) {
- isc_throw(AuthConfigError, "Statistics interval value "
- << config_interval
- << " must be equal to or shorter than 86400");
- }
- interval_ = config_interval;
- }
- virtual void commit() {
- // setStatisticsTimerInterval() is not 100% exception free. But
- // exceptions should happen only in a very rare situation, so we
- // let them be thrown and subsequently regard them as a fatal error.
- server_.setStatisticsTimerInterval(interval_);
- }
-private:
- AuthSrv& server_;
- uint32_t interval_;
-};
-
/// A special parser for testing: it throws from commit() despite the
/// suggested convention of the class interface.
class ThrowerCommitConfig : public AuthConfigParser {
@@ -155,9 +124,7 @@ createAuthConfigParser(AuthSrv& server, const std::string& config_id) {
// simplicity. In future we'll probably generalize it using map-like
// data structure, and may even provide external register interface so
// that it can be dynamically customized.
- if (config_id == "statistics-interval") {
- return (new StatisticsIntervalConfig(server));
- } else if (config_id == "listen_on") {
+ if (config_id == "listen_on") {
return (new ListenAddressConfig(server));
} else if (config_id == "_commit_throw") {
// This is for testing purpose only and should not appear in the
diff --git a/src/bin/auth/auth_messages.mes b/src/bin/auth/auth_messages.mes
index e964b05..01a18a1 100644
--- a/src/bin/auth/auth_messages.mes
+++ b/src/bin/auth/auth_messages.mes
@@ -122,11 +122,6 @@ a NOTIFY packet that an RR type of something other than SOA in the
question section. (The RR type received is included in the message.) The
server will return a FORMERR error to the sender.
-% AUTH_NO_STATS_SESSION session interface for statistics is not available
-The authoritative server had no session with the statistics module at the
-time it attempted to send it data: the attempt has been abandoned. This
-could be an error in configuration.
-
% AUTH_NO_XFRIN received NOTIFY but XFRIN session is not running
This is a debug message produced by the authoritative server when it receives
a NOTIFY packet but the XFRIN process is not running. The packet will be
@@ -169,12 +164,6 @@ a command on the command channel.
% AUTH_RECEIVED_NOTIFY received incoming NOTIFY for zone name %1, zone class %2
This is a debug message reporting that an incoming NOTIFY was received.
-% AUTH_RECEIVED_SENDSTATS command 'sendstats' received
-This is a debug message issued when the authoritative server has received
-a command from the statistics module to send it data. The 'sendstats'
-command is handled differently to other commands, which is why the debug
-message associated with it has its own code.
-
% AUTH_RESPONSE_FAILURE exception while building response to query: %1
This is a debug message, generated by the authoritative server when an
attempt to create a response to a received DNS packet has failed. The
@@ -242,37 +231,6 @@ is not running, b10-auth will respond to UPDATE requests with rcode NOTIMP.
When b10-ddns is running, b10-ddns will handle and respond to the UPDATE
message.
-% AUTH_STATS_CHANNEL_CREATED STATS session channel created
-This is a debug message indicating that the authoritative server has
-created a channel to the statistics process. It is issued during server
-startup is an indication that the initialization is proceeding normally.
-
-% AUTH_STATS_CHANNEL_ESTABLISHED STATS session channel established
-This is a debug message indicating that the authoritative server
-has established communication over the previously created statistics
-channel. It is issued during server startup is an indication that the
-initialization is proceeding normally.
-
-% AUTH_STATS_COMMS communication error in sending statistics data: %1
-An error was encountered when the authoritative server tried to send data
-to the statistics daemon. The message includes additional information
-describing the reason for the failure.
-
-% AUTH_STATS_TIMEOUT timeout while sending statistics data: %1
-The authoritative server sent data to the statistics daemon but received
-no acknowledgement within the specified time. The message includes
-additional information describing the reason for the failure.
-
-% AUTH_STATS_TIMER_DISABLED statistics timer has been disabled
-This is a debug message indicating that the statistics timer has been
-disabled in the authoritative server and no statistics information is
-being produced.
-
-% AUTH_STATS_TIMER_SET statistics timer set to %1 second(s)
-This is a debug message indicating that the statistics timer has been
-enabled and that the authoritative server will produce statistics data
-at the specified interval.
-
% AUTH_STOP_DDNS_FORWARDER DDNS UPDATE handling stopped
This is a debug message indicating that b10-auth has received a message
that it should stop internally forwarding UPDATE message to b10-ddns.
diff --git a/src/bin/auth/auth_srv.cc b/src/bin/auth/auth_srv.cc
index 0a17d1b..6e5666f 100644
--- a/src/bin/auth/auth_srv.cc
+++ b/src/bin/auth/auth_srv.cc
@@ -247,9 +247,6 @@ public:
ModuleCCSession* config_session_;
AbstractSession* xfrin_session_;
- /// Interval timer for periodic submission of statistics counters.
- IntervalTimer statistics_timer_;
-
/// Query counters for statistics
AuthCounters counters_;
@@ -320,7 +317,6 @@ AuthSrvImpl::AuthSrvImpl(AbstractXfroutClient& xfrout_client,
BaseSocketSessionForwarder& ddns_forwarder) :
config_session_(NULL),
xfrin_session_(NULL),
- statistics_timer_(io_service_),
counters_(),
keyring_(NULL),
ddns_base_forwarder_(ddns_forwarder),
@@ -479,43 +475,11 @@ AuthSrv::setConfigSession(ModuleCCSession* config_session) {
impl_->registerStatisticsValidator();
}
-void
-AuthSrv::setStatisticsSession(AbstractSession* statistics_session) {
- impl_->counters_.setStatisticsSession(statistics_session);
-}
-
ModuleCCSession*
AuthSrv::getConfigSession() const {
return (impl_->config_session_);
}
-uint32_t
-AuthSrv::getStatisticsTimerInterval() const {
- return (impl_->statistics_timer_.getInterval() / 1000);
-}
-
-void
-AuthSrv::setStatisticsTimerInterval(uint32_t interval) {
- if (interval == impl_->statistics_timer_.getInterval()) {
- return;
- }
- if (interval > 86400) {
- // It can't occur since the value is checked in
- // statisticsIntervalConfig::build().
- isc_throw(InvalidParameter, "Too long interval: " << interval);
- }
- if (interval == 0) {
- impl_->statistics_timer_.cancel();
- LOG_DEBUG(auth_logger, DBG_AUTH_OPS, AUTH_STATS_TIMER_DISABLED);
- } else {
- impl_->statistics_timer_.setup(boost::bind(&AuthSrv::submitStatistics,
- this),
- interval * 1000);
- LOG_DEBUG(auth_logger, DBG_AUTH_OPS, AUTH_STATS_TIMER_SET)
- .arg(interval);
- }
-}
-
void
AuthSrv::processMessage(const IOMessage& io_message, Message& message,
OutputBuffer& buffer, DNSServer* server)
@@ -882,8 +846,8 @@ AuthSrv::updateConfig(ConstElementPtr new_config) {
}
}
-bool AuthSrv::submitStatistics() const {
- return (impl_->counters_.submitStatistics());
+ConstElementPtr AuthSrv::getStatistics() const {
+ return (impl_->counters_.getStatistics());
}
uint64_t
diff --git a/src/bin/auth/auth_srv.h b/src/bin/auth/auth_srv.h
index c1835e6..2c2b415 100644
--- a/src/bin/auth/auth_srv.h
+++ b/src/bin/auth/auth_srv.h
@@ -17,7 +17,6 @@
#include <string>
-#include <cc/data.h>
#include <config/ccsession.h>
#include <datasrc/factory.h>
#include <dns/message.h>
@@ -203,64 +202,21 @@ public:
///
void setXfrinSession(isc::cc::AbstractSession* xfrin_session);
- /// \brief Set the communication session with Statistics.
- ///
- /// This function never throws an exception as far as
- /// AuthCounters::setStatisticsSession() doesn't throw.
- ///
- /// Note: this interface is tentative. We'll revisit the ASIO and
- /// session frameworks, at which point the session will probably
- /// be passed on construction of the server.
- ///
- /// \param statistics_session A Session object over which statistics
- /// information is exchanged with statistics module.
- /// The session must be established before setting in the server
- /// object.
- /// Ownership isn't transferred: the caller is responsible for keeping
- /// this object to be valid while the server object is working and for
- /// disconnecting the session and destroying the object when the server
- /// is shutdown.
- void setStatisticsSession(isc::cc::AbstractSession* statistics_session);
-
- /// Return the interval of periodic submission of statistics in seconds.
- ///
- /// If the statistics submission is disabled, it returns 0.
- ///
- /// This method never throws an exception.
- uint32_t getStatisticsTimerInterval() const;
-
- /// Set the interval of periodic submission of statistics.
- ///
- /// If the specified value is non 0, the \c AuthSrv object will submit
- /// its statistics to the statistics module every \c interval seconds.
- /// If it's 0, and \c AuthSrv currently submits statistics, the submission
- /// will be disabled. \c interval must be equal to or shorter than 86400
- /// seconds (1 day).
- ///
- /// This method should normally not throw an exception; however, its
- /// underlying library routines may involve resource allocation, and
- /// when it fails it would result in a corresponding standard exception.
- ///
- /// \param interval The submission interval in seconds if non 0;
- /// or a value of 0 to disable the submission.
- void setStatisticsTimerInterval(uint32_t interval);
-
- /// \brief Submit statistics counters to statistics module.
+ /// \brief Returns statistics data
///
/// This function can throw an exception from
- /// AuthCounters::submitStatistics().
+ /// AuthCounters::getStatistics().
///
- /// \return true on success, false on failure (e.g. session timeout,
- /// session error).
- bool submitStatistics() const;
+ /// \return JSON format statistics data.
+ isc::data::ConstElementPtr getStatistics() const;
/// \brief Get the value of counter in the AuthCounters.
///
- /// This function calls AuthCounters::getCounter() and
+ /// This function calls AuthCounters::getStatistics() and
/// returns its return value.
///
/// This function never throws an exception as far as
- /// AuthCounters::getCounter() doesn't throw.
+ /// AuthCounters::getStatistics() doesn't throw.
///
/// Note: Currently this function is for testing purpose only.
///
diff --git a/src/bin/auth/command.cc b/src/bin/auth/command.cc
index f3cc260..0658c17 100644
--- a/src/bin/auth/command.cc
+++ b/src/bin/auth/command.cc
@@ -98,16 +98,27 @@ public:
/// \c AuthCommandError when it encounters an internal error, such as
/// semantics error on the command arguments.
///
+ /// This method should return the execution result in the form of
+ /// \c ConstElementPtr. It will be transparently used as the return
+ /// value from the command handler called from the corresponding
+ /// \c CCSession object. For a successful completion of the command,
+ /// it should suffice to return the return value of
+ /// \c isc::config::createAnswer() with no argument.
+ ///
/// \param server The \c AuthSrv object on which the command is executed.
/// \param args Command specific argument.
- virtual void exec(AuthSrv& server, isc::data::ConstElementPtr args) = 0;
+ /// \return Command execution result.
+ virtual ConstElementPtr exec(AuthSrv& server,
+ isc::data::ConstElementPtr args) = 0;
};
// Handle the "shutdown" command. An optional parameter "pid" is used to
// see if it is really for our instance.
class ShutdownCommand : public AuthCommand {
public:
- virtual void exec(AuthSrv& server, isc::data::ConstElementPtr args) {
+ virtual ConstElementPtr exec(AuthSrv& server,
+ isc::data::ConstElementPtr args)
+ {
// Is the pid argument provided?
if (args && args->contains("pid")) {
// If it is, we check it is the same as our PID
@@ -123,41 +134,47 @@ public:
// there are multiple instances of the server running and
// another instance is being shut down, we get the message
// too, due to the multicast nature of our message bus.
- return;
+ return (createAnswer());
}
}
LOG_DEBUG(auth_logger, DBG_AUTH_SHUT, AUTH_SHUTDOWN);
server.stop();
+ return (createAnswer());
}
};
-// Handle the "sendstats" command. No argument is assumed.
-class SendStatsCommand : public AuthCommand {
+// Handle the "getstats" command. The argument is a list.
+class GetStatsCommand : public AuthCommand {
public:
- virtual void exec(AuthSrv& server, isc::data::ConstElementPtr) {
- LOG_DEBUG(auth_logger, DBG_AUTH_OPS, AUTH_RECEIVED_SENDSTATS);
- server.submitStatistics();
+ virtual ConstElementPtr exec(AuthSrv& server, isc::data::ConstElementPtr) {
+ return (createAnswer(0, server.getStatistics()));
}
};
class StartDDNSForwarderCommand : public AuthCommand {
public:
- virtual void exec(AuthSrv& server, isc::data::ConstElementPtr) {
+ virtual ConstElementPtr exec(AuthSrv& server,
+ isc::data::ConstElementPtr) {
server.createDDNSForwarder();
+ return (createAnswer());
}
};
class StopDDNSForwarderCommand : public AuthCommand {
public:
- virtual void exec(AuthSrv& server, isc::data::ConstElementPtr) {
+ virtual ConstElementPtr exec(AuthSrv& server,
+ isc::data::ConstElementPtr) {
server.destroyDDNSForwarder();
+ return (createAnswer());
}
};
// Handle the "loadzone" command.
class LoadZoneCommand : public AuthCommand {
public:
- virtual void exec(AuthSrv& server, isc::data::ConstElementPtr args) {
+ virtual ConstElementPtr exec(AuthSrv& server,
+ isc::data::ConstElementPtr args)
+ {
if (args == NULL) {
isc_throw(AuthCommandError, "Null argument");
}
@@ -185,7 +202,7 @@ public:
// Everything worked fine.
LOG_DEBUG(auth_logger, DBG_AUTH_OPS, AUTH_LOAD_ZONE)
.arg(zone_class).arg(origin);
- return;
+ return (createAnswer());
case ConfigurableClientList::ZONE_NOT_FOUND:
isc_throw(AuthCommandError, "Zone " << origin << "/" <<
zone_class << " was not found in any configured "
@@ -202,6 +219,7 @@ public:
isc_throw(isc::Unexpected, "Cache disabled in client list of "
"class " << zone_class);
}
+ return (createAnswer());
}
};
@@ -212,8 +230,8 @@ createAuthCommand(const string& command_id) {
// (see also createAuthConfigParser())
if (command_id == "shutdown") {
return (new ShutdownCommand());
- } else if (command_id == "sendstats") {
- return (new SendStatsCommand());
+ } else if (command_id == "getstats") {
+ return (new GetStatsCommand());
} else if (command_id == "loadzone") {
return (new LoadZoneCommand());
} else if (command_id == "start_ddns_forwarder") {
@@ -238,13 +256,11 @@ execAuthServerCommand(AuthSrv& server, const string& command_id,
{
LOG_DEBUG(auth_logger, DBG_AUTH_OPS, AUTH_RECEIVED_COMMAND).arg(command_id);
try {
- scoped_ptr<AuthCommand>(createAuthCommand(command_id))->exec(server,
- args);
+ return (scoped_ptr<AuthCommand>(
+ createAuthCommand(command_id))->exec(server, args));
} catch (const isc::Exception& ex) {
LOG_ERROR(auth_logger, AUTH_COMMAND_FAILED).arg(command_id)
.arg(ex.what());
return (createAnswer(1, ex.what()));
}
-
- return (createAnswer());
}
diff --git a/src/bin/auth/main.cc b/src/bin/auth/main.cc
index 0bf24f2..3cca3c0 100644
--- a/src/bin/auth/main.cc
+++ b/src/bin/auth/main.cc
@@ -123,9 +123,7 @@ main(int argc, char* argv[]) {
// XXX: we should eventually pass io_service here.
Session* cc_session = NULL;
Session* xfrin_session = NULL;
- Session* statistics_session = NULL;
bool xfrin_session_established = false; // XXX (see Trac #287)
- bool statistics_session_established = false; // XXX (see Trac #287)
ModuleCCSession* config_session = NULL;
XfroutClient xfrout_client(getXfroutSocketPath());
SocketSessionForwarder ddns_forwarder(getDDNSSocketPath());
@@ -173,14 +171,7 @@ main(int argc, char* argv[]) {
xfrin_session_established = true;
LOG_DEBUG(auth_logger, DBG_AUTH_START, AUTH_XFRIN_CHANNEL_ESTABLISHED);
- statistics_session = new Session(io_service.get_io_service());
- LOG_DEBUG(auth_logger, DBG_AUTH_START, AUTH_STATS_CHANNEL_CREATED);
- statistics_session->establish(NULL);
- statistics_session_established = true;
- LOG_DEBUG(auth_logger, DBG_AUTH_START, AUTH_STATS_CHANNEL_ESTABLISHED);
-
auth_server->setXfrinSession(xfrin_session);
- auth_server->setStatisticsSession(statistics_session);
// Configure the server. configureAuthServer() is expected to install
// all initial configurations, but as a short term workaround we
@@ -226,16 +217,11 @@ main(int argc, char* argv[]) {
ret = 1;
}
- if (statistics_session_established) {
- statistics_session->disconnect();
- }
-
if (xfrin_session_established) {
xfrin_session->disconnect();
}
DataSourceConfigurator::cleanup();
- delete statistics_session;
delete xfrin_session;
delete config_session;
delete cc_session;
diff --git a/src/bin/auth/statistics.cc b/src/bin/auth/statistics.cc
index 427f59e..2d5f336 100644
--- a/src/bin/auth/statistics.cc
+++ b/src/bin/auth/statistics.cc
@@ -55,8 +55,7 @@ public:
}
void inc(const std::string& zone,
const AuthCounters::PerZoneCounterType type);
- bool submitStatistics() const;
- void setStatisticsSession(isc::cc::AbstractSession* statistics_session);
+ isc::data::ConstElementPtr getStatistics() const;
void registerStatisticsValidator
(AuthCounters::validator_type validator);
// Currently for testing purpose only
@@ -74,7 +73,6 @@ private:
Counter rcode_counter_;
static const size_t NUM_RCODES = 17;
CounterDictionary per_zone_counter_;
- isc::cc::AbstractSession* statistics_session_;
AuthCounters::validator_type validator_;
};
@@ -84,8 +82,7 @@ AuthCountersImpl::AuthCountersImpl() :
// size of per_zone_counter_: AuthCounters::PER_ZONE_COUNTER_TYPES
server_counter_(AuthCounters::SERVER_COUNTER_TYPES),
opcode_counter_(NUM_OPCODES), rcode_counter_(NUM_RCODES),
- per_zone_counter_(AuthCounters::PER_ZONE_COUNTER_TYPES),
- statistics_session_(NULL)
+ per_zone_counter_(AuthCounters::PER_ZONE_COUNTER_TYPES)
{
per_zone_counter_.addElement("_SERVER_");
}
@@ -105,25 +102,13 @@ AuthCountersImpl::inc(const std::string& zone,
per_zone_counter_[zone].inc(type);
}
-bool
-AuthCountersImpl::submitStatistics() const {
- if (statistics_session_ == NULL) {
- LOG_ERROR(auth_logger, AUTH_NO_STATS_SESSION);
- return (false);
- }
+isc::data::ConstElementPtr
+AuthCountersImpl::getStatistics() const {
std::stringstream statistics_string;
- // add pid in order for stats to identify which auth sends
- // statistics in the situation that multiple auth instances are
- // working
- statistics_string << "{\"command\": [\"set\","
- << "{ \"owner\": \"Auth\","
- << " \"pid\":" << getpid()
- << ", \"data\":"
- << "{ \"queries.udp\": "
- << server_counter_.get(AuthCounters::SERVER_UDP_QUERY)
- << ", \"queries.tcp\": "
- << server_counter_.get(
- AuthCounters::SERVER_TCP_QUERY);
+ statistics_string << "{ \"queries.udp\": "
+ << server_counter_.get(AuthCounters::SERVER_UDP_QUERY)
+ << ", \"queries.tcp\": "
+ << server_counter_.get(AuthCounters::SERVER_TCP_QUERY);
// Insert non 0 Opcode counters.
for (int i = 0; i < NUM_OPCODES; ++i) {
const Counter::Type counter = opcode_counter_.get(i);
@@ -150,45 +135,18 @@ AuthCountersImpl::submitStatistics() const {
<< counter;
}
}
- statistics_string << " }"
- << "}"
- << "]}";
+ statistics_string << "}";
+
isc::data::ConstElementPtr statistics_element =
isc::data::Element::fromJSON(statistics_string);
// validate the statistics data before send
if (validator_) {
- if (!validator_(
- statistics_element->get("command")->get(1)->get("data"))) {
+ if (!validator_(statistics_element)) {
LOG_ERROR(auth_logger, AUTH_INVALID_STATISTICS_DATA);
- return (false);
+ return (isc::data::ElementPtr());
}
}
- try {
- // group_{send,recv}msg() can throw an exception when encountering
- // an error, and group_recvmsg() will throw an exception on timeout.
- // We don't want to kill the main server just due to this, so we
- // handle them here.
- const int seq =
- statistics_session_->group_sendmsg(statistics_element, "Stats");
- isc::data::ConstElementPtr env, answer;
- // TODO: parse and check response from statistics module
- // currently it just returns empty message
- statistics_session_->group_recvmsg(env, answer, false, seq);
- } catch (const isc::cc::SessionError& ex) {
- LOG_ERROR(auth_logger, AUTH_STATS_COMMS).arg(ex.what());
- return (false);
- } catch (const isc::cc::SessionTimeout& ex) {
- LOG_ERROR(auth_logger, AUTH_STATS_TIMEOUT).arg(ex.what());
- return (false);
- }
- return (true);
-}
-
-void
-AuthCountersImpl::setStatisticsSession
- (isc::cc::AbstractSession* statistics_session)
-{
- statistics_session_ = statistics_session;
+ return (statistics_element);
}
void
@@ -224,16 +182,9 @@ AuthCounters::inc(const Rcode rcode) {
impl_->inc(rcode);
}
-bool
-AuthCounters::submitStatistics() const {
- return (impl_->submitStatistics());
-}
-
-void
-AuthCounters::setStatisticsSession
- (isc::cc::AbstractSession* statistics_session)
-{
- impl_->setStatisticsSession(statistics_session);
+isc::data::ConstElementPtr
+AuthCounters::getStatistics() const {
+ return (impl_->getStatistics());
}
uint64_t
diff --git a/src/bin/auth/statistics.h b/src/bin/auth/statistics.h
index 0c92605..0ca8da4 100644
--- a/src/bin/auth/statistics.h
+++ b/src/bin/auth/statistics.h
@@ -17,8 +17,9 @@
#include <dns/opcode.h>
#include <dns/rcode.h>
-
#include <cc/session.h>
+#include <cc/data.h>
+
#include <stdint.h>
#include <boost/scoped_ptr.hpp>
@@ -34,14 +35,11 @@ class AuthCountersImpl;
/// statistics module.
///
/// This class is designed to be a part of \c AuthSrv.
-/// Call \c setStatisticsSession() to set a session to communicate with
-/// statistics module like Xfrin session.
/// Call \c inc() to increment a counter for specific type of query in
/// the query processing function. use \c enum \c CounterType to specify
/// the type of query.
-/// Call \c submitStatistics() to submit statistics information to statistics
-/// module with statistics_session, periodically or at a time the command
-/// \c sendstats is received.
+/// Call \c getStatistics() to answer statistics information to statistics
+/// module with statistics_session, when the command \c getstats is received.
///
/// We may eventually want to change the structure to hold values that are
/// not counters (such as concurrent TCP connections), or seperate generic
@@ -108,43 +106,15 @@ public:
/// \throw None
void inc(const isc::dns::Rcode rcode);
- /// \brief Submit statistics counters to statistics module.
- ///
- /// This method is desinged to be called periodically
- /// with \c asio_link::StatisticsSendTimer, or arbitrary
- /// by the command 'sendstats'.
- ///
- /// Note: Set the session to communicate with statistics module
- /// by \c setStatisticsSession() before calling \c submitStatistics().
+ /// \brief Answers statistics counters to statistics module.
///
/// This method is mostly exception free (error conditions are
/// represented via the return value). But it may still throw
/// a standard exception if memory allocation fails inside the method.
///
- /// \return true on success, false on error.
- ///
- /// \todo Do not block message handling in auth_srv while submitting
- /// statistics data.
- ///
- bool submitStatistics() const;
-
- /// \brief Set the session to communicate with Statistics
- /// module.
- ///
- /// This method never throws an exception.
- ///
- /// Note: this interface is tentative. We'll revisit the ASIO and session
- /// frameworks, at which point the session will probably be passed on
- /// construction of the server.
- ///
- /// Ownership isn't transferred: the caller is responsible for keeping
- /// this object to be valid while the server object is working and for
- /// disconnecting the session and destroying the object when the server
- /// is shutdown.
- ///
- /// \param statistics_session A pointer to the session
+ /// \return statistics data
///
- void setStatisticsSession(isc::cc::AbstractSession* statistics_session);
+ isc::data::ConstElementPtr getStatistics() const;
/// \brief Get the value of a counter in the AuthCounters.
///
diff --git a/src/bin/auth/tests/auth_srv_unittest.cc b/src/bin/auth/tests/auth_srv_unittest.cc
index 4dddfaf..ca42473 100644
--- a/src/bin/auth/tests/auth_srv_unittest.cc
+++ b/src/bin/auth/tests/auth_srv_unittest.cc
@@ -100,7 +100,6 @@ protected:
{
server.setDNSService(dnss_);
server.setXfrinSession(¬ify_session);
- server.setStatisticsSession(&statistics_session);
server.createDDNSForwarder();
}
@@ -180,7 +179,6 @@ protected:
}
MockDNSService dnss_;
- MockSession statistics_session;
MockXfroutClient xfrout;
MockSocketSessionForwarder ddns_forwarder;
AuthSrv server;
diff --git a/src/bin/auth/tests/command_unittest.cc b/src/bin/auth/tests/command_unittest.cc
index bb2e7c3..a22725e 100644
--- a/src/bin/auth/tests/command_unittest.cc
+++ b/src/bin/auth/tests/command_unittest.cc
@@ -67,16 +67,13 @@ protected:
rcode_(-1),
expect_rcode_(0),
itimer_(server_.getIOService())
- {
- server_.setStatisticsSession(&statistics_session_);
- }
+ {}
void checkAnswer(const int expected_code, const char* name = "") {
SCOPED_TRACE(name);
parseAnswer(rcode_, result_);
EXPECT_EQ(expected_code, rcode_) << result_->str();
}
- MockSession statistics_session_;
MockXfroutClient xfrout_;
MockSocketSessionForwarder ddns_forwarder_;
AuthSrv server_;
@@ -106,14 +103,6 @@ TEST_F(AuthCommandTest, DISABLED_unexpectedException) {
runtime_error);
}
-TEST_F(AuthCommandTest, sendStatistics) {
- result_ = execAuthServerCommand(server_, "sendstats", ConstElementPtr());
- // Just check some message has been sent. Detailed tests specific to
- // statistics are done in its own tests.
- EXPECT_EQ("Stats", statistics_session_.getMessageDest());
- checkAnswer(0);
-}
-
void
AuthCommandTest::stopServer() {
result_ = execAuthServerCommand(server_, "shutdown", param_);
@@ -425,4 +414,12 @@ TEST_F(AuthCommandTest, loadZoneInvalidParams) {
Element::fromJSON("{\"origin\": 10}"));
checkAnswer(1, "Integral name");
}
+
+TEST_F(AuthCommandTest, getStats) {
+ result_ = execAuthServerCommand(server_, "getstats", ConstElementPtr());
+ parseAnswer(rcode_, result_);
+ // Just check the command execution succeeded. Detailed tests specific to
+ // statistics are done in its own tests.
+ EXPECT_EQ(0, rcode_);
+}
}
diff --git a/src/bin/auth/tests/config_unittest.cc b/src/bin/auth/tests/config_unittest.cc
index c4d1db7..73ab353 100644
--- a/src/bin/auth/tests/config_unittest.cc
+++ b/src/bin/auth/tests/config_unittest.cc
@@ -80,17 +80,29 @@ TEST_F(AuthConfigTest, versionConfig) {
}
TEST_F(AuthConfigTest, exceptionGuarantee) {
- server.setStatisticsTimerInterval(1234);
- EXPECT_EQ(1234, server.getStatisticsTimerInterval());
- // This configuration contains an invalid item, which will trigger
- // an exception.
+ using namespace isc::server_common::portconfig;
+ AddressList a;
+ a.push_back(AddressPair("127.0.0.1", 53210));
+ server.setListenAddresses(a);
+ const AddressList b = server.getListenAddresses();
+ EXPECT_EQ(a.size(), b.size());
+ EXPECT_EQ(a.at(0).first, b.at(0).first);
+ EXPECT_EQ(a.at(0).second, b.at(0).second);
+ // The test socket request will reject the second address (192.0.2.2)
+ // with an exception
EXPECT_THROW(configureAuthServer(
server,
Element::fromJSON(
- "{ \"no_such_config_var\": 1}")),
+ "{ \"listen_on\": ["
+ "{\"address\": \"::1\", \"port\": 53210},"
+ "{\"address\": \"192.0.2.2\", \"port\": 53210}"
+ "]}")),
AuthConfigError);
// The server state shouldn't change
- EXPECT_EQ(1234, server.getStatisticsTimerInterval());
+ const AddressList c = server.getListenAddresses();
+ EXPECT_EQ(a.size(), c.size());
+ EXPECT_EQ(a.at(0).first, c.at(0).first);
+ EXPECT_EQ(a.at(0).second, c.at(0).second);
}
TEST_F(AuthConfigTest, badConfig) {
@@ -131,52 +143,4 @@ TEST_F(AuthConfigTest, listenAddressConfig) {
EXPECT_EQ(DNSService::SERVER_SYNC_OK, dnss_.getUDPFdParams().at(1).options);
}
-class StatisticsIntervalConfigTest : public AuthConfigTest {
-protected:
- StatisticsIntervalConfigTest() :
- parser(createAuthConfigParser(server, "statistics-interval"))
- {}
- ~StatisticsIntervalConfigTest() {
- delete parser;
- }
- AuthConfigParser* parser;
-};
-
-TEST_F(StatisticsIntervalConfigTest, setInterval) {
- // initially the timer is not configured.
- EXPECT_EQ(0, server.getStatisticsTimerInterval());
-
- // initialize the timer
- parser->build(Element::fromJSON("5"));
- parser->commit();
- EXPECT_EQ(5, server.getStatisticsTimerInterval());
-
- // reset the timer with a new interval
- delete parser;
- parser = createAuthConfigParser(server, "statistics-interval");
- ASSERT_NE(static_cast<void*>(NULL), parser);
- parser->build(Element::fromJSON("10"));
- parser->commit();
- EXPECT_EQ(10, server.getStatisticsTimerInterval());
-
- // disable the timer again
- delete parser;
- parser = createAuthConfigParser(server, "statistics-interval");
- ASSERT_NE(static_cast<void*>(NULL), parser);
- parser->build(Element::fromJSON("0"));
- parser->commit();
- EXPECT_EQ(0, server.getStatisticsTimerInterval());
-}
-
-TEST_F(StatisticsIntervalConfigTest, badInterval) {
- EXPECT_THROW(parser->build(Element::fromJSON("\"should be integer\"")),
- isc::data::TypeError);
- EXPECT_THROW(parser->build(Element::fromJSON("2.5")),
- isc::data::TypeError);
- EXPECT_THROW(parser->build(Element::fromJSON("-1")), AuthConfigError);
- // bounds check: interval value must be equal to or shorter than
- // 86400 seconds (1 day)
- EXPECT_NO_THROW(parser->build(Element::fromJSON("86400")));
- EXPECT_THROW(parser->build(Element::fromJSON("86401")), AuthConfigError);
-}
}
diff --git a/src/bin/auth/tests/statistics_unittest.cc b/src/bin/auth/tests/statistics_unittest.cc
index 2c25591..d2f5a5a 100644
--- a/src/bin/auth/tests/statistics_unittest.cc
+++ b/src/bin/auth/tests/statistics_unittest.cc
@@ -30,7 +30,6 @@
#include <dns/tests/unittest_util.h>
-using isc::UnitTestUtil;
using namespace std;
using namespace isc::cc;
using namespace isc::dns;
@@ -77,11 +76,9 @@ private:
protected:
AuthCountersTest() : counters() {
- counters.setStatisticsSession(&statistics_session_);
}
~AuthCountersTest() {
}
- MockSession statistics_session_;
AuthCounters counters;
// no need to be inherited from the original class here.
class MockModuleSpec {
@@ -195,25 +192,6 @@ TEST_F(AuthCountersTest, incrementRcodeCounter) {
}
}
-TEST_F(AuthCountersTest, submitStatisticsWithoutSession) {
- // Set statistics_session to NULL and call submitStatistics().
- // Expect to return false.
- counters.setStatisticsSession(NULL);
- EXPECT_FALSE(counters.submitStatistics());
-}
-
-TEST_F(AuthCountersTest, submitStatisticsWithException) {
- // Exception SessionError and SessionTimeout will be thrown
- // while sending statistics data.
- // Both expect to return false.
- statistics_session_.setThrowSessionError(true);
- EXPECT_FALSE(counters.submitStatistics());
- statistics_session_.setThrowSessionError(false);
- statistics_session_.setThrowSessionTimeout(true);
- EXPECT_FALSE(counters.submitStatistics());
- statistics_session_.setThrowSessionTimeout(false);
-}
-
void
opcodeDataCheck(ConstElementPtr data, const int expected[16]) {
const char* item_names[] = {
@@ -258,10 +236,9 @@ rcodeDataCheck(ConstElementPtr data, const int expected[17]) {
ASSERT_EQ(static_cast<const char*>(NULL), item_names[i]);
}
-
-TEST_F(AuthCountersTest, submitStatisticsWithoutValidator) {
- // Submit statistics data.
- // Validate if it submits correct data.
+TEST_F(AuthCountersTest, getStatisticsWithoutValidator) {
+ // Get statistics data.
+ // Validate if it answers correct data.
// Counters should be initialized to 0.
EXPECT_EQ(0, counters.getCounter(AuthCounters::SERVER_UDP_QUERY));
@@ -272,20 +249,8 @@ TEST_F(AuthCountersTest, submitStatisticsWithoutValidator) {
counters.inc(AuthCounters::SERVER_UDP_QUERY);
// TCP query counter is set to 1.
counters.inc(AuthCounters::SERVER_TCP_QUERY);
- counters.submitStatistics();
-
- // Destination is "Stats".
- EXPECT_EQ("Stats", statistics_session_.msg_destination);
- // Command is "set".
- EXPECT_EQ("set", statistics_session_.sent_msg->get("command")
- ->get(0)->stringValue());
- EXPECT_EQ("Auth", statistics_session_.sent_msg->get("command")
- ->get(1)->get("owner")->stringValue());
- EXPECT_EQ(statistics_session_.sent_msg->get("command")
- ->get(1)->get("pid")->intValue(), getpid());
- ConstElementPtr statistics_data = statistics_session_.sent_msg
- ->get("command")->get(1)
- ->get("data");
+ ConstElementPtr statistics_data = counters.getStatistics();
+
// UDP query counter is 2 and TCP query counter is 1.
EXPECT_EQ(2, statistics_data->get("queries.udp")->intValue());
EXPECT_EQ(1, statistics_data->get("queries.tcp")->intValue());
@@ -318,61 +283,53 @@ updateRcodeCounters(AuthCounters &counters, const int expected[17]) {
}
}
-TEST_F(AuthCountersTest, submitStatisticsWithOpcodeCounters) {
+TEST_F(AuthCountersTest, getStatisticsWithOpcodeCounters) {
// Increment some of the opcode counters. Then they should appear in the
// submitted data; others shouldn't
const int opcode_results[16] = { 1, 2, 3, 0, 4, 5, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0 };
updateOpcodeCounters(counters, opcode_results);
- counters.submitStatistics();
- ConstElementPtr statistics_data = statistics_session_.sent_msg
- ->get("command")->get(1)->get("data");
+ ConstElementPtr statistics_data = counters.getStatistics();
opcodeDataCheck(statistics_data, opcode_results);
}
-TEST_F(AuthCountersTest, submitStatisticsWithAllOpcodeCounters) {
+TEST_F(AuthCountersTest, getStatisticsWithAllOpcodeCounters) {
// Increment all opcode counters. Then they should appear in the
// submitted data.
const int opcode_results[16] = { 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1 };
updateOpcodeCounters(counters, opcode_results);
- counters.submitStatistics();
- ConstElementPtr statistics_data = statistics_session_.sent_msg
- ->get("command")->get(1)->get("data");
+ ConstElementPtr statistics_data = counters.getStatistics();
opcodeDataCheck(statistics_data, opcode_results);
}
-TEST_F(AuthCountersTest, submitStatisticsWithRcodeCounters) {
+TEST_F(AuthCountersTest, getStatisticsWithRcodeCounters) {
// Increment some of the rcode counters. Then they should appear in the
// submitted data; others shouldn't
const int rcode_results[17] = { 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 0, 0, 0, 0, 0, 0, 11 };
updateRcodeCounters(counters, rcode_results);
- counters.submitStatistics();
- ConstElementPtr statistics_data = statistics_session_.sent_msg
- ->get("command")->get(1)->get("data");
+ ConstElementPtr statistics_data = counters.getStatistics();
rcodeDataCheck(statistics_data, rcode_results);
}
-TEST_F(AuthCountersTest, submitStatisticsWithAllRcodeCounters) {
+TEST_F(AuthCountersTest, getStatisticsWithAllRcodeCounters) {
// Increment all rcode counters. Then they should appear in the
// submitted data.
const int rcode_results[17] = { 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1 };
updateOpcodeCounters(counters, rcode_results);
- counters.submitStatistics();
- ConstElementPtr statistics_data = statistics_session_.sent_msg
- ->get("command")->get(1)->get("data");
+ ConstElementPtr statistics_data = counters.getStatistics();
opcodeDataCheck(statistics_data, rcode_results);
}
-TEST_F(AuthCountersTest, submitStatisticsWithValidator) {
+TEST_F(AuthCountersTest, getStatisticsWithValidator) {
//a validator for the unittest
AuthCounters::validator_type validator;
ConstElementPtr el;
- // Submit statistics data with correct statistics validator.
+ // Get statistics data with correct statistics validator.
validator = boost::bind(
&AuthCountersTest::MockModuleSpec::validateStatistics,
&module_spec_, _1, true);
@@ -392,24 +349,14 @@ TEST_F(AuthCountersTest, submitStatisticsWithValidator) {
// TCP query counter is set to 1.
counters.inc(AuthCounters::SERVER_TCP_QUERY);
- // checks the value returned by submitStatistics
- EXPECT_TRUE(counters.submitStatistics());
-
- // Destination is "Stats".
- EXPECT_EQ("Stats", statistics_session_.msg_destination);
- // Command is "set".
- EXPECT_EQ("set", statistics_session_.sent_msg->get("command")
- ->get(0)->stringValue());
- EXPECT_EQ("Auth", statistics_session_.sent_msg->get("command")
- ->get(1)->get("owner")->stringValue());
- ConstElementPtr statistics_data = statistics_session_.sent_msg
- ->get("command")->get(1)
- ->get("data");
+ // checks the value returned by getStatistics
+ ConstElementPtr statistics_data = counters.getStatistics();
+
// UDP query counter is 2 and TCP query counter is 1.
EXPECT_EQ(2, statistics_data->get("queries.udp")->intValue());
EXPECT_EQ(1, statistics_data->get("queries.tcp")->intValue());
- // Submit statistics data with incorrect statistics validator.
+ // Get statistics data with incorrect statistics validator.
validator = boost::bind(
&AuthCountersTest::MockModuleSpec::validateStatistics,
&module_spec_, _1, false);
@@ -418,7 +365,7 @@ TEST_F(AuthCountersTest, submitStatisticsWithValidator) {
counters.registerStatisticsValidator(validator);
- // checks the value returned by submitStatistics
- EXPECT_FALSE(counters.submitStatistics());
+ // checks the value returned by getStatistics
+ EXPECT_FALSE(counters.getStatistics());
}
}
diff --git a/tests/system/bindctl/nsx1/b10-config.db.template.in b/tests/system/bindctl/nsx1/b10-config.db.template.in
index 118e533..4d6f287 100644
--- a/tests/system/bindctl/nsx1/b10-config.db.template.in
+++ b/tests/system/bindctl/nsx1/b10-config.db.template.in
@@ -1,8 +1,7 @@
{"version": 2,
"Auth": {
"listen_on": [{"address": "10.53.0.1", "port": 53210}],
- "database_file": "@abs_builddir@/zone.sqlite3",
- "statistics-interval": 1
+ "database_file": "@abs_builddir@/zone.sqlite3"
},
"data_sources": {
"classes": {
diff --git a/tests/system/bindctl/tests.sh b/tests/system/bindctl/tests.sh
index 019461f..9611c90 100755
--- a/tests/system/bindctl/tests.sh
+++ b/tests/system/bindctl/tests.sh
@@ -52,7 +52,6 @@ n=`expr $n + 1`
echo "I:Checking BIND 10 statistics after a pause ($n)"
# wait for 2sec to make sure b10-stats gets the latest statistics.
-# note that we set statistics-interval to 1.
sleep 2
echo 'Stats show
' | $RUN_BINDCTL \
@@ -62,15 +61,10 @@ echo 'Stats show
cnt_value1=`expr $cnt_value1 + 0`
cnt_value2=`expr $cnt_value2 + 1`
cnt_value3=`expr $cnt_value1 + $cnt_value2`
-# Further changes of Boss(#2137) and Auth(#2138) depends on this
-# change(#2136). So statistics tests in this system test make no
-# sense. Following statistics tests are disabled until codes of both
-# #2137 and #2138 are merged.
-#grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
-#grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
-#grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
-#if [ $status != 0 ]; then echo "I:failed"; fi
-echo "I:skipped"
+grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
+grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
+grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
+if [ $status != 0 ]; then echo "I:failed"; fi
n=`expr $n + 1`
echo "I:Stopping b10-auth and checking that ($n)"
@@ -110,15 +104,10 @@ echo 'Stats show
cnt_value1=`expr $cnt_value1 + 0`
cnt_value2=`expr $cnt_value2 + 1`
cnt_value3=`expr $cnt_value1 + $cnt_value2`
-# Further changes of Boss(#2137) and Auth(#2138) depends on this
-# change(#2136). So statistics tests in this system test make no
-# sense. Following statistics tests are disabled until codes of both
-# #2137 and #2138 are merged.
-#grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
-#grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
-#grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
-#if [ $status != 0 ]; then echo "I:failed"; fi
-echo "I:skipped"
+grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
+grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
+grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
+if [ $status != 0 ]; then echo "I:failed"; fi
n=`expr $n + 1`
echo "I:Changing the data source from sqlite3 to in-memory ($n)"
@@ -143,15 +132,10 @@ echo 'Stats show
cnt_value1=`expr $cnt_value1 + 0`
cnt_value2=`expr $cnt_value2 + 1`
cnt_value3=`expr $cnt_value1 + $cnt_value2`
-# Further changes of Boss(#2137) and Auth(#2138) depends on this
-# change(#2136). So statistics tests in this system test make no
-# sense. Following statistics tests are disabled until codes of both
-# #2137 and #2138 are merged.
-#grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
-#grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
-#grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
-#if [ $status != 0 ]; then echo "I:failed"; fi
-echo "I:skipped"
+grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
+grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
+grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
+if [ $status != 0 ]; then echo "I:failed"; fi
n=`expr $n + 1`
echo "I:Starting more b10-auths and checking that ($n)"
@@ -183,15 +167,10 @@ do
# The statistics counters should keep being consistent even while
# multiple b10-auths are running.
- # Further changes of Boss(#2137) and Auth(#2138) depends on this
- # change(#2136). So statistics tests in this system test make no
- # sense. Following statistics tests are disabled until codes of both
- # #2137 and #2138 are merged.
- #grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
- #grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
- #grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
- #if [ $status != 0 ]; then echo "I:failed "; break ; fi
- echo "I:skipped"
+ grep $cnt_name1".*\<"$cnt_value1"\>" bindctl.out.$n > /dev/null || status=1
+ grep $cnt_name2".*\<"$cnt_value2"\>" bindctl.out.$n > /dev/null || status=1
+ grep $cnt_name3".*\<"$cnt_value3"\>" bindctl.out.$n > /dev/null || status=1
+ if [ $status != 0 ]; then echo "I:failed "; break ; fi
done
n=`expr $n + 1`
More information about the bind10-changes
mailing list