]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5189] Added a test for checking ClientConnection timeout in CA.
authorMarcin Siodelski <marcin@isc.org>
Mon, 29 May 2017 11:51:51 +0000 (13:51 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 29 May 2017 11:51:51 +0000 (13:51 +0200)
src/bin/agent/tests/ca_command_mgr_unittests.cc
src/lib/config/client_connection.cc

index 5b2b98c29f619396a0e5f8c856c2d4791786a424..39bee3096b5133277b815f769eb7f2299522c700 100644 (file)
@@ -326,6 +326,18 @@ TEST_F(CtrlAgentCommandMgrTest, invalidAnswer) {
                 "{ \"result\": }");
 }
 
+/// Check that connection is dropped if it takes too long. The test checks
+/// client's behavior when partial JSON is returned. Client will be waiting
+/// for the '}' and will timeout because it is never received.
+/// @todo Currently this test is disabled because we don't have configurable
+/// timeout value. It is hardcoded to 5 sec, which is too long for the
+/// unit test to run.
+TEST_F(CtrlAgentCommandMgrTest, DISABLED_connectionTimeout) {
+    testForward(CtrlAgentCfgContext::TYPE_DHCP6, "dhcp6",
+                isc::config::CONTROL_RESULT_ERROR, -1, -1, 1,
+                "{ \"result\": 0");
+}
+
 /// Check that error is returned to the client if the forwarding socket is
 /// not configured for the given service.
 TEST_F(CtrlAgentCommandMgrTest, noClientSocket) {
index 0a5dad1aae6dc5fb1dc706a7c50c2ff3b15e1507..7d23ee0445e999fd5677077a7dbdfd77eb491ddc 100644 (file)
@@ -221,6 +221,7 @@ ClientConnectionImpl::terminate(const boost::system::error_code& ec,
                                 ClientConnection::Handler handler) {
     try {
         timer_.cancel();
+        socket_.close();
         current_command_.clear();
         handler(ec, feed_);