mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
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.
This commit is contained in:
parent
ea3c7d1d31
commit
36f75cf062
@ -221,8 +221,8 @@ func TestStreamReaderDialDetectUnsupport(t *testing.T) {
|
|||||||
// TestStream tests that streamReader and streamWriter can build stream to
|
// TestStream tests that streamReader and streamWriter can build stream to
|
||||||
// send messages between each other.
|
// send messages between each other.
|
||||||
func TestStream(t *testing.T) {
|
func TestStream(t *testing.T) {
|
||||||
recvc := make(chan raftpb.Message)
|
recvc := make(chan raftpb.Message, streamBufSize)
|
||||||
propc := make(chan raftpb.Message)
|
propc := make(chan raftpb.Message, streamBufSize)
|
||||||
msgapp := raftpb.Message{
|
msgapp := raftpb.Message{
|
||||||
Type: raftpb.MsgApp,
|
Type: raftpb.MsgApp,
|
||||||
From: 2,
|
From: 2,
|
||||||
@ -294,10 +294,10 @@ func TestStream(t *testing.T) {
|
|||||||
select {
|
select {
|
||||||
case m = <-tt.wc:
|
case m = <-tt.wc:
|
||||||
case <-time.After(time.Second):
|
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) {
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user