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

fix(iroh-net): Fix some flaky magicsock tests #2034

Merged
merged 10 commits into from
Feb 21, 2024
Merged

Conversation

flub
Copy link
Contributor

@flub flub commented Feb 20, 2024

Description

Fix flaky tests in iroh-net (hopefully). The main issue was that the
testing code meshing together the sockets had a race-condition and
would sometimes fail.

Other improvements:

  • Logging improvements of various parts. These tests should now
    provide better info on failure.

  • Add alternative formatting of NodeId to use the short format.

  • Use NodeId in the public API, rather than PublicKey.

  • Move multi-threaded logging setup to the testing utils crate now
    that it can work properly. More code will have to switch.

Notes & open questions

The local_endpoints_change API is really difficult to use correctly.
Even the way this testing code uses it now is wrong. Instead of the
two current APIs there should be a single API which returns a stream.
I'll do this as a separate followup PR though.

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.

flub added 8 commits February 20, 2024 13:28
This works for me, but used to be flaky.  The way it is setup now
should give use useful logs in case it fails.
this is somewhat more useful now that we use nextest
This is likely the bug that made all of these tests flaky.  Let's see.
@flub flub changed the title Facelift the magicsock roundtrip test fix(iroh-net): Fix flaky magicsock tests Feb 21, 2024
@flub flub marked this pull request as ready for review February 21, 2024 12:37
@flub flub requested a review from dignifiedquire February 21, 2024 12:37
@@ -227,7 +227,11 @@ impl Debug for PublicKey {

impl Display for PublicKey {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", base32::fmt(self.as_bytes()))
if f.alternate() {
Copy link
Contributor

Choose a reason for hiding this comment

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

when/how is this triggered?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When you use a # formatter: {:#} (or {:#?} for Debug)

Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn’t it be the other way around then,? # prints longer more detailed messages

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could be rather tempted to switch this around and do the short format by default and the long format for alternate. That would reduce rather a lot of verbosity in our code.

Copy link
Contributor

Choose a reason for hiding this comment

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

the issue is that, even externally, we rely on to_string() roundtriping

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, it'd probably break things if this can't be round-tripped. so maybe we'll have to settle for this.

@flub flub changed the title fix(iroh-net): Fix flaky magicsock tests fix(iroh-net): Fix some flaky magicsock tests Feb 21, 2024
@flub flub enabled auto-merge February 21, 2024 15:43
@flub flub added this pull request to the merge queue Feb 21, 2024
Merged via the queue into main with commit df57623 Feb 21, 2024
21 checks passed
@flub flub deleted the flub/test-magicsock-roundtrip branch February 21, 2024 15:58
fubuloubu pushed a commit to ApeWorX/iroh that referenced this pull request Feb 21, 2024
## Description

Fix flaky tests in iroh-net (hopefully).  The main issue was that the
testing code meshing together the sockets had a race-condition and
would sometimes fail.

Other improvements:

- Logging improvements of various parts.  These tests should now
  provide better info on failure.

- Add alternative formatting of NodeId to use the short format.

- Use NodeId in the public API, rather than PublicKey.

- Move multi-threaded logging setup to the testing utils crate now
  that it can work properly.  More code will have to switch.

## Notes & open questions

The local_endpoints_change API is really difficult to use correctly.
Even the way this testing code uses it now is wrong.  Instead of the
two current APIs there should be a single API which returns a stream.
I'll do this as a separate followup PR though.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
matheus23 pushed a commit that referenced this pull request Nov 14, 2024
## Description

Fix flaky tests in iroh-net (hopefully).  The main issue was that the
testing code meshing together the sockets had a race-condition and
would sometimes fail.

Other improvements:

- Logging improvements of various parts.  These tests should now
  provide better info on failure.

- Add alternative formatting of NodeId to use the short format.

- Use NodeId in the public API, rather than PublicKey.

- Move multi-threaded logging setup to the testing utils crate now
  that it can work properly.  More code will have to switch.

## Notes & open questions

The local_endpoints_change API is really difficult to use correctly.
Even the way this testing code uses it now is wrong.  Instead of the
two current APIs there should be a single API which returns a stream.
I'll do this as a separate followup PR though.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants