BIND 10 trac1596, updated. 03a1f23dbeec538ee042f3f28203ea8cb3b29bfd [1596] Update test

BIND 10 source code commits bind10-changes at lists.isc.org
Fri Feb 10 12:34:21 UTC 2012


The branch, trac1596 has been updated
       via  03a1f23dbeec538ee042f3f28203ea8cb3b29bfd (commit)
       via  67167017ac51545493ed1adb6c7c33d3c19501c5 (commit)
       via  716ae36b91bc71f72098b8c831c5e86c845a99bc (commit)
      from  308d0c39eade6985c4f61feb215255cf2ec92abf (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 03a1f23dbeec538ee042f3f28203ea8cb3b29bfd
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Feb 10 13:30:15 2012 +0100

    [1596] Update test
    
    Put some more realistic data there

commit 67167017ac51545493ed1adb6c7c33d3c19501c5
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Feb 10 13:25:13 2012 +0100

    [1596] Some review addressing

commit 716ae36b91bc71f72098b8c831c5e86c845a99bc
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Fri Feb 10 12:40:13 2012 +0100

    [1596] Return deleted line

-----------------------------------------------------------------------

Summary of changes:
 src/bin/auth/auth_log.h                           |    2 +
 src/bin/auth/auth_messages.mes                    |    4 +++
 src/bin/auth/auth_srv.h                           |    1 +
 src/bin/auth/command.cc                           |   30 ++++++++++++---------
 src/bin/auth/tests/command_unittest.cc            |   26 ++++++++++++++----
 src/bin/resolver/main.cc                          |   22 ++++++++++-----
 src/bin/resolver/resolver_messages.mes            |    4 +++
 src/lib/python/isc/bind10/tests/component_test.py |    4 +-
 8 files changed, 65 insertions(+), 28 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/auth/auth_log.h b/src/bin/auth/auth_log.h
index e0cae0f..33d4432 100644
--- a/src/bin/auth/auth_log.h
+++ b/src/bin/auth/auth_log.h
@@ -29,6 +29,8 @@ namespace auth {
 
 // Debug messages indicating normal startup are logged at this debug level.
 const int DBG_AUTH_START = DBGLVL_START_SHUT;
+// Debug messages upon shutdown
+const int DBG_AUTH_SHUT = DBGLVL_START_SHUT;
 
 // Debug level used to log setting information (such as configuration changes).
 const int DBG_AUTH_OPS = DBGLVL_COMMAND;
diff --git a/src/bin/auth/auth_messages.mes b/src/bin/auth/auth_messages.mes
index 4706690..44f8d4b 100644
--- a/src/bin/auth/auth_messages.mes
+++ b/src/bin/auth/auth_messages.mes
@@ -192,6 +192,10 @@ reason for the failure is included in the message.
 Initialization of the authoritative server has completed successfully
 and it is entering the main loop, waiting for queries to arrive.
 
+% AUTH_SHUTDOWN asked to stop, doing so
+This is a debug message indicating the server was asked to shut down and it is
+complying to the request.
+
 % AUTH_SQLITE3 nothing to do for loading sqlite3
 This is a debug message indicating that the authoritative server has
 found that the data source it is loading is an SQLite3 data source,
diff --git a/src/bin/auth/auth_srv.h b/src/bin/auth/auth_srv.h
index dc0e512..5383e5a 100644
--- a/src/bin/auth/auth_srv.h
+++ b/src/bin/auth/auth_srv.h
@@ -343,6 +343,7 @@ public:
     ///
     /// \param type Type of a counter to get the value of
     ///
+    /// \return the value of the counter.
 
     uint64_t getCounter(const AuthCounters::ServerCounterType type) const;
 
diff --git a/src/bin/auth/command.cc b/src/bin/auth/command.cc
index 820596a..a0362d2 100644
--- a/src/bin/auth/command.cc
+++ b/src/bin/auth/command.cc
@@ -16,15 +16,11 @@
 #include <auth/auth_log.h>
 #include <auth/auth_srv.h>
 
-#include <exceptions/exceptions.h>
-
-#include <dns/rrclass.h>
-
 #include <cc/data.h>
-
 #include <datasrc/memory_datasrc.h>
-
 #include <config/ccsession.h>
+#include <exceptions/exceptions.h>
+#include <dns/rrclass.h>
 
 #include <string>
 
@@ -113,16 +109,24 @@ class ShutdownCommand : public AuthCommand {
 public:
     virtual void exec(AuthSrv& server, isc::data::ConstElementPtr args) {
         // Is the pid argument provided?
-        if (args && args->getType() ==
-            isc::data::Element::map && args->contains("pid")) {
+        if (args && args->getType() == isc::data::Element::map &&
+            args->contains("pid")) {
             // If it is, we check it is the same as our PID
-            const int pid(args->get("pid")->intValue());
-            const pid_t my_pid(getpid());
-            if (my_pid != pid) {
-                // It is not for us
-                return;
+            if (args->get("pid")->getType() == isc::data::Element::integer) {
+                const int pid(args->get("pid")->intValue());
+                const pid_t my_pid(getpid());
+                if (my_pid != pid) {
+                    // It is not for us
+                    //
+                    // Note that this is completely expected situation, if
+                    // 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;
+                }
             }
         }
+        LOG_DEBUG(auth_logger, DBG_AUTH_SHUT, AUTH_SHUTDOWN);
         server.stop();
     }
 };
diff --git a/src/bin/auth/tests/command_unittest.cc b/src/bin/auth/tests/command_unittest.cc
index 9eaf281..1b152c8 100644
--- a/src/bin/auth/tests/command_unittest.cc
+++ b/src/bin/auth/tests/command_unittest.cc
@@ -69,7 +69,7 @@ protected:
     AuthSrv server;
     ConstElementPtr result;
     // The shutdown command parameter
-    ConstElementPtr param;
+    ConstElementPtr param_;
     int rcode;
     isc::asiolink::IntervalTimer itimer_;
 public:
@@ -103,7 +103,7 @@ TEST_F(AuthCommandTest, sendStatistics) {
 
 void
 AuthCommandTest::stopServer() {
-    result = execAuthServerCommand(server, "shutdown", param);
+    result = execAuthServerCommand(server, "shutdown", param_);
     parseAnswer(rcode, result);
     assert(rcode == 0); // make sure the test stops when something is wrong
 }
@@ -120,7 +120,21 @@ TEST_F(AuthCommandTest, shutdownCorrectPID) {
     const pid_t pid(getpid());
     ElementPtr param(new isc::data::MapElement());
     param->set("pid", ConstElementPtr(new isc::data::IntElement(pid)));
-    this->param = param;
+    param_ = param;
+    // With the correct PID, it should act exactly the same as in case
+    // of no parameter
+    itimer_.setup(boost::bind(&AuthCommandTest::stopServer, this), 1);
+    server.getIOService().run();
+    EXPECT_EQ(0, rcode);
+}
+
+// If we provide something not an int, the PID is not really specified, so
+// act as if nothing came.
+TEST_F(AuthCommandTest, shutdownNotInt) {
+    // Put the pid parameter there
+    ElementPtr param(new isc::data::MapElement());
+    param->set("pid", ConstElementPtr(new isc::data::StringElement("pid")));
+    param_ = param;
     // With the correct PID, it should act exactly the same as in case
     // of no parameter
     itimer_.setup(boost::bind(&AuthCommandTest::stopServer, this), 1);
@@ -132,14 +146,14 @@ TEST_F(AuthCommandTest, shutdownCorrectPID) {
 // command, it should be running
 void
 AuthCommandTest::dontStopServer() {
-    result = execAuthServerCommand(server, "shutdown", param);
+    result = execAuthServerCommand(server, "shutdown", param_);
     parseAnswer(rcode, result);
     EXPECT_EQ(0, rcode);
     rcode = -1;
     // We run the stopServer now, to really stop the server.
     // If it had stopped already, it won't be run and the rcode -1 will
     // be left here.
-    param = ConstElementPtr();
+    param_ = ConstElementPtr();
     itimer_.cancel();
     itimer_.setup(boost::bind(&AuthCommandTest::stopServer, this), 1);
 }
@@ -147,7 +161,7 @@ AuthCommandTest::dontStopServer() {
 TEST_F(AuthCommandTest, shutdownIncorrectPID) {
     // The PID = 0 should be taken by init, so we are not init and the
     // PID should be different
-    param = Element::fromJSON("{\"pid\": 0}");
+    param_ = Element::fromJSON("{\"pid\": 0}");
     itimer_.setup(boost::bind(&AuthCommandTest::dontStopServer, this), 1);
     server.getIOService().run();
     EXPECT_EQ(0, rcode);
diff --git a/src/bin/resolver/main.cc b/src/bin/resolver/main.cc
index eed3378..8d005ac 100644
--- a/src/bin/resolver/main.cc
+++ b/src/bin/resolver/main.cc
@@ -87,16 +87,24 @@ my_command_handler(const string& command, ConstElementPtr args) {
         answer = createAnswer(0, args);
     } else if (command == "shutdown") {
         // Is the pid argument provided?
-        if (args && args->getType() ==
-            isc::data::Element::map && args->contains("pid")) {
+        if (args && args->getType() == isc::data::Element::map &&
+            args->contains("pid")) {
             // If it is, we check it is the same as our PID
-            const int pid(args->get("pid")->intValue());
-            const pid_t my_pid(getpid());
-            if (my_pid != pid) {
-                // It is not for us
-                return (answer);
+            if (args->get("pid")->getType() == isc::data::Element::integer) {
+                const int pid(args->get("pid")->intValue());
+                const pid_t my_pid(getpid());
+                if (my_pid != pid) {
+                    // It is not for us
+                    //
+                    // Note that this is completely expected situation, if
+                    // 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 answer;
+                }
             }
         }
+        LOG_DEBUG(resolver_logger, RESOLVER_DBG_INIT, RESOLVER_SHUTDOWN);
         io_service.stop();
     }
 
diff --git a/src/bin/resolver/resolver_messages.mes b/src/bin/resolver/resolver_messages.mes
index 7930c52..bd9c818 100644
--- a/src/bin/resolver/resolver_messages.mes
+++ b/src/bin/resolver/resolver_messages.mes
@@ -246,3 +246,7 @@ RESOLVER_QUERY_REJECTED case, the server does not return any response.
 The log message shows the query in the form of <query name>/<query
 type>/<query class>, and the client that sends the query in the form of
 <Source IP address>#<source port>.
+
+% RESOLVER_SHUTDOWN asked to shut down, doing so
+A debug message noting that the server was asked to terminate and is
+complying to the request.
diff --git a/src/lib/python/isc/bind10/tests/component_test.py b/src/lib/python/isc/bind10/tests/component_test.py
index b14821c..ec0e8af 100644
--- a/src/lib/python/isc/bind10/tests/component_test.py
+++ b/src/lib/python/isc/bind10/tests/component_test.py
@@ -573,10 +573,10 @@ class ComponentTests(BossUtils, unittest.TestCase):
         component.start()
         self.assertTrue(component.running())
         self.assertEqual('component', self.__start_simple_params)
+        component.pid = lambda: 42
         component.stop()
         self.assertFalse(component.running())
-        # The PID is None, as we don't give it one when faking the start
-        self.assertEqual(('component', 'Address', None),
+        self.assertEqual(('component', 'Address', 42),
                          self.__stop_process_params)
 
     def test_component_kill(self):




More information about the bind10-changes mailing list