Commit 754b945f authored by yacovm's avatar yacovm
Browse files

[FAB-14424] Fix test flake TestMetrics

This change set fixes the test flake by ensuring that
we continuously send until the buffer overflow is reported.

Ran it 1000 times and it passes.

Change-Id: I2b1dec09457a16fbf8e15c79c88fb55ca6e6393e
Signed-off-by: default avataryacovm <>
parent 2240d5f3
Pipeline #1399 failed with stages
......@@ -1240,9 +1240,19 @@ func TestMetrics(t *testing.T) {
name: "MsgDropCount",
runTest: func(node1, node2 *clusterNode, testMetrics *testMetrics) {
blockRecv := make(chan struct{})
wasReported := func() bool {
select {
case <-blockRecv:
return true
return false
// When the drop count is reported, release the lock on the server side receive operation.
testMetrics.msgDropCount.AddStub = func(float642 float64) {
if !wasReported() {
node2.handler.On("OnConsensus", testChannel, node1.nodeInfo.ID, mock.Anything).Run(func(args mock.Arguments) {
......@@ -1254,11 +1264,13 @@ func TestMetrics(t *testing.T) {
assert.NoError(t, err)
stream := assertEventualEstablishStream(t, rm)
// Send 1 too many messages while the server side is not reading from the stream
for i := 0; i < node2.c.SendBufferSize+1; i++ {
// Send too many messages while the server side is not reading from the stream
for {
if wasReported() {
assert.Equal(t, []string{"host", node2.nodeInfo.Endpoint, "channel", testChannel},
assert.Equal(t, 1, testMetrics.msgDropCount.AddCallCount())
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment