forked from lei.chen/myxce
feat(raft-sim-conformance): raft_sim_check_all first-failure composition (task 3.5)
This commit is contained in:
parent
a38d9a7271
commit
f0be46fb32
4 changed files with 171 additions and 1 deletions
|
|
@ -909,6 +909,34 @@ int raft_sim_check_state_machine_safety(const raft_sim_cluster_t *c)
|
|||
return 1; /* holds */
|
||||
}
|
||||
|
||||
raft_sim_invariant_t raft_sim_check_all(const raft_sim_cluster_t *c)
|
||||
{
|
||||
/* Evaluate the four invariants in the FIXED order required by Req 3.5 and
|
||||
* short-circuit on the FIRST violation, so the reported failing invariant is
|
||||
* deterministic. Each checker returns 1=holds / 0=violated. */
|
||||
if (!raft_sim_check_election_safety(c))
|
||||
return RAFT_SIM_INV_ELECTION_SAFETY;
|
||||
if (!raft_sim_check_log_matching(c))
|
||||
return RAFT_SIM_INV_LOG_MATCHING;
|
||||
if (!raft_sim_check_leader_completeness(c))
|
||||
return RAFT_SIM_INV_LEADER_COMPLETENESS;
|
||||
if (!raft_sim_check_state_machine_safety(c))
|
||||
return RAFT_SIM_INV_STATE_MACHINE_SAFETY;
|
||||
return RAFT_SIM_INV_NONE; /* all four hold */
|
||||
}
|
||||
|
||||
const char *raft_sim_invariant_name(raft_sim_invariant_t inv)
|
||||
{
|
||||
switch (inv) {
|
||||
case RAFT_SIM_INV_NONE: return "none";
|
||||
case RAFT_SIM_INV_ELECTION_SAFETY: return "election-safety";
|
||||
case RAFT_SIM_INV_LOG_MATCHING: return "log-matching";
|
||||
case RAFT_SIM_INV_LEADER_COMPLETENESS: return "leader-completeness";
|
||||
case RAFT_SIM_INV_STATE_MACHINE_SAFETY: return "state-machine-safety";
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
int raft_sim_restart_node(raft_sim_cluster_t *c, int node_idx)
|
||||
{
|
||||
if (node_idx < 0 || node_idx >= c->n)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue