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

feat(tests): Improve test_utils to warn about mutli-runtime tests #1280

Merged
merged 6 commits into from
Jul 21, 2023

Conversation

flub
Copy link
Contributor

@flub flub commented Jul 19, 2023

Description

This detects if setup_logging() is going to blow up in your face and warns
against it.

Also adds closed spans to the log output.

Notes & open questions

It works this time? I'm as surprised as anything.

It did not work, reverted this to be just the other improvements of the logging stuff under test.

Change checklist

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

This enables the test-local logging output also for multi-threaded
tests.  The usage is not as nice as the entire test needs to be
wrapped in an async block, but it works.
iroh-net/src/magicsock.rs Outdated Show resolved Hide resolved
@flub flub changed the title feat(tests): Provide test-local logging for multi-threaded tests feat(tests): Improve test_utils to warn about mutli-runtime tests Jul 19, 2023
let var = std::env::var_os("RUST_LOG");
let trace_log_layer = match var {
Some(_) => None,
None => Some(
tracing_subscriber::fmt::layer()
.with_span_events(FmtSpan::CLOSE)
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It also shows a log line when a span is closed. I find this really nice as you very clearly see things finish.

Copy link
Contributor

Choose a reason for hiding this comment

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

Every thing that makes spans more readable is welcome. By the way - is there a way to use RUST_LOG to get rid of the span info in each log line? I find it a bit overwhelming sometimes...

2023-07-19T12:47:00.734742Z DEBUG conn{name=magic-78c000c451139ad8}:derp.actor:recv_detail:client-connect{key=PublicKey(78c000c451139ad8a8a77e9b5fe752b18320a9c551c0959ee71a85f24c82de15)}: rustls::client::hs: Using ciphersuite TLS13_AES_256_GCM_SHA384    

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the way - is there a way to use RUST_LOG to get rid of the span info in each log line? I find it a bit overwhelming sometimes...

2023-07-19T12:47:00.734742Z DEBUG conn{name=magic-78c000c451139ad8}:derp.actor:recv_detail:client-connect{key=PublicKey(78c000c451139ad8a8a77e9b5fe752b18320a9c551c0959ee71a85f24c82de15)}: rustls::client::hs: Using ciphersuite TLS13_AES_256_GCM_SHA384    

Yeah, it is a lot of stuff. Though I find it very useful information. I sometimes wonder about making some kind of interactive tui to explore tracing output more interactively... but someone else will have to write it probably.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

though often you only have to go scan all the way to the right for the few things you care about. that's a little mitigating i guess.

@flub flub enabled auto-merge (squash) July 19, 2023 13:09
@flub
Copy link
Contributor Author

flub commented Jul 20, 2023

@dignifiedquire @rklaehn could I get either an LGTM or more changes requested?

@flub flub merged commit 62522dc into main Jul 21, 2023
@flub flub deleted the flub/multi-threaded-test-logging branch July 21, 2023 11:10
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.

3 participants