Skip to content
Snippets Groups Projects
Commit 32194610 authored by Kurdakov Alexander's avatar Kurdakov Alexander
Browse files

review fixes: add test cases to conf_chage

parent 2110034e
No related branches found
No related tags found
No related merge requests found
Pipeline #39646 passed
......@@ -306,7 +306,7 @@ mod tests {
macro_rules! p_with_tier {
(
$raft_id:literal,
$tier:literal,
$tier:ident,
$grade:ident
) => {{
......@@ -610,24 +610,26 @@ mod tests {
);
let mut tiers = HashMap::new();
let storage_tier = Tier {
name: "storage".into(),
const VOTER_TIER_NAME: &str = "voter";
const FOLLOWER_TIER_NAME: &str = "follower";
let voter_tier = Tier {
name: VOTER_TIER_NAME.into(),
replication_factor: 1,
can_vote: true,
};
let router_tier = Tier {
name: "router".into(),
name: FOLLOWER_TIER_NAME.into(),
replication_factor: 1,
can_vote: false,
};
tiers.insert(storage_tier.name.as_str(), &storage_tier);
tiers.insert(voter_tier.name.as_str(), &voter_tier);
tiers.insert(router_tier.name.as_str(), &router_tier);
assert_eq!(
cc_with_tiers(
&[
p_with_tier!(1, "storage", Online),
p_with_tier!(2, "router", Online),
p_with_tier!(1, VOTER_TIER_NAME, Online),
p_with_tier!(2, FOLLOWER_TIER_NAME, Online),
],
&[1],
&[2],
......@@ -640,8 +642,8 @@ mod tests {
assert_eq!(
cc_with_tiers(
&[
p_with_tier!(1, "storage", Online),
p_with_tier!(2, "router", Online),
p_with_tier!(1, VOTER_TIER_NAME, Online),
p_with_tier!(2, FOLLOWER_TIER_NAME, Online),
],
&[2],
&[1],
......@@ -650,5 +652,46 @@ mod tests {
// case when bootstrap leader from tier with falsy `can_vote`
cc![AddNode(1), RemoveNode(2), AddLearnerNode(2)]
);
assert_eq!(
cc_with_tiers(
&[
p_with_tier!(1, VOTER_TIER_NAME, Expelled),
p_with_tier!(2, FOLLOWER_TIER_NAME, Online),
],
&[1],
&[2],
&tiers
),
// remove expelled voter
cc![RemoveNode(1)]
);
assert_eq!(
cc_with_tiers(
&[
p_with_tier!(1, FOLLOWER_TIER_NAME, Expelled),
p_with_tier!(2, FOLLOWER_TIER_NAME, Online),
],
&[1],
&[2],
&tiers
),
// remove expelled follower
cc![RemoveNode(1)]
);
assert_eq!(
cc_with_tiers(
&[
p_with_tier!(1, VOTER_TIER_NAME, Online),
p_with_tier!(2, VOTER_TIER_NAME, Online),
],
&[],
&[1, 2],
&tiers
),
cc![AddNode(1), AddNode(2)]
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment