Skip to content

Commit

Permalink
Unit test flake when rpc server stream not closed (#2935)
Browse files Browse the repository at this point in the history
Testcase expects to fail SubmitRequest after
node server restarts, but if restart not closed
streams before sendSubmit submitted; test fails.

It is random failure. Introduced a delay between
restart and submitRequest.

Signed-off-by: Parameswaran Selvam <parselva@in.ibm.com>
  • Loading branch information
Param-S authored Sep 21, 2021
1 parent 0545ac8 commit 70ff46a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion orderer/common/cluster/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@ func TestSendSubmitWithReport(t *testing.T) {
node2.stop()
node2.resurrect()

/*
* allow the node2 to restart completely
* if restart not complete, the existing stream able to successfully send
* the next SubmitRequest which makes the testcase fails. Hence this delay
* required
*/
time.Sleep(time.Second * 5)

var wg2 sync.WaitGroup
wg2.Add(1)

reportSubmitFailed := func(err error) {
require.EqualError(t, err, io.EOF.Error())
defer wg2.Done()
require.EqualError(t, err, io.EOF.Error())
}

err = node1RPC.SendSubmit(node2.nodeInfo.ID, &orderer.SubmitRequest{Channel: testChannel, Payload: &common.Envelope{Payload: []byte("2")}}, reportSubmitFailed)
Expand Down

0 comments on commit 70ff46a

Please sign in to comment.