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

chore: test peer connection management #3049

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Ivansete-status
Copy link
Collaborator

@Ivansete-status Ivansete-status commented Sep 23, 2024

Description

Enhance reconnect logic and fix reconnect tests.
The important point is that it is necessary to set a port different than zero in tests.

Changes

Issue

closes

@Ivansete-status Ivansete-status changed the title Test peer connection management chore: test peer connection management Sep 23, 2024
Copy link

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:3049

Built from 6289957

Copy link
Contributor

@gabrielmer gabrielmer left a comment

Choose a reason for hiding this comment

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

Looks amazing! Thanks so much!

Added a small question :)

Comment on lines +625 to +626
reconnectDurationWithBackoffPeriod >
(reconnectDuration + backoffPeriod.seconds.float)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand why this is true. Shouldn't they be theoretically equal, but in practice any of them be longer than the other one?

Or in other words, why reconnectDuration + backoffPeriod.seconds.float can't be greater than reconnectDurationWithBackoffPeriod?

Copy link
Collaborator Author

@Ivansete-status Ivansete-status Sep 23, 2024

Choose a reason for hiding this comment

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

Not sure I understand why this is true. Shouldn't they be theoretically equal, but in practice any of them be longer than the other one?

Or in other words, why reconnectDuration + backoffPeriod.seconds.float can't be greater than reconnectDurationWithBackoffPeriod?

Actually, in both cases we are doing the same operation but, in when the backoff time assigned is != 0, then we add this extra block:

    if backoffTime > ZeroDuration:
      debug "Backing off before reconnect",
        peerId = peerInfo.peerId, backoffTime = backoffTime
      # We disconnected recently and still need to wait for a backoff period before connecting
      await sleepAsync(backoffTime)

... where we are adding an extra backoffTime plus the time spent in the debug call plus the if statement. Hence, the > condition should happen.

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.

3 participants