Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new states in WarmState Adapter. #905

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
6 changes: 5 additions & 1 deletion common/warm_restart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ const WarmStart::WarmStartStateNameMap WarmStart::warmStartStateNameMap =
{REPLAYED, "replayed"},
{RECONCILED, "reconciled"},
{WSDISABLED, "disabled"},
{WSUNKNOWN, "unknown"}
{WSUNKNOWN, "unknown"},
{FROZEN, "frozen"},
{QUIESCENT, "quiescent"},
{CHECKPOINTED, "checkpointed"},
{FAILED, "failed"}
};

const WarmStart::DataCheckStateNameMap WarmStart::dataCheckStateNameMap =
Expand Down
4 changes: 4 additions & 0 deletions common/warm_restart.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class WarmStart
RECONCILED,
WSDISABLED,
WSUNKNOWN,
FROZEN,
QUIESCENT,
CHECKPOINTED,
FAILED,
};

enum DataCheckState
Expand Down
43 changes: 43 additions & 0 deletions tests/warm_restart_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,49 @@ TEST(WarmRestart, getWarmStartTimer)
EXPECT_EQ(timer, 5000u);
}

TEST(WarmRestart, set_get_WarmStartState)
{
DBConnector stateDb("STATE_DB", 0, true);
Table stateWarmRestartTable(&stateDb, STATE_WARM_RESTART_TABLE_NAME);
Table stateWarmRestartEnableTable(&stateDb, STATE_WARM_RESTART_ENABLE_TABLE_NAME);

DBConnector configDb("CONFIG_DB", 0, true);
Table cfgWarmRestartTable(&configDb, CFG_WARM_RESTART_TABLE_NAME);

//Clean up warm restart state for testAppName and warm restart config for testDockerName
stateWarmRestartTable.del(testAppName);
cfgWarmRestartTable.del(testDockerName);

//Initialize WarmStart class for TestApp
WarmStart::initialize(testAppName, testDockerName, 0, true);

WarmStart::WarmStartState warmStartStates[] =
{
WarmStart::INITIALIZED,
WarmStart::RESTORED,
WarmStart::REPLAYED,
WarmStart::RECONCILED,
WarmStart::WSDISABLED,
WarmStart::WSUNKNOWN,
WarmStart::FROZEN,
WarmStart::QUIESCENT,
WarmStart::CHECKPOINTED,
WarmStart::FAILED,
};

for (const auto &currState : warmStartStates) {
WarmStart::setWarmStartState(testAppName, currState);

string state;
stateWarmRestartTable.hget(testAppName, "state", state);
EXPECT_EQ(state, WarmStart::warmStartStateNameMap()->at(currState).c_str());

WarmStart::WarmStartState ret_state;
WarmStart::getWarmStartState(testAppName, ret_state);
EXPECT_EQ(ret_state, currState);
}
}

TEST(WarmRestart, set_get_DataCheckState)
{
DBConnector stateDb("STATE_DB", 0, true);
Expand Down
Loading