Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the flaky middleware unsubscribe test #1173

Merged
merged 3 commits into from
Aug 20, 2021

Conversation

vishalchangrani
Copy link
Contributor

@vishalchangrani vishalchangrani commented Aug 19, 2021

This passes on this branch locally while fails immediately on master:
go test -tags relic -run TestMiddlewareTestSuit ./network/test -v -race -count 10 -failfast

@codecov-commenter
Copy link

codecov-commenter commented Aug 20, 2021

Codecov Report

Merging #1173 (99c1e08) into master (4bcdeb1) will decrease coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1173      +/-   ##
==========================================
- Coverage   55.59%   55.57%   -0.03%     
==========================================
  Files         481      481              
  Lines       29449    29449              
==========================================
- Hits        16372    16366       -6     
- Misses      10844    10848       +4     
- Partials     2233     2235       +2     
Flag Coverage Δ
unittests 55.57% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
engine/consensus/approvals/caches.go 94.11% <0.00%> (-2.95%) ⬇️
...sus/approvals/assignment_collector_statemachine.go 47.11% <0.00%> (-1.93%) ⬇️
...nsensus/approvals/veryfing_assignment_collector.go 59.06% <0.00%> (-1.35%) ⬇️
cmd/util/ledger/migrations/storage_v4.go 41.56% <0.00%> (-0.61%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4bcdeb1...99c1e08. Read the comment docs.

@vishalchangrani vishalchangrani changed the title wip Fixing the flaky middleware unsubscribe test Aug 20, 2021
@vishalchangrani vishalchangrani marked this pull request as ready for review August 20, 2021 19:01

// first test that when both nodes are subscribed to the channel, the target node receives the message
err := m.mws[first].Publish(message1, testChannel)
assert.NoError(m.T(), err)

assert.Eventually(m.T(), func() bool {
return m.ov[last].AssertCalled(m.T(), "Receive", firstNode, mockery.Anything)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AssertCalled calls Fail if the assertion doesn't succeed. This caused the flakiness if the message was not delivered in 1 millisecond before the first call to AssertCalled. Subsequent calls may succeed but by then the test has already been marked as failed :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯

@vishalchangrani
Copy link
Contributor Author

bors merge

@bors
Copy link
Contributor

bors bot commented Aug 20, 2021

👎 Rejected by too few approved reviews

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense!
OK, is this true of other assert calls?
I'm worried about these in our code base:
https://gist.github.com/3eecce8d13fc60e45180039855171324


// first test that when both nodes are subscribed to the channel, the target node receives the message
err := m.mws[first].Publish(message1, testChannel)
assert.NoError(m.T(), err)

assert.Eventually(m.T(), func() bool {
return m.ov[last].AssertCalled(m.T(), "Receive", firstNode, mockery.Anything)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤯

@vishalchangrani
Copy link
Contributor Author

vishalchangrani commented Aug 20, 2021

This makes sense!
OK, is this true of other assert calls?
I'm worried about these in our code base:
https://gist.github.com/3eecce8d13fc60e45180039855171324

I think so - the AssertXXX calls eventually call testing.Errorf which marks the test as failed.
Hence this pattern of calling Eventually { AssertXXX} will not work. I will fix those in a different PR.

Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a ton! I recorded the leftovers in #1179

Copy link
Contributor

@yhassanzadeh13 yhassanzadeh13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@vishalchangrani
Copy link
Contributor Author

bors merge

bors bot added a commit that referenced this pull request Aug 20, 2021
1173: Fixing the flaky middleware unsubscribe test r=vishalchangrani a=vishalchangrani

This passes on this branch locally while fails immediately on master:
`go  test -tags relic -run TestMiddlewareTestSuit  ./network/test -v  -race -count 10 -failfast`

Co-authored-by: vishal <1117327+vishalchangrani@users.noreply.github.com>
Co-authored-by: Vishal <1117327+vishalchangrani@users.noreply.github.com>
@vishalchangrani vishalchangrani merged commit 0d10aa1 into master Aug 20, 2021
@vishalchangrani vishalchangrani deleted the vishal/flaky_middleware_test branch August 20, 2021 20:55
@bors
Copy link
Contributor

bors bot commented Aug 20, 2021

This PR was included in a batch that successfully built, but then failed to merge into master (it was a non-fast-forward update). It will be automatically retried.

bors bot added a commit that referenced this pull request Aug 20, 2021
1173: Fixing the flaky middleware unsubscribe test r=vishalchangrani a=vishalchangrani

This passes on this branch locally while fails immediately on master:
`go  test -tags relic -run TestMiddlewareTestSuit  ./network/test -v  -race -count 10 -failfast`

Co-authored-by: vishal <1117327+vishalchangrani@users.noreply.github.com>
Co-authored-by: Vishal <1117327+vishalchangrani@users.noreply.github.com>
@synzhu
Copy link
Contributor

synzhu commented Aug 20, 2021

Thanks @vishalchangrani !

@bors
Copy link
Contributor

bors bot commented Aug 20, 2021

Build failed:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants