Skip to content

Commit

Permalink
Fancy elections
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou committed Oct 25, 2023
1 parent 212cabf commit 5935a04
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 19 deletions.
30 changes: 21 additions & 9 deletions tests/raft_scenarios/fancy_election.1
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
nodes,0,1,2

# Node 2 is initially partitioned
connect,0,1

# Node 0 starts first, and begins sending messages first
# Node 0 starts first, and wins the first election
start_node
periodic_one,0,110
dispatch_all

# Add two more nodes
trust_node,1,1
trust_node,1,2
emit_signature,1
periodic_all,10
dispatch_all

state_all
# Commit reconfiguration
periodic_all,10
dispatch_all

# Three node network is ready
assert_is_primary,0
assert_is_backup,1
assert_is_backup,2
assert_state_sync

# Node 2 is initially partitioned
disconnect,0,2
disconnect,1,2

replicate,1,helloworld
emit_signature,1
Expand Down Expand Up @@ -65,8 +77,8 @@ dispatch_one,1
dispatch_one,2

# Node 1 appends a new committable entry to confirm its primaryship
replicate,2,ConfirmCommit
emit_signature,2
replicate,3,ConfirmCommit
emit_signature,3

# Node 1 sends an initial AppendEntries probe
periodic_one,1,10
Expand Down
41 changes: 31 additions & 10 deletions tests/raft_scenarios/fancy_election.2
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
# This scenario re-creates figure 8 from the Raft paper

nodes,0,1,2,3,4

connect,0,1
connect,0,2
connect,0,3
connect,0,4

# Node 0 starts first, becomes primary
# Node 0 starts first, and wins the first election
start_node
periodic_one,0,110
dispatch_all

# Add two more nodes
trust_node,1,1
trust_node,1,2
trust_node,1,3
trust_node,1,4
emit_signature,1
periodic_all,10
dispatch_all

# Commit reconfiguration
periodic_all,10
dispatch_all
periodic_all,10
dispatch_all

# Three node network is ready
assert_is_primary,0
assert_is_backup,1
assert_is_backup,2
assert_is_backup,3
assert_is_backup,4
assert_state_sync

# This scenario re-creates figure 8 from the Raft paper

disconnect,1,2
disconnect,1,3
disconnect,1,4
disconnect,2,3
disconnect,2,4
disconnect,3,4

# Node 0 appends a single entry, replicates it to all nodes
replicate,1,entry_1
Expand Down

0 comments on commit 5935a04

Please sign in to comment.