Skip to content

Commit

Permalink
rafthttp: test transport multiple transport removes
Browse files Browse the repository at this point in the history
  Unit test to verify multiple transport removes does not create an
  issue.

Signed-off-by: Austin Benoit <22805659+AustinBenoit@users.noreply.github.com>
  • Loading branch information
AustinBenoit committed Jul 28, 2022
1 parent 223b33f commit ff56da7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions server/etcdserver/api/rafthttp/transport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,25 @@ func TestTransportRemove(t *testing.T) {
}
}

func TestTransportRemoveIsIdempotent(t *testing.T) {
tr := &Transport{
LeaderStats: stats.NewLeaderStats(zaptest.NewLogger(t), ""),
streamRt: &roundTripperRecorder{},
peers: make(map[types.ID]Peer),
pipelineProber: probing.NewProber(nil),
streamProber: probing.NewProber(nil),
}

tr.AddPeer(1, []string{"http://localhost:2380"})
tr.RemovePeer(types.ID(1))
tr.RemovePeer(types.ID(1))
defer tr.Stop()

if _, ok := tr.peers[types.ID(1)]; ok {
t.Fatalf("senders[1] exists, want removed")
}
}

func TestTransportUpdate(t *testing.T) {
peer := newFakePeer()
tr := &Transport{
Expand Down

0 comments on commit ff56da7

Please sign in to comment.