-
Notifications
You must be signed in to change notification settings - Fork 44
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
Write assertions for logged errors #1150
Comments
Some tracing log spans were missing. In adition to that we were using new spans to log requests and responses instead of using the span provided by the TraceLayer. That enables to join all the log events related tho the same requests. This fix is needed to contunie with this issue: torrust#1150 Becuase it allos to use a "request-id" header to identify logs. We can write log assertions by mathich lines with the request-id used in the request. For example, it yo make this request: ```console curl -H "x-request-id: YOUR_REQUEST_ID" http://0.0.0.0:1212/api/v1/stats?token=InvalidToken ``` This is the new output (which was missing before this change): ```output 2024-12-23T17:53:06.530704Z INFO request{method=GET uri=/api/v1/stats?token=InvalidToken version=HTTP/1.1}: API: request method=GET uri=/api/v1/stats?token=InvalidToken request_id=YOUR_REQUEST_ID 2024-12-23T17:53:06.530777Z ERROR request{method=GET uri=/api/v1/stats?token=InvalidToken version=HTTP/1.1}: API: response latency_ms=0 status_code=500 Internal Server Error request_id=YOUR_REQUEST_ID 2024-12-23T17:53:06.530785Z ERROR request{method=GET uri=/api/v1/stats?token=InvalidToken version=HTTP/1.1}: API: response failed failure_classification=Status code: 500 Internal Server Error latency=0 ms ``` As you can see. now we have the "request_id=YOUR_REQUEST_ID" field which can be used to identify the test that made the request.
You can run And to run only one |
Test producing errors in logs:
|
Updated list of tests producing errors in logs (22 in total): API (19):
HTTP Tracker:
UDP Tracker:
cc @da2ce7 |
97233f5 fix: missing logs for HTTP requests (Jose Celano) Pull request description: Relates to: - #1150 - #1152 Some log lines (tracing spans) were missing. In addition to that, we were using new spans to log requests and responses instead of using the span provided by the `TraceLayer`. That enables you to join all the log events related to the same request. This fix is needed to continue with this issue: #1150 Because it allows the use of a "request-id" header to identify logs. We can write log assertions by matching lines with the `request-id` used in the request. For example, if you make this request: ```console curl -H "x-request-id: YOUR_REQUEST_ID" http://0.0.0.0:1212/api/v1/stats?token=InvalidToken ``` This is the new output (which was missing before this change): ```output 2024-12-23T17:53:06.530704Z INFO request{method=GET uri=/api/v1/stats?token=InvalidToken version=HTTP/1.1}: API: request method=GET uri=/api/v1/stats?token=InvalidToken request_id=YOUR_REQUEST_ID 2024-12-23T17:53:06.530777Z ERROR request{method=GET uri=/api/v1/stats?token=InvalidToken version=HTTP/1.1}: API: response latency_ms=0 status_code=500 Internal Server Error request_id=YOUR_REQUEST_ID 2024-12-23T17:53:06.530785Z ERROR request{method=GET uri=/api/v1/stats?token=InvalidToken version=HTTP/1.1}: API: response failed failure_classification=Status code: 500 Internal Server Error latency=0 ms ``` As you can see, now we have the "request_id=YOUR_REQUEST_ID" field, which can be used to identify the test that made the request and write a log assertion for that concrete expected line. ACKs for top commit: josecelano: ACK 97233f5 Tree-SHA512: 075a3cdeafa735d4a263c942b34594049adc9d42ed5e8a1bef043ffea394bfdae7cf109928f1311d4589f40804c72ebe71c66d6ec5380f5ce472ba9ba5304ad5
You can run a single test with:
|
All subtasks implemented. |
Relates to: #1069
Implement after: #1146
Some tests produce errors in logs. There are expected errors:
cargo test -- --nocapture | grep "ERROR"
We want to add assertions for them.
After merging this PR, we will be able to capture logs in tests.
This issue is better implemented after this one.
Subtasks
Errors in test execution output
These are the three types of errors:
Tracker API:
The tracker API returns a 500 response on some endpoints, in spite of not being a server error.
Whitelist:
UDP connection cookie:
The text was updated successfully, but these errors were encountered: