From: Marcin Siodelski Date: Mon, 29 May 2017 11:51:51 +0000 (+0200) Subject: [5189] Added a test for checking ClientConnection timeout in CA. X-Git-Tag: trac5243_base~4^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=180f1f993a78cbd9feff172cc33631f172c024c2;p=thirdparty%2Fkea.git [5189] Added a test for checking ClientConnection timeout in CA. --- diff --git a/src/bin/agent/tests/ca_command_mgr_unittests.cc b/src/bin/agent/tests/ca_command_mgr_unittests.cc index 5b2b98c29f..39bee3096b 100644 --- a/src/bin/agent/tests/ca_command_mgr_unittests.cc +++ b/src/bin/agent/tests/ca_command_mgr_unittests.cc @@ -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) { diff --git a/src/lib/config/client_connection.cc b/src/lib/config/client_connection.cc index 0a5dad1aae..7d23ee0445 100644 --- a/src/lib/config/client_connection.cc +++ b/src/lib/config/client_connection.cc @@ -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_);