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

interop: Improve logging level of tests #114

Closed
wants to merge 3 commits into from

Conversation

jxs
Copy link
Member

@jxs jxs commented Jan 24, 2023

By reducing the redis container logs to warning, and changing the target of the rust ping test to stdout instead of stderr.

@jxs jxs changed the title Improve logging level interop: Improve logging level of tests Jan 24, 2023
@@ -78,7 +78,9 @@ where
let mut conn = client.get_async_connection().await?;

info!("Running ping test: {}", swarm.local_peer_id());
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
env_logger::Builder::from_env(Env::default().default_filter_or("info"))
.target(Target::Stdout)
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK, it is good unix behaviour to send logs to stderr. Why change to stdout?

Copy link
Member Author

@jxs jxs Jan 24, 2023

Choose a reason for hiding this comment

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

to make them available in the interop tests. Currently interop tests only show stdout see here.
I read a couple of discussions like this one as I also found it surprising that the default for env_logger was stderr but as I didn't see an industry wide status quo, so I thought it would be easier to just change the Rust tests, since the Go ones already log to stdout.

Copy link
Contributor

Choose a reason for hiding this comment

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

at least the “ping successful” should be on stdout. The rest can be on stderr. https://pubs.opengroup.org/onlinepubs/9699919799/functions/stderr.html

Copy link
Contributor

Choose a reason for hiding this comment

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

If ping successful is part of the test contract, we should probably be printing that on stdout with println. Logs should be on stderr IMO.

I am sure you thought about this @MarcoPolo: It would be nice if we could rely on the exit code instead of scanning stdout for a string. Would it make sense to push a listenerDone to redis and thus synchronise the shutdown between the two?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is untested but have you explored using depends-on to express the relationship between dialer and listener? If we tell docker compose that dialer depends on listener and have listener run an endless loop at the end, we may get a cleaner shutdown behaviour where only the dialer exits by itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be a little easier to parse JSON. But I don't have a preference here. Matching against output strings is only marginally more work. And it's a little nicer to see "Ping Successful: " then {"pingDuration": <duration>}. But this is purely subjective.

Happy to define the stdout schema to print a JSON result at the end.

Copy link
Contributor

Choose a reason for hiding this comment

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

What multiple values?

  1. RTT, as measured by the ping protocol
  2. Duration of the handshake

Copy link
Contributor

Choose a reason for hiding this comment

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

What multiple values?

thinking about it more I like the “leave listener around for a bit”. It removes a redis sync point and lets us use the exit code as source of truth.

I opened an issue: #115

Copy link
Contributor

@thomaseizinger thomaseizinger Jan 25, 2023

Choose a reason for hiding this comment

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

And it's a little nicer to see "Ping Successful: " then {"pingDuration": <duration>}.

Depending on how we define the JSON structure, the test runner can parse it and print something more human-focused :)

Copy link
Member

Choose a reason for hiding this comment

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

Following up on the concrete discussion for this pull request I suggest:

  • Logging to stderr
  • Print ping successful to stdout via println!.

Copy link
Member

@mxinden mxinden left a comment

Choose a reason for hiding this comment

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

Comment on logging to stderr, otherwise this looks good to me.

Thanks for the patch for the redis log level. Will make my life a lot easier.

@@ -78,7 +78,9 @@ where
let mut conn = client.get_async_connection().await?;

info!("Running ping test: {}", swarm.local_peer_id());
env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
env_logger::Builder::from_env(Env::default().default_filter_or("info"))
.target(Target::Stdout)
Copy link
Member

Choose a reason for hiding this comment

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

Following up on the concrete discussion for this pull request I suggest:

  • Logging to stderr
  • Print ping successful to stdout via println!.

@jxs
Copy link
Member Author

jxs commented Jan 26, 2023

Yeah also makes sense to me after reading the conversation, thanks for elaborating and researching @thomaseizinger and @MarcoPolo. Should we then also print stderr from the compose runner? As logs from the rust ping test will not be shown (can be done in another PR)

@MarcoPolo
Copy link
Contributor

Is it useful? We print stderr when there’s a failure. But only stdout on success.

@thomaseizinger
Copy link
Contributor

Is it useful? We print stderr when there’s a failure. But only stdout on success.

That is the way to go IMO. Quiet by default, noisy on failure.

@marten-seemann
Copy link
Contributor

Is it useful? We print stderr when there’s a failure. But only stdout on success.

That is the way to go IMO. Quiet by default, noisy on failure.

Judging from the experience with the QUIC interop runner, having nodes output (very) detailed logs by default has proved very useful in debugging failures, especially when you're debugging a failure involving an implementation you're not familiar with.

@MarcoPolo
Copy link
Contributor

Nodes should always output diagnostic logs. Just on stderr. If there's a failure we'll show stderr. If everything looks good, I'm currently thinking that the node simply output a json string in stdout {"pingRTT": <duration>}. This is inline with the purpose of stderr: https://pubs.opengroup.org/onlinepubs/9699919799/functions/stderr.html.

@thomaseizinger
Copy link
Contributor

Is it useful? We print stderr when there’s a failure. But only stdout on success.

That is the way to go IMO. Quiet by default, noisy on failure.

Judging from the experience with the QUIC interop runner, having nodes output (very) detailed logs by default has proved very useful in debugging failures, especially when you're debugging a failure involving an implementation you're not familiar with.

I am not sure whether you are agreeing or disagreeing with the quoted statement? :)

@marten-seemann
Copy link
Contributor

My general take on this:

  • Logs are useful. Let's encourage implementation to dial up the log level. No particular preference for stdout vs. stderr.
  • Not sure why we need the ping successful output. We get the success / fail bit from the exit code, no need to parse any output. Parsing stdout seems error prone.
  • Any test more sophisticated than a simple ping will want to export more results. These results might be measurements, or even binary files (e.g. a file downloaded via protocol X). I expect us to introduce a convention that nodes put all their output into a predefined directory, and the runner to run some validation / evaluation steps based on that output.

@thomaseizinger
Copy link
Contributor

Not sure why we need the ping successful output. We get the success / fail bit from the exit code, no need to parse any output. Parsing stdout seems error prone.

See @MarcoPolo's comment here: #114 (comment)

  • Any test more sophisticated than a simple ping will want to export more results. These results might be measurements, or even binary files (e.g. a file downloaded via protocol X). I expect us to introduce a convention that nodes put all their output into a predefined directory, and the runner to run some validation / evaluation steps based on that output.

Without wanting to go too much OT: Another way of solving this would be to use stdout to output metadata and if a certain tests outputs a binary file, we can emit the path to it via stdout. Having said that, let's see what makes the most sense once we have a concrete requirement at hand.

@MarcoPolo
Copy link
Contributor

Cherry picked this commit, so closing this

@MarcoPolo MarcoPolo closed this Feb 8, 2023
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