Commit 00053db7 authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Allow reducing a cluster into a single node

parent ec1ecbb8
Pipeline #508304 failed with stages
in 71 minutes and 14 seconds
......@@ -247,7 +247,7 @@ struct ReplicationStatus {
}
bool quorumUpToDate(LogIndex leaderLogSize) {
if(replicas.size() == 1) return false;
if(replicas.size() == 1) return true;
return calculateQuorumSize(replicas.size()) <= replicasUpToDate(leaderLogSize);
}
......
......@@ -599,6 +599,8 @@ TEST_F(SingleNodeInitially, BuildClusterFromSingle) {
int leaderID = getLeaderID();
if(leaderID == 1) break;
tunnel(1)->exec("raft-attempt-coup").get();
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
// commit a write
......@@ -606,5 +608,13 @@ TEST_F(SingleNodeInitially, BuildClusterFromSingle) {
// get a previous read
ASSERT_REPLY(tunnel(1)->exec("get", "entry-100"), "contents-100");
}
// remove #0
ASSERT_REPLY(tunnel(1)->exec("raft-remove-member", myself(0).toString()), "OK");
// commit one more write
ASSERT_REPLY(tunnel(1)->exec("set", "bbb", "123"), "OK");
// read
ASSERT_REPLY(tunnel(1)->exec("get", "entry-5"), "contents-5");
}
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