Skip to content

Commit

Permalink
Fix the rest of the scenarios for startup at 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
achamayou committed Oct 30, 2023
1 parent 893c4a1 commit a40ce56
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 186 deletions.
19 changes: 11 additions & 8 deletions tests/raft_scenarios/bad_network
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
# Node 0 starts first, and wins the first election
start_node
periodic_one,0,110
dispatch_all
emit_signature,2

# Add two more nodes
trust_node,1,1
trust_node,1,2
emit_signature,1
trust_node,2,1
trust_node,2,2
emit_signature,2
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_state_sync

# An initial entry is written and successfully replicated
replicate,1,helloworld
emit_signature,1
replicate,2,helloworld
emit_signature,2

periodic_all,10
dispatch_all
Expand All @@ -34,8 +37,8 @@ state_all
assert_state_sync

# An additional entry takes much longer to replicate, as it is lost on bad connection between nodes
replicate,1,salutonmondo
emit_signature,1
replicate,2,salutonmondo
emit_signature,2

periodic_all,10
drop_pending,0
Expand Down
14 changes: 7 additions & 7 deletions tests/raft_scenarios/check_quorum
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Node 0 starts first, and wins the first election
start_node
periodic_one,0,110
dispatch_all
emit_signature,2

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

Expand All @@ -25,8 +25,8 @@ assert_is_backup,3
assert_state_sync

# An initial entry is written and successfully replicated
replicate,1,helloworld
emit_signature,1
replicate,2,helloworld
emit_signature,2

periodic_all,10
dispatch_all
Expand Down
12 changes: 6 additions & 6 deletions tests/raft_scenarios/election_while_reconfiguration
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
# quorums when a reconfiguration is in flight
# Note: This is a fix for the issue described in https://github.com/microsoft/CCF/issues/3948
start_node
periodic_one,0,110
dispatch_all
emit_signature,2

assert_is_primary,0

#Reconfiguration: add a new node
trust_node,1,1
trust_node,2,1

emit_signature,1
emit_signature,2
periodic_all,10
dispatch_all
assert_is_backup,1

# Reconfiguration: add three nodes
trust_nodes,1,2,3,4 # New configuration: C1=[0,1,2,3,4] in term 1 (quorum=3)
emit_signature,1
trust_nodes,2,2,3,4 # New configuration: C1=[0,1,2,3,4] in term 1 (quorum=3)
emit_signature,2
periodic_all,10

# New nodes first respond with NACKs as they don't have full history
Expand Down Expand Up @@ -55,7 +55,7 @@ state_all
assert_is_primary,2

# New primary appends a new committable entry to confirm its primaryship
emit_signature,2
emit_signature,3

periodic_all,10
dispatch_all
Expand Down
37 changes: 20 additions & 17 deletions tests/raft_scenarios/fancy_election.1
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# Node 0 starts first, and wins the first election
start_node
periodic_one,0,110
dispatch_all
emit_signature,2

# Add two more nodes
trust_node,1,1
trust_node,1,2
emit_signature,1
trust_node,2,1
trust_node,2,2
emit_signature,2
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
Expand All @@ -24,17 +27,17 @@ assert_state_sync
disconnect,0,2
disconnect,1,2

replicate,1,helloworld
emit_signature,1
replicate,2,helloworld
emit_signature,2
periodic_all,10
dispatch_all

# Build an uncommitted suffix
replicate,1,salutonmondo
replicate,1,hallo
replicate,1,hullo
replicate,1,ahoyhoy
emit_signature,1
replicate,2,salutonmondo
replicate,2,hallo
replicate,2,hullo
replicate,2,ahoyhoy
emit_signature,2

# Dispatch AppendEntries containing this suffix, which will be received by Node 1, making
# it committed (known by a majority of nodes), though its commit status remains unknown
Expand All @@ -51,10 +54,10 @@ dispatch_one,1
state_all

# Build a further suffix which is _not_ shared in time
replicate,1,z
replicate,1,zz
replicate,1,zzz
emit_signature,1
replicate,2,z
replicate,2,zz
replicate,2,zzz
emit_signature,2

state_all

Expand All @@ -77,8 +80,8 @@ dispatch_one,1
dispatch_one,2

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

# Node 1 sends an initial AppendEntries probe
periodic_one,1,10
Expand Down
28 changes: 14 additions & 14 deletions tests/raft_scenarios/fancy_election.2
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Node 0 starts first, and wins the first election
start_node
periodic_one,0,110
dispatch_all
emit_signature,2

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

Expand Down Expand Up @@ -36,17 +36,17 @@ disconnect,2,4
disconnect,3,4

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

periodic_all,10
dispatch_all

# Node 0 appends a second entry, which only reaches Node 1
disconnect_node,0
connect,0,1
replicate,1,entry_2
emit_signature,1
replicate,2,entry_2
emit_signature,2

periodic_all,10
dispatch_all
Expand All @@ -59,8 +59,8 @@ connect,4,2
periodic_one,4,110
dispatch_all

replicate,2,entry_3
emit_signature,2
replicate,3,entry_3
emit_signature,3

state_all

Expand Down Expand Up @@ -112,8 +112,8 @@ dispatch_all
state_all

# Not yet! We need node 4 to produce a new entry in its current term
replicate,4,entry_4
emit_signature,4
replicate,5,entry_4
emit_signature,5

periodic_all,10
dispatch_all
Expand Down
37 changes: 20 additions & 17 deletions tests/raft_scenarios/multi_election
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
# Node 0 starts first, and wins the first election
start_node
periodic_one,0,110
dispatch_all
emit_signature,2

# Add two more nodes
trust_node,1,1
trust_node,1,2
emit_signature,1
trust_node,2,1
trust_node,2,2
emit_signature,2
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_state_sync

replicate,1,helloworld
emit_signature,1
replicate,2,helloworld
emit_signature,2
periodic_all,10
dispatch_all

replicate,1,salutonmondo
emit_signature,1
replicate,2,salutonmondo
emit_signature,2
periodic_all,10
dispatch_all

Expand All @@ -47,8 +50,8 @@ assert_state_sync

# NB: Node 1 i now primary in term 2. There is no primary in term 1,
# and attempting to replicate in it will produce an error
replicate,2,my world now
emit_signature,2
replicate,3,my world now
emit_signature,3
periodic_all,10
dispatch_all

Expand All @@ -58,8 +61,8 @@ dispatch_all
state_all
assert_state_sync

replicate,2,im in charge
emit_signature,2
replicate,3,im in charge
emit_signature,3
periodic_all,10
dispatch_all

Expand All @@ -74,9 +77,9 @@ disconnect,0,1
disconnect,1,2

# While 1 was partitioned, it continued to receive transactions!
replicate,2,i think i am still in charge
replicate,2,i am going to continue like i am the primary
replicate,2,until i am told otherwise
replicate,3,i think i am still in charge
replicate,3,i am going to continue like i am the primary
replicate,3,until i am told otherwise

periodic_all,10
dispatch_all
Expand All @@ -102,8 +105,8 @@ periodic_all,10
dispatch_all

# Election has now succeeded, and new primary can replicate in term 3
replicate,3,look at me i am the primary now
emit_signature,3
replicate,4,look at me i am the primary now
emit_signature,4

periodic_all,10
dispatch_all
Expand Down
12 changes: 6 additions & 6 deletions tests/raft_scenarios/reconfiguration
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
start_node
periodic_one,0,110
dispatch_all
emit_signature,2

assert_is_primary,0

#Reconfiguration: add a new node
trust_node,1,1
trust_node,2,1

emit_signature,1
emit_signature,2
periodic_all,10
dispatch_all
assert_is_backup,1

# Reconfiguration: add two nodes at once that are necessary to
# commit reconfiguration entry itself
trust_nodes,1,2,3 # New configuration: [0, 1, 2, 3] in term 1
emit_signature,1
trust_nodes,2,2,3 # New configuration: [0, 1, 2, 3] in term 1
emit_signature,2
periodic_all,10
dispatch_one,0

Expand All @@ -32,7 +32,7 @@ dispatch_one,0 # Send a catchup
dispatch_one,2 # ACK the cactchup

state_all # 1 is now committed as new node 2 has acked
assert_commit_idx,0,4
assert_commit_idx,0,6

periodic_all,10
dispatch_all
Expand Down
Loading

0 comments on commit a40ce56

Please sign in to comment.