Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Fix: Increment stats.MessagesSent in msgToStream() function #441

Merged
merged 8 commits into from
Sep 10, 2020

Conversation

wolneykien
Copy link
Contributor

See #440.

Extract the code that is common in TestMessageResendAfterError,
TestMessageSendTimeout and TestMessageSendNotSupportedResponse to a
separate function.
Let prepareNetwork() make simmetric setup with two `ErrHost`s
with two `impl` networks to be sure we test `impl` instances on
both ends.
The test shows we have a problem with `MessagesSent` counter.
Fixes the bug with incrementing `MessagesSent` counter only in
`SendMessage()` method if `impl`. Now it works for `MessageSender`
too.
@wolneykien wolneykien changed the title Devel/fixmsgsent Fix: Increment stats.MessagesSent in msgToStream() function Sep 9, 2020
@wolneykien
Copy link
Contributor Author

When working on the branch I've once got the following error on CircleCI:

Failed
=== RUN   TestSessionBetweenPeers
    TestSessionBetweenPeers: bitswap_with_sessions_test.go:127: uninvolved nodes should only receive two messages 4
--- FAIL: TestSessionBetweenPeers (0.89s)

Locally, I've got the same error 6-9 times out of 16 runs in a row and for the master branch too. So I think that the test is unstable.

@dirkmc
Copy link
Contributor

dirkmc commented Sep 10, 2020

That test is flaky, created an issue: #442

Copy link
Contributor

@dirkmc dirkmc left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! 👍

// Wait a little for MessagesRecvd counters to be updated
// after receiver.ReceiveMessage() returns. FIXME: Can we
// use some network event instead of a timer?
ctxwait, cancelwait := context.WithTimeout(ctx, 100*time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be possible to use bsnet.host.Network().Notify(listener) to listen for ClosedStream(n network.Network, v network.Stream).
Could you give that a shot? If it's more than half an hour of work no worries I think this is good enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was interesting enough. Now the receiver has listener network.Notifiee field that is used by prepareNetwork() to set up the listener before the network becomes active (that's important). Also I've found that every MessageSender needs to be closed ;) and added .Close() calls to all tests in the file.

@dirkmc
Copy link
Contributor

dirkmc commented Sep 10, 2020

Also thanks for refactoring to clean up the ipfs impl tests 💯

Added `listener network.Notifiee` to the `receiver` structure.
If a listener is specified then `prepareNetwork()` connects it
to the mock network it builds before making any connections.
Wait for all network streams are closed instead of just using a
timeout. The timeout of 5 s is still used as a deadline (it makes
the test to fail).
The `MessageSender` needs to be closed if we want all streams in
the network to be closed.
@wolneykien
Copy link
Contributor Author

However, it seems there is another unstable test out there:

Failed
=== RUN   TestCancelOneRequestDoesNotTerminateAnother
    TestCancelOneRequestDoesNotTerminateAnother: providerquerymanager_test.go:174: Collected all peers on cancelled peer, should have been cancelled immediately
--- FAIL: TestCancelOneRequestDoesNotTerminateAnother (0.01s)

@dirkmc
Copy link
Contributor

dirkmc commented Sep 10, 2020

Added an issue for the flaky test: ipfs/boxo#88

Copy link
Contributor

@dirkmc dirkmc left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM 👍

@dirkmc dirkmc merged commit bcf8541 into ipfs:master Sep 10, 2020
@aschmahmann aschmahmann mentioned this pull request Feb 18, 2021
73 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants