فهرست منبع

rafthttp: avoid TestStream to use outdated stream

The original test code before fb4b0b5cf075212f79fcdfa58533915a29c0912d
doesn't work because reader side may update the
stream, while writer side writes message to the old stream and fails.

This PR removes unnecessary call to set term, and avoids this problem to
happen on term > 1 in the future.
Yicheng Qin 10 سال پیش
والد
کامیت
28342ae097
1فایلهای تغییر یافته به همراه1 افزوده شده و 4 حذف شده
  1. 1 4
      rafthttp/stream_test.go

+ 1 - 4
rafthttp/stream_test.go

@@ -274,11 +274,8 @@ func TestStream(t *testing.T) {
 		h.sw = sw
 
 		picker := mustNewURLPicker(t, []string{srv.URL})
-		sr := startStreamReader(&http.Transport{}, picker, tt.t, types.ID(1), types.ID(2), types.ID(1), newPeerStatus(types.ID(1)), recvc, propc, nil, 1)
+		sr := startStreamReader(&http.Transport{}, picker, tt.t, types.ID(1), types.ID(2), types.ID(1), newPeerStatus(types.ID(1)), recvc, propc, nil, tt.term)
 		defer sr.stop()
-		if tt.t == streamTypeMsgApp {
-			sr.updateMsgAppTerm(tt.term)
-		}
 		// wait for stream to work
 		var writec chan<- raftpb.Message
 		for {