Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Willemt Raft
Commits
d1885191
Commit
d1885191
authored
Jan 10, 2018
by
Willem Thiart
Browse files
Fixes #49
parent
d620a9fd
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/test_snapshotting.c
View file @
d1885191
...
@@ -562,47 +562,3 @@ void TestRaft_recv_entry_fails_if_snapshot_in_progress(CuTest* tc)
...
@@ -562,47 +562,3 @@ void TestRaft_recv_entry_fails_if_snapshot_in_progress(CuTest* tc)
ety
.
type
=
RAFT_LOGTYPE_ADD_NODE
;
ety
.
type
=
RAFT_LOGTYPE_ADD_NODE
;
CuAssertIntEquals
(
tc
,
RAFT_ERR_SNAPSHOT_IN_PROGRESS
,
raft_recv_entry
(
r
,
&
ety
,
&
cr
));
CuAssertIntEquals
(
tc
,
RAFT_ERR_SNAPSHOT_IN_PROGRESS
,
raft_recv_entry
(
r
,
&
ety
,
&
cr
));
}
}
void
TxestRaft_full_snapshot
(
CuTest
*
tc
)
{
raft_cbs_t
funcs
=
{
.
persist_term
=
__raft_persist_term
,
.
send_appendentries
=
__raft_send_appendentries
,
};
void
*
r
=
raft_new
();
raft_set_callbacks
(
r
,
&
funcs
,
NULL
);
msg_entry_response_t
cr
;
raft_add_node
(
r
,
NULL
,
1
,
1
);
raft_add_node
(
r
,
NULL
,
2
,
0
);
/* I am the leader */
raft_set_state
(
r
,
RAFT_STATE_LEADER
);
raft_set_current_term
(
r
,
1
);
CuAssertIntEquals
(
tc
,
0
,
raft_get_log_count
(
r
));
/* entry message */
msg_entry_t
ety
=
{};
ety
.
id
=
1
;
ety
.
data
.
buf
=
"entry"
;
ety
.
data
.
len
=
strlen
(
"entry"
);
/* receive entry */
raft_recv_entry
(
r
,
&
ety
,
&
cr
);
raft_set_commit_idx
(
r
,
1
);
CuAssertIntEquals
(
tc
,
1
,
raft_get_log_count
(
r
));
CuAssertIntEquals
(
tc
,
1
,
raft_get_num_snapshottable_logs
(
r
));
CuAssertIntEquals
(
tc
,
0
,
raft_begin_snapshot
(
r
));
raft_entry_t
*
_ety
;
int
i
=
raft_get_first_entry_idx
(
r
);
for
(;
i
<
raft_get_commit_idx
(
r
);
i
++
)
CuAssertIntEquals
(
tc
,
0
,
raft_poll_entry
(
r
,
&
_ety
));
CuAssertIntEquals
(
tc
,
0
,
raft_end_snapshot
(
r
));
CuAssertIntEquals
(
tc
,
0
,
raft_get_num_snapshottable_logs
(
r
));
CuAssertIntEquals
(
tc
,
1
,
raft_get_log_count
(
r
));
}
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