Skip to content

Commit

Permalink
Adding new states in WarmState Adapter.
Browse files Browse the repository at this point in the history
  • Loading branch information
divyagayathri-hcl committed Sep 5, 2024
1 parent aba0f66 commit f28b8d5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
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

0 comments on commit f28b8d5

Please sign in to comment.