TestRaft_follower_recv_appendentries_delete_entries_if_conflict_with_new_entries problem
tinymindxx opened this issue · 2 comments
tinymindxx commented
in Test_server.c, function TestRaft_follower_recv_appendentries_delete_entries_if_conflict_with_new_entries my be some problem.
void TestRaft_follower_recv_appendentries_delete_entries_if_conflict_with_new_entries(
CuTest * tc)
{
msg_appendentries_t ae;
msg_appendentries_response_t aer;
void *r = raft_new();
raft_add_node(r, NULL, 1, 1);
raft_add_node(r, NULL, 2, 0);
raft_set_current_term(r, 1);
char* strs[] = {"111", "222", "333"};
termid of entries in log are 1
raft_entry_t *ety_appended = __entries_for_conflict_tests(tc, r, strs);
pass a appendentry that is newer */
msg_entry_t mety = {};
memset(&ae, 0, sizeof(msg_appendentries_t));
ae.term = 2;
prev_log_idx is 1 and prev_termid is 1 ,so there is no conflict with entries in log. maybe ae.prev_log_term should change to 2
ae.prev_log_idx = 1;
ae.prev_log_term = 1;
this entry termid is 0, so conflict with previous one
/* include one entry */
memset(&mety, 0, sizeof(msg_entry_t));
char *str4 = "444";
mety.data.buf = str4;
mety.data.len = 3;
mety.id = 4;
ae.entries = &mety;
ae.n_entries = 1;
raft_recv_appendentries(r, raft_get_node(r, 2), &ae, &aer);
CuAssertTrue(tc, 1 == aer.success);
CuAssertTrue(tc, 2 == raft_get_log_count(r));
CuAssertTrue(tc, NULL != (ety_appended = raft_get_entry_from_idx(r, 1)));
CuAssertTrue(tc, !strncmp(ety_appended->data.buf, strs[0], 3));
}
wonder if this is a mistake or my understanding error? thanks !
tinymindxx commented
sorry, this is my understanding error.
willemt commented
Sorry it took me this long to respond.
I've improved the tests so that it's easier to read.
Thanks for highlighting this to me :)