From: Marcin Siodelski Date: Thu, 22 Jun 2017 09:11:57 +0000 (+0200) Subject: [master] Merge branch 'trac5190' X-Git-Tag: trac5286_base~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc67885022115df76425c6901959cedee63a93b9;p=thirdparty%2Fkea.git [master] Merge branch 'trac5190' --- fc67885022115df76425c6901959cedee63a93b9 diff --cc src/bin/agent/tests/ca_command_mgr_unittests.cc index 39bee3096b,99e799c5cd..6d1890eb5a --- a/src/bin/agent/tests/ca_command_mgr_unittests.cc +++ b/src/bin/agent/tests/ca_command_mgr_unittests.cc @@@ -224,20 -221,17 +223,20 @@@ public const size_t expected_responses = 1, const std::string& server_response = "{ \"result\": 0 }") { // Configure client side socket. - configureControlSocket(server_type); + configureControlSocket(configured_service); // Create server side socket. - bindServerSocket(server_response); + bindServerSocket(server_response, true); // The client side communication is synchronous. To be able to respond - // 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 - // as soon as it receives the control command. - isc::util::thread::Thread th(boost::bind(&CtrlAgentCommandMgrTest::runIO, - getIOService(), server_socket_, - expected_responses)); + // to this we need to run the server side socket at the same time as the + // client. Running IO service in a thread guarantees that the server + //responds as soon as it receives the control command. + isc::util::thread::Thread th(boost::bind(&IOService::run, + getIOService().get())); + + + // Wait for the IO service in thread to actually run. + server_socket_->waitForRunning(); ConstElementPtr command = createCommand("foo", service); ConstElementPtr answer = mgr_.handleCommand("foo", ConstElementPtr(), @@@ -321,19 -322,7 +316,19 @@@ TEST_F(CtrlAgentCommandMgrTest, noServi /// Check that error is returned to the client when the server to which the /// command was forwarded sent an invalid message. TEST_F(CtrlAgentCommandMgrTest, invalidAnswer) { - testForward(CtrlAgentCfgContext::TYPE_DHCP6, "dhcp6", + testForward("dhcp6", "dhcp6", + isc::config::CONTROL_RESULT_ERROR, -1, -1, 1, + "{ \"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"); } @@@ -364,9 -353,9 +359,9 @@@ TEST_F(CtrlAgentCommandMgrTest, noServe // value is specified. TEST_F(CtrlAgentCommandMgrTest, forwardListCommands) { // Configure client side socket. - configureControlSocket(CtrlAgentCfgContext::TYPE_DHCP4); + configureControlSocket("dhcp4"); // Create server side socket. - bindServerSocket("{ \"result\" : 3 }"); + bindServerSocket("{ \"result\" : 3 }", true); // The client side communication is synchronous. To be able to respond // to this we need to run the server side socket at the same time.