Fix bug related to the crate tracing-test
for writing assertions for logs
#1430
Labels
Testing
Checking Torrust
Relates to:
tracing-test
crate #1147Some time ago I tried to use the
tracing-test
for writing assertions for logs. I could it use it because I had a bug described here:#1148 (comment)
In the end, I decided to implement our own logging setup for testing, I copied part of the code from the
tracing-test
:https://github.com/dbrgn/tracing-test/blob/main/tracing-test/src/subscriber.rs
That was included here:
https://github.com/torrust/torrust-tracker/blob/develop/packages/test-helpers/src/logging.rs
However I limited the buffer because I was planning to use it also in production.
I think I decided to copy because it gives us more control on the logging setup. If I remember well, the crate does its own initialization. And there's not much code.
One thing I could not make it work was using an span to identify logs for the tests we are writing the log assertions. It described on:
#1148 (comment)
We are using natural identifiers in the log lines to identify the logs related to the test we are running. For example the "request id".
@da2ce7 has opened an PR that might solve the problem. I guess we can test it adding a new test like this:
It seems blocking functions could be the problem but I don't think so. As I mentioned in this comment I think the problem could be
spans
are not into the spawned threads when we run the test environments.This is the PR opened by @da2ce7
I would keep our logging setup that gives us more flexibility but I would try to fix the problem using spans to identify logs for a tests.
cc @dbrgn
The text was updated successfully, but these errors were encountered: