Skip to content

Commit

Permalink
replica_rac2: test piggybacked admitted vectors
Browse files Browse the repository at this point in the history
Epic: none
Release note: none
  • Loading branch information
pav-kv committed Sep 12, 2024
1 parent 253e0df commit 49e476c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
17 changes: 14 additions & 3 deletions pkg/kv/kvserver/kvflowcontrol/replica_rac2/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,9 +408,20 @@ func TestProcessorBasic(t *testing.T) {
var from, to uint64
d.ScanArgs(t, "from", &from)
d.ScanArgs(t, "to", &to)
// TODO(pav-kv): parse the admitted vector.
p.EnqueuePiggybackedAdmittedAtLeader(
roachpb.ReplicaID(from), kvflowcontrolpb.AdmittedState{})
require.Equal(t, p.opts.ReplicaID, roachpb.ReplicaID(to))

var term, index, pri int
d.ScanArgs(t, "term", &term)
d.ScanArgs(t, "index", &index)
d.ScanArgs(t, "pri", &pri)
require.Less(t, pri, int(raftpb.NumPriorities))
as := kvflowcontrolpb.AdmittedState{
Term: uint64(term),
Admitted: make([]uint64, raftpb.NumPriorities),
}
as.Admitted[pri] = uint64(index)

p.EnqueuePiggybackedAdmittedAtLeader(roachpb.ReplicaID(from), as)
return builderStr()

case "process-piggybacked-admitted":
Expand Down
20 changes: 7 additions & 13 deletions pkg/kv/kvserver/kvflowcontrol/replica_rac2/testdata/processor
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ HandleRaftReady:
.....

# Noop, since not the leader.
enqueue-piggybacked-admitted from=25 to=5
enqueue-piggybacked-admitted from=25 to=5 term=50 index=24 pri=0
----

# Noop.
Expand Down Expand Up @@ -489,29 +489,23 @@ HandleRaftReady:
.....

# Enqueue piggybacked admitted vector.
enqueue-piggybacked-admitted from=25 to=5
enqueue-piggybacked-admitted from=25 to=5 term=52 index=24 pri=0
----

# Process it.
process-piggybacked-admitted
# Enqueue another piggybacked admitted vector, it merges into the previous one.
enqueue-piggybacked-admitted from=25 to=5 term=52 index=25 pri=2
----
Replica.RaftMuAssertHeld
RangeController.AdmitRaftMuLocked(25, {Term:0 Admitted:[0 0 0 0]})

# Noop.
# Process it.
process-piggybacked-admitted
----
Replica.RaftMuAssertHeld

# Noop, since the replica id does not match.
enqueue-piggybacked-admitted from=25 to=6
----
RangeController.AdmitRaftMuLocked(25, {Term:52 Admitted:[24 0 25 0]})

# Noop.
process-piggybacked-admitted
----
Replica.RaftMuAssertHeld
RangeController.AdmitRaftMuLocked(25, {Term:0 Admitted:[0 0 0 0]})

# We are still the leader, now at a new term.
set-raft-state term=53
Expand Down Expand Up @@ -578,7 +572,7 @@ get-enabled-level
enabled-level: v1-encoding

# Noop.
enqueue-piggybacked-admitted from=25 to=5
enqueue-piggybacked-admitted from=25 to=5 term=52 index=24 pri=0
----

# Noop.
Expand Down

0 comments on commit 49e476c

Please sign in to comment.