diff options
author | Alan Conway <aconway@apache.org> | 2009-11-24 20:07:24 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2009-11-24 20:07:24 +0000 |
commit | a53255f11a8f8ee49aadec889981cea03934cc72 (patch) | |
tree | 680d2055af6297cfbf77e4eaa57f3c9f7d78f90d /qpid/cpp/src/tests/InitialStatusMap.cpp | |
parent | 892cfdf7c3578d27603c4ae4a54ac5aec101d521 (diff) | |
download | qpid-python-a53255f11a8f8ee49aadec889981cea03934cc72.tar.gz |
Support for restarting a persistent cluster.
Option --cluster-size=N: members wait for N members before recovering store.
Stores marked as clean/dirty. Automatically recover from clean store on restart.
Stores marked with UUID to detect errors.
Not yet implemented: consistency checks, manual recovery from all dirty stores.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@883842 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/InitialStatusMap.cpp')
-rw-r--r-- | qpid/cpp/src/tests/InitialStatusMap.cpp | 76 |
1 files changed, 74 insertions, 2 deletions
diff --git a/qpid/cpp/src/tests/InitialStatusMap.cpp b/qpid/cpp/src/tests/InitialStatusMap.cpp index c3587965e5..e6a3ec1620 100644 --- a/qpid/cpp/src/tests/InitialStatusMap.cpp +++ b/qpid/cpp/src/tests/InitialStatusMap.cpp @@ -26,6 +26,7 @@ using namespace std; using namespace qpid::cluster; using namespace qpid::framing; +using namespace qpid::framing::cluster; using namespace boost::assign; namespace qpid { @@ -35,8 +36,19 @@ QPID_AUTO_TEST_SUITE(InitialStatusMapTestSuite) typedef InitialStatusMap::Status Status; -Status activeStatus(const Uuid& id=Uuid()) { return Status(ProtocolVersion(), true, false, id, 0, ""); } -Status newcomerStatus(const Uuid& id=Uuid()) { return Status(ProtocolVersion(), false, false, id, 0, ""); } +Status activeStatus(const Uuid& id=Uuid()) { + return Status(ProtocolVersion(), 0, true, id, + STORE_STATE_NO_STORE, Uuid(), Uuid()); +} + +Status newcomerStatus(const Uuid& id=Uuid()) { + return Status(ProtocolVersion(), 0, false, id, + STORE_STATE_NO_STORE, Uuid(), Uuid()); +} + +Status storeStatus(bool active, StoreState state, Uuid start=Uuid(), Uuid stop=Uuid()) { + return Status(ProtocolVersion(), 0, active, Uuid(), state, start, stop); +} QPID_AUTO_TEST_CASE(testFirstInCluster) { // Single member is first in cluster. @@ -173,6 +185,66 @@ QPID_AUTO_TEST_CASE(testInitialSize) { BOOST_CHECK(map.isComplete()); } +QPID_AUTO_TEST_CASE(testAllCleanNoUpdate) { + InitialStatusMap map(MemberId(0), 3); + map.configChange(list_of<MemberId>(0)(1)(2)); + map.received(MemberId(0), storeStatus(false, STORE_STATE_CLEAN_STORE)); + map.received(MemberId(1), storeStatus(false, STORE_STATE_CLEAN_STORE)); + map.received(MemberId(2), storeStatus(false, STORE_STATE_CLEAN_STORE)); + BOOST_CHECK(!map.isUpdateNeeded()); +} + +QPID_AUTO_TEST_CASE(testAllEmptyNoUpdate) { + InitialStatusMap map(MemberId(0), 3); + map.configChange(list_of<MemberId>(0)(1)(2)); + map.received(MemberId(0), storeStatus(false, STORE_STATE_EMPTY_STORE)); + map.received(MemberId(1), storeStatus(false, STORE_STATE_EMPTY_STORE)); + map.received(MemberId(2), storeStatus(false, STORE_STATE_EMPTY_STORE)); + BOOST_CHECK(map.isComplete()); + BOOST_CHECK(!map.isUpdateNeeded()); +} + +QPID_AUTO_TEST_CASE(testAllNoStoreNoUpdate) { + InitialStatusMap map(MemberId(0), 3); + map.configChange(list_of<MemberId>(0)(1)(2)); + map.received(MemberId(0), storeStatus(false, STORE_STATE_NO_STORE)); + map.received(MemberId(1), storeStatus(false, STORE_STATE_NO_STORE)); + map.received(MemberId(2), storeStatus(false, STORE_STATE_NO_STORE)); + BOOST_CHECK(map.isComplete()); + BOOST_CHECK(!map.isUpdateNeeded()); +} + +QPID_AUTO_TEST_CASE(testDirtyNeedUpdate) { + InitialStatusMap map(MemberId(0), 3); + map.configChange(list_of<MemberId>(0)(1)(2)); + map.received(MemberId(0), storeStatus(false, STORE_STATE_DIRTY_STORE)); + map.received(MemberId(1), storeStatus(false, STORE_STATE_CLEAN_STORE)); + map.received(MemberId(2), storeStatus(false, STORE_STATE_CLEAN_STORE)); + BOOST_CHECK(map.transitionToComplete()); + BOOST_CHECK(map.isUpdateNeeded()); +} + +QPID_AUTO_TEST_CASE(testEmptyNeedUpdate) { + InitialStatusMap map(MemberId(0), 3); + map.configChange(list_of<MemberId>(0)(1)(2)); + map.received(MemberId(0), storeStatus(false, STORE_STATE_EMPTY_STORE)); + map.received(MemberId(1), storeStatus(false, STORE_STATE_CLEAN_STORE)); + map.received(MemberId(2), storeStatus(false, STORE_STATE_CLEAN_STORE)); + BOOST_CHECK(map.transitionToComplete()); + BOOST_CHECK(map.isUpdateNeeded()); +} + +QPID_AUTO_TEST_CASE(testEmptyAlone) { + InitialStatusMap map(MemberId(0), 1); + map.configChange(list_of<MemberId>(0)); + map.received(MemberId(0), storeStatus(false, STORE_STATE_EMPTY_STORE)); + BOOST_CHECK(map.transitionToComplete()); + BOOST_CHECK(!map.isUpdateNeeded()); +} + +// FIXME aconway 2009-11-20: consistency tests for mixed stores, +// tests for manual intervention case. + QPID_AUTO_TEST_SUITE_END() }} // namespace qpid::tests |