Commit 598e73f9 authored by Marcin Siodelski's avatar Marcin Siodelski

[5675] Implemented ha-continue command handler.

parent 2147c6a3
......@@ -1384,6 +1384,14 @@ HAService::processScopes(const std::vector<std::string>& scopes) {
return (createAnswer(CONTROL_RESULT_SUCCESS, "New HA scopes configured."));
}
data::ConstElementPtr
HAService::processContinue() {
if (unpause()) {
return (createAnswer(CONTROL_RESULT_SUCCESS, "HA state machine continues."));
}
return (createAnswer(CONTROL_RESULT_SUCCESS, "HA state machine is not paused."));
}
ConstElementPtr
HAService::verifyAsyncResponse(const HttpResponsePtr& response) {
// The response must cast to JSON type.
......
......@@ -610,6 +610,11 @@ public:
/// @return Pointer to the response to the ha-scopes command.
data::ConstElementPtr processScopes(const std::vector<std::string>& scopes);
/// @brief Processes ha-continue command and returns a response.
///
/// @return Pointer to the response to the ha-continue command.
data::ConstElementPtr processContinue();
protected:
/// @brief Checks if the response is valid or contains an error.
......
......@@ -192,6 +192,7 @@ public:
using HAService::config_;
using HAService::communication_state_;
using HAService::query_filter_;
using HAService::state_machine_control_;
using HAService::pending_requests_;
};
......@@ -2320,6 +2321,49 @@ TEST_F(HAServiceTest, processScopes) {
EXPECT_FALSE(service.query_filter_.amServingScope("server3"));
}
// This test verifies that the ha-continue command is processed successfully.
TEST_F(HAServiceTest, processContinue) {
HAConfigPtr config_storage = createValidConfiguration();
// State machine is to be paused in the waiting state.
ASSERT_NO_THROW(config_storage->getStateConfig(HA_WAITING_ST)->setPausing("always"));
TestHAService service(io_service_, network_state_, config_storage);
// Pause the state machine.
EXPECT_NO_THROW(service.state_machine_control_.notify(HA_WAITING_ST));
EXPECT_TRUE(service.state_machine_control_.amPaused());
// Process ha-continue command that should unpause the state machine.
ConstElementPtr rsp;
ASSERT_NO_THROW(rsp = service.processContinue());
// The server should have responded.
ASSERT_TRUE(rsp);
checkAnswer(rsp, CONTROL_RESULT_SUCCESS, "HA state machine continues.");
// State machine should have been unpaused as a result of processing the
// command.
EXPECT_FALSE(service.state_machine_control_.amPaused());
// Response should include no arguments.
EXPECT_FALSE(rsp->get("arguments"));
// Sending ha-continue command again which should return success but
// slightly different textual status.
ASSERT_NO_THROW(rsp = service.processContinue());
// The server should have responded.
ASSERT_TRUE(rsp);
checkAnswer(rsp, CONTROL_RESULT_SUCCESS, "HA state machine is not paused.");
// The state machine should not be paused.
EXPECT_FALSE(service.state_machine_control_.amPaused());
// Response should include no arguments.
EXPECT_FALSE(rsp->get("arguments"));
}
/// @brief HA partner to the server under test.
///
/// This is a wrapper class around @c HttpListener which simulates a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment