Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Willemt Raft
Commits
103aeaaa
Commit
103aeaaa
authored
Nov 15, 2015
by
Willem Thiart
Browse files
Refactor test to use 5 nodes
parent
760b29fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_server.c
View file @
103aeaaa
...
...
@@ -1683,6 +1683,9 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori
void
*
r
=
raft_new
();
raft_add_node
(
r
,
(
void
*
)
1
,
1
);
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
);
/* I'm the leader */
...
...
@@ -1709,16 +1712,16 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori
/* FIRST entry log application */
/* send appendentries -
* server will be waiting for response */
raft_send_appendentries
(
r
,
0
);
raft_send_appendentries
(
r
,
1
);
raft_send_appendentries
(
r
,
2
);
/* receive mock success responses */
aer
.
term
=
1
;
aer
.
success
=
1
;
aer
.
current_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
);
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 */
CuAssertIntEquals
(
tc
,
1
,
raft_get_commit_idx
(
r
));
raft_periodic
(
r
,
1
);
...
...
@@ -1727,16 +1730,16 @@ void TestRaft_leader_recv_appendentries_response_increase_commit_idx_when_majori
/* SECOND entry log application */
/* send appendentries -
* server will be waiting for response */
raft_send_appendentries
(
r
,
0
);
raft_send_appendentries
(
r
,
1
);
raft_send_appendentries
(
r
,
2
);
/* receive mock success responses */
aer
.
term
=
1
;
aer
.
success
=
1
;
aer
.
current_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
);
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 */
CuAssertIntEquals
(
tc
,
2
,
raft_get_commit_idx
(
r
));
raft_periodic
(
r
,
1
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment