Browse Source

[master] Multiple small improvements in the unit tests.

Also, the read buffer for unix socket client is extended to 64k.
Marcin Siodelski 8 years ago
parent
commit
c6522aa9c3

+ 1 - 1
src/bin/agent/ca_command_mgr.h

@@ -110,7 +110,7 @@ private:
     CtrlAgentCommandMgr();
     CtrlAgentCommandMgr();
 
 
     /// @brief Buffer into which responses to forwarded commands are stored.
     /// @brief Buffer into which responses to forwarded commands are stored.
-    std::array<char, 8192> receive_buf_;
+    std::array<char, 65535> receive_buf_;
 
 
 };
 };
 
 

+ 9 - 5
src/bin/agent/tests/ca_command_mgr_unittests.cc

@@ -230,14 +230,16 @@ public:
         // to this we need to run the server side socket at the same time.
         // to this we need to run the server side socket at the same time.
         // Running IO service in a thread guarantees that the server responds
         // Running IO service in a thread guarantees that the server responds
         // as soon as it receives the control command.
         // as soon as it receives the control command.
-        isc::util::thread::Thread(boost::bind(&CtrlAgentCommandMgrTest::runIO,
-                                              getIOService(), server_socket_,
-                                              expected_responses));
+        isc::util::thread::Thread th(boost::bind(&CtrlAgentCommandMgrTest::runIO,
+                                                 getIOService(), server_socket_,
+                                                 expected_responses));
 
 
         ConstElementPtr command = createCommand("foo", service);
         ConstElementPtr command = createCommand("foo", service);
         ConstElementPtr answer = mgr_.handleCommand("foo", ConstElementPtr(),
         ConstElementPtr answer = mgr_.handleCommand("foo", ConstElementPtr(),
                                                     command);
                                                     command);
 
 
+        th.wait();
+
         checkAnswer(answer, expected_result0, expected_result1, expected_result2);
         checkAnswer(answer, expected_result0, expected_result1, expected_result2);
     }
     }
 
 
@@ -364,13 +366,15 @@ TEST_F(CtrlAgentCommandMgrTest, forwardListCommands) {
     // to this we need to run the server side socket at the same time.
     // to this we need to run the server side socket at the same time.
     // Running IO service in a thread guarantees that the server responds
     // Running IO service in a thread guarantees that the server responds
     // as soon as it receives the control command.
     // as soon as it receives the control command.
-    isc::util::thread::Thread(boost::bind(&CtrlAgentCommandMgrTest::runIO,
-                                          getIOService(), server_socket_, 1));
+    isc::util::thread::Thread th(boost::bind(&CtrlAgentCommandMgrTest::runIO,
+                                             getIOService(), server_socket_, 1));
 
 
     ConstElementPtr command = createCommand("list-commands", "dhcp4");
     ConstElementPtr command = createCommand("list-commands", "dhcp4");
     ConstElementPtr answer = mgr_.handleCommand("list-commands", ConstElementPtr(),
     ConstElementPtr answer = mgr_.handleCommand("list-commands", ConstElementPtr(),
                                                 command);
                                                 command);
 
 
+    th.wait();
+
     // Answer of 3 is specific to the stub response we send when the
     // Answer of 3 is specific to the stub response we send when the
     // command is forwarded. So having this value returned means that
     // command is forwarded. So having this value returned means that
     // the command was forwarded as expected.
     // the command was forwarded as expected.

+ 5 - 1
src/lib/asiolink/testutils/test_server_unix_socket.cc

@@ -225,7 +225,11 @@ TestServerUnixSocket::bindServerSocket() {
 }
 }
 
 
 void
 void
-TestServerUnixSocket::acceptHandler(const boost::system::error_code&) {
+TestServerUnixSocket::acceptHandler(const boost::system::error_code& ec) {
+    if (ec) {
+        return;
+    }
+
     connection_pool_->start(custom_response_);
     connection_pool_->start(custom_response_);
     accept();
     accept();
 }
 }