Commit 103aeaaa authored by Willem Thiart's avatar Willem Thiart
Browse files

Refactor test to use 5 nodes

parent 760b29fe
...@@ -1683,6 +1683,9 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori ...@@ -1683,6 +1683,9 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori
void *r = raft_new(); void *r = raft_new();
raft_add_node(r, (void*)1, 1); raft_add_node(r, (void*)1, 1);
raft_add_node(r, (void*)2, 0); raft_add_node(r, (void*)2, 0);
raft_add_node(r, (void*)3, 0);
raft_add_node(r, (void*)4, 0);
raft_add_node(r, (void*)5, 0);
raft_set_callbacks(r, &funcs, sender); raft_set_callbacks(r, &funcs, sender);
/* I'm the leader */ /* I'm the leader */
...@@ -1709,16 +1712,16 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori ...@@ -1709,16 +1712,16 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori
/* FIRST entry log application */ /* FIRST entry log application */
/* send appendentries - /* send appendentries -
* server will be waiting for response */ * server will be waiting for response */
raft_send_appendentries(r, 0);
raft_send_appendentries(r, 1); raft_send_appendentries(r, 1);
raft_send_appendentries(r, 2);
/* receive mock success responses */ /* receive mock success responses */
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 1; aer.current_idx = 1;
aer.first_idx = 1; aer.first_idx = 1;
raft_recv_appendentries_response(r, 0, &aer);
CuAssertIntEquals(tc, 0, raft_get_commit_idx(r));
raft_recv_appendentries_response(r, 1, &aer); raft_recv_appendentries_response(r, 1, &aer);
CuAssertIntEquals(tc, 0, raft_get_commit_idx(r));
raft_recv_appendentries_response(r, 2, &aer);
/* leader will now have majority followers who have appended this log */ /* leader will now have majority followers who have appended this log */
CuAssertIntEquals(tc, 1, raft_get_commit_idx(r)); CuAssertIntEquals(tc, 1, raft_get_commit_idx(r));
raft_periodic(r, 1); raft_periodic(r, 1);
...@@ -1727,16 +1730,16 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori ...@@ -1727,16 +1730,16 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori
/* SECOND entry log application */ /* SECOND entry log application */
/* send appendentries - /* send appendentries -
* server will be waiting for response */ * server will be waiting for response */
raft_send_appendentries(r, 0);
raft_send_appendentries(r, 1); raft_send_appendentries(r, 1);
raft_send_appendentries(r, 2);
/* receive mock success responses */ /* receive mock success responses */
aer.term = 1; aer.term = 1;
aer.success = 1; aer.success = 1;
aer.current_idx = 2; aer.current_idx = 2;
aer.first_idx = 2; aer.first_idx = 2;
raft_recv_appendentries_response(r, 0, &aer);
CuAssertIntEquals(tc, 1, raft_get_commit_idx(r));
raft_recv_appendentries_response(r, 1, &aer); raft_recv_appendentries_response(r, 1, &aer);
CuAssertIntEquals(tc, 1, raft_get_commit_idx(r));
raft_recv_appendentries_response(r, 2, &aer);
/* leader will now have majority followers who have appended this log */ /* leader will now have majority followers who have appended this log */
CuAssertIntEquals(tc, 2, raft_get_commit_idx(r)); CuAssertIntEquals(tc, 2, raft_get_commit_idx(r));
raft_periodic(r, 1); raft_periodic(r, 1);
......
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