-
Notifications
You must be signed in to change notification settings - Fork 132
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
Use pipes instead of file for logging in tests #3074
Conversation
120f300
to
64e94f3
Compare
Does this replace #3051 as a proper fix to the problem? |
Yes, this should solve that problem |
Please close #3051 then. |
This is ready for review, it is still a draft because it points to a patched jortestkit |
input-output-hk/jortestkit#59 merged, please update and rebase. |
log_location: PathBuf, | ||
error_lines: String, | ||
}, | ||
#[error("error in logs. Error lines: {error_lines}, full content:{logs}")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[error("error in logs. Error lines: {error_lines}, full content:{logs}")] | |
#[error("error in logs. Error lines: {error_lines}, full content: {logs}")] |
Not really sure it's useful to put the full JSON content in a single error printout. Maybe the test fixture handling this error can re-parse the logs
field and print the lines out nicely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could reuse log formatting from tracing_subscriber::fmt
but I'm not sure if it can be used independently, need to check.
210e52e
to
993ec4e
Compare
993ec4e
to
ee7bf92
Compare
The nightly failure should be fixed by #2888 |
Reading from file has some challenges associated with it. Namely on some Os reads can see torn writes and invalid utf-8 sequences. In addition, it is also pretty inefficient to read from file every time we want to access the logs. This solution is not the best one, we probably want to use some other library or method that allows us to read from stdout in a non blocking way.
Trait objects impose unnecessary bound for Sync/Send, so let's use generics instead. Add a dummy implementer of SyncNode to make using those types easier and almost identical as before.
Move selection of node inside the method to avoid having to clone the nodes. It would be impossible to use a reference since the argument must be a immutable reference but the method needs a mutable one, and they would be both from the same struct.
Change 'controller' method to consume self and add logger, since we do not read from file anymore. Client can then use a reference to the logger, but is important that there is only one logger that reads from the child stdout.
With the new architecture there is only one instace of logger per process, and this instance is controlled by the process itself. It also makes sense that the process is responsible for knowing when it started properly.
13efbc8
to
483f1ae
Compare
Use a pipe for reading logs from child processes instead of reading from files, because that caused synchronization problems.
The main problem is that reading from stdout is blocking, the current solution is to spawn a new thread that blocks on new messages and then send them back on a channel. It's not ideal because we spawn a new thread for each new process, but it should not be too much of a problem.
I also tried with async processes and output (
tokio::process
) but I had issues with I/O drivers not receiving updates in some cases and I dropped it.Another option could be to use some crate that exposes non future-based non blocking reads (mio only supports unix)