Commit 717006b2 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[5674] State machine pausing in syncing state.

parent 6fb64283
......@@ -296,6 +296,12 @@ HAService::syncingStateHandler() {
if (doOnEntry()) {
if (state_machine_control_.amPaused()) {
// Check if the clock skew is still acceptable. If not, transition to
......@@ -3555,6 +3555,7 @@ TEST_F(HAServiceStateMachineTest, stateTransitionsLoadBalancingPause) {
HAConfigPtr valid_config = createValidConfiguration();
auto state_configs = valid_config->getStateMachineConfig();
// Set state machine pausing in all states.
for (auto cfg = state_configs.begin(); cfg != state_configs.end(); ++cfg) {
......@@ -3612,6 +3613,55 @@ TEST_F(HAServiceStateMachineTest, stateTransitionsLoadBalancingPause) {
// This test verifies that the HA state machine can be paused in the syncing
// state.
TEST_F(HAServiceStateMachineTest, syncingTransitionsLoadBalancingPause) {
HAConfigPtr valid_config = createValidConfiguration();
// Pause state machine in syncing state.
auto state_config = valid_config->getStateConfig(HA_SYNCING_ST);
// The syncing state handler doesn't start synchronization until it
// detects that the partner is online. It may remember that from the
// previous heartbeat attempts. If the partner appears to be unavailable
// it will continue heartbeats before it synchronizes. This prevents the
// server from making endless attempts to synchronize without any chance
// to succeed. We verify that the server is not trying to synchronize
// by checking that the last event is not the one associated with the
// synchronization attempt.
ASSERT_NE(service_->getLastEvent(), HAService::HA_SYNCING_FAILED_EVT);
ASSERT_NE(service_->getLastEvent(), HAService::HA_SYNCING_SUCCEEDED_EVT);
// Startup the partner.
// We haven't been running heartbeats so we have to manually set the
// partner's state to something other than 'unavailable'.
// Run the syncing state handler.
// We should see no synchronization attempts because the server is paused
// in this state.
EXPECT_NE(service_->getLastEvent(), HAService::HA_SYNCING_FAILED_EVT);
EXPECT_NE(service_->getLastEvent(), HAService::HA_SYNCING_SUCCEEDED_EVT);
// Unpause the state machine.
// Retry the test. It should now transition to the ready state.
// This time the server should have synchronized.
EXPECT_EQ(HAService::HA_SYNCING_SUCCEEDED_EVT, service_->getLastEvent());
// This test verifies that the server takes ownership of the given scopes
// and whether the DHCP service is disabled or enabled in certain states.
TEST_F(HAServiceStateMachineTest, scopesServingLoadBalancing) {
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