rafthttp: test transport multiple transport removes
Unit test to verify multiple transport removes does not create an
issue.
@@ -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{
