From 36f75cf06296082794ece180a282b1bde5d9910c Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Fri, 12 Jun 2015 13:21:11 -0700 Subject: [PATCH] rafthttp: use buffered channel as recv/prop chan So it ensures that the message will not be discarded because the receive side has not been ready, which happens easily in multiple core test. Use log.fatal instead of log.error. The test exits when there is something wrong because the error may affect following test cases. --- rafthttp/stream_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rafthttp/stream_test.go b/rafthttp/stream_test.go index e42326482..bdc7debf4 100644 --- a/rafthttp/stream_test.go +++ b/rafthttp/stream_test.go @@ -221,8 +221,8 @@ func TestStreamReaderDialDetectUnsupport(t *testing.T) { // TestStream tests that streamReader and streamWriter can build stream to // send messages between each other. func TestStream(t *testing.T) { - recvc := make(chan raftpb.Message) - propc := make(chan raftpb.Message) + recvc := make(chan raftpb.Message, streamBufSize) + propc := make(chan raftpb.Message, streamBufSize) msgapp := raftpb.Message{ Type: raftpb.MsgApp, From: 2, @@ -294,10 +294,10 @@ func TestStream(t *testing.T) { select { case m = <-tt.wc: case <-time.After(time.Second): - t.Errorf("#%d: failed to receive message from the channel", i) + t.Fatalf("#%d: failed to receive message from the channel", i) } if !reflect.DeepEqual(m, tt.m) { - t.Errorf("#%d: message = %+v, want %+v", i, m, tt.m) + t.Fatalf("#%d: message = %+v, want %+v", i, m, tt.m) } } }