Repository navigation
Closed
Labels
Description
When you run the tests you see some errors in the stderror
test servers::api::v1::contract::context::torrent::should_allow_limiting_the_torrents_in_the_result ... ok
2024-11-01T09:27:25.702371Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::auth_key::should_fail_when_keys_cannot_be_reloaded ... ok
2024-11-01T09:27:25.711737Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
2024-11-01T09:27:25.713069Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::authentication::should_not_authenticate_requests_when_the_token_is_empty ... ok
2024-11-01T09:27:25.723461Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::authentication::should_not_authenticate_requests_when_the_token_is_missing ... ok
2024-11-01T09:27:25.725770Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
2024-11-01T09:27:25.746900Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
2024-11-01T09:27:25.749262Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::auth_key::should_fail_when_the_auth_key_cannot_be_generated ... ok
test servers::api::v1::contract::context::auth_key::should_allow_uploading_a_preexisting_auth_key ... ok
test servers::api::v1::contract::context::auth_key::should_allow_deleting_an_auth_key ... ok
2024-11-01T09:27:25.774618Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
2024-11-01T09:27:25.775134Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::auth_key::should_fail_when_the_auth_key_cannot_be_deleted ... ok
test servers::api::v1::contract::context::torrent::should_allow_getting_a_list_of_torrents_providing_infohashes ... ok
2024-11-01T09:27:25.797612Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::torrent::should_allow_getting_all_torrents ... ok
test servers::api::v1::contract::context::stats::should_allow_getting_tracker_statistics ... ok
test servers::api::v1::contract::authentication::should_allow_the_token_query_param_to_be_at_any_position_in_the_url_query ... ok
test servers::api::v1::contract::context::auth_key::deprecated_generate_key_endpoint::should_fail_generating_a_new_auth_key_when_the_key_duration_is_invalid ... ok
2024-11-01T09:27:26.242719Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::torrent::should_fail_while_getting_a_torrent_info_when_the_torrent_does_not_exist ... ok
2024-11-01T09:27:26.297102Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::whitelist::should_allow_reload_the_whitelist_from_the_database ... ok
test servers::api::v1::contract::context::whitelist::should_allow_whitelisting_a_torrent ... ok
test servers::api::v1::contract::context::whitelist::should_allow_removing_a_torrent_from_the_whitelist ... ok
2024-11-01T09:27:26.361616Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::whitelist::should_fail_when_the_whitelist_cannot_be_reloaded_from_the_database ... ok
2024-11-01T09:27:26.383337Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
2024-11-01T09:27:26.383617Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::auth_key::should_not_allow_deleting_an_auth_key_for_unauthenticated_users ... ok
2024-11-01T09:27:26.388780Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::auth_key::should_not_allow_generating_a_new_auth_key_for_unauthenticated_users ... ok
2024-11-01T09:27:26.391286Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::whitelist::should_fail_when_the_torrent_cannot_be_whitelisted ... ok
2024-11-01T09:27:26.401139Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::stats::should_not_allow_getting_tracker_statistics_for_unauthenticated_users ... ok
2024-11-01T09:27:26.407532Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::whitelist::should_fail_when_the_torrent_cannot_be_removed_from_the_whitelist ... ok
test servers::api::v1::contract::context::whitelist::should_not_fail_trying_to_remove_a_non_whitelisted_torrent_from_the_whitelist ... ok
2024-11-01T09:27:26.442571Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::auth_key::deprecated_generate_key_endpoint::should_not_allow_generating_a_new_auth_key_for_unauthenticated_users ... ok
2024-11-01T09:27:26.453664Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::auth_key::should_fail_generating_a_new_auth_key_when_the_key_duration_is_invalid ... ok
2024-11-01T09:27:26.472636Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::auth_key::should_not_allow_reloading_keys_for_unauthenticated_users ... ok
test servers::health_check_api::contract::health_check_endpoint_should_return_status_ok_when_there_is_no_services_registered ... ok
test servers::http::v1::contract::environment_should_be_started_and_stopped ... ok
2024-11-01T09:27:26.893709Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::torrent::should_not_allow_getting_a_torrent_info_for_unauthenticated_users ... ok
test servers::health_check_api::contract::udp::it_should_return_good_health_for_udp_service ... ok
test servers::http::v1::contract::configured_as_private::receiving_an_scrape_request::should_fail_if_the_key_query_param_cannot_be_parsed ... ok
2024-11-01T09:27:26.993979Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::torrent::should_not_allow_getting_torrents_for_unauthenticated_users ... ok
test servers::http::v1::contract::for_all_config_modes::receiving_an_announce_request::it_should_start_and_stop ... ok
test servers::http::v1::contract::configured_as_private::and_receiving_an_announce_request::should_fail_if_the_peer_has_not_provided_the_authentication_key ... ok
test servers::http::v1::contract::configured_as_private::and_receiving_an_announce_request::should_fail_if_the_key_query_param_cannot_be_parsed ... ok
test servers::api::v1::contract::context::whitelist::should_allow_whitelisting_a_torrent_that_has_been_already_whitelisted ... ok
2024-11-01T09:27:27.047456Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
test servers::api::v1::contract::context::whitelist::should_not_allow_whitelisting_a_torrent_for_unauthenticated_users ... ok
test servers::http::v1::contract::configured_as_whitelisted::and_receiving_an_announce_request::should_allow_announcing_a_whitelisted_torrent ... ok
test servers::http::v1::contract::configured_as_private::and_receiving_an_announce_request::should_respond_to_authenticated_peers ... ok
test servers::http::v1::contract::configured_as_private::and_receiving_an_announce_request::should_fail_if_the_peer_cannot_be_authenticated_with_the_provided_key ... ok
test servers::http::v1::contract::configured_as_private::receiving_an_scrape_request::should_return_the_zeroed_file_when_the_client_is_not_authenticated ... ok
test servers::http::v1::contract::configured_as_private::receiving_an_scrape_request::should_return_the_real_file_stats_when_the_client_is_authenticated ... ok
2024-11-01T09:27:27.110995Z ERROR tower_http::trace::on_failure: response failed, classification: Status code: 500 Internal Server Error, latency: 0 ms
at /home/josecelano/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tower-http-0.6.1/src/trace/on_failure.rs:93
You can run the tests with command 2>/dev/null, but we should disable that output in tracing when running the tests.
Activity
da2ce7 commentedon Nov 19, 2024
Hmmm... I think that having the
ERRORgo through to theSTDERRin tests is a good thing... For these cases we should idivitually look into each on, and see if the error is really an error, or it is limitation of our reporting, or we should lower the warning toWARN... or it is a real error, and we disable the tracing for that individual test, (with a comment why).mario-nt commentedon Nov 19, 2024
@da2ce7 I would add a new config option to set the tracing level for the tests in the toml file. And still have the
tracing_stderr_initfunction to override that tracing level on tests when needed, as I think having that function called in every test adds a bit of repeated code.Regarding having tracing on tests, I think it can be useful for development, but I think it is better if we just show an OK or FAIL result when running them, I will do some research on the topic anyway.
josecelano commentedon Nov 21, 2024
Hi @da2ce7 and @mario-nt, the reason those tests are returning a 500 error is to keep compatibility with the old API.
Before migrating to Axum, the previous API returned a 500 for all these cases. I decided not to break the contract in the migration and wait until the new API.
These are the cases in tests:
The tests are all from the API:
I think we should do what we agreed on in the meeting. We should:
For example, in this test:
We can change the test to something like:
We can start with the most straightforward implementation and see later whether we can extract this into a test helper or move the logic to the
configuration::ephemeral()factory. A helper seems like a good option because, in fact, login setup is done for the whole app, not for a specific service (API).I would fix all tests with this pattern to remove the errors. There are only a few of them.
josecelano commentedon Dec 9, 2024
Hi @mario-nt I'm working on a PR that will add more errors like these. I won't "hide" them in that PR to avoid conflicts with this issue. It's easier to fix all of them at the same time.
josecelano commentedon Dec 9, 2024
The error is this:
josecelano commentedon Dec 18, 2024
Hi @mario-nt, I'm also working on this. The
TestWriteris just to ignore output. I think we have to implement a Writer to capture the logs in tests.test: [torrust#1069] example of capturing tracing output
test: [torrust#1069] example of capturing tracing output
josecelano commentedon Dec 18, 2024
The errors come from the tower_http's struct TracerLayer that uses the DefaultOnFailure struct.
We can customize the error calling
.on_failure:I would override it even if we print the same message to avoid depending on the third-party error when writing assertions in tests. It's also easier to find the code when you see the error in logs.
The extra code:
test: [torrust#1069] example of capturing tracing output
josecelano commentedon Dec 20, 2024
I've opened a new PR, which is only one step toward fixing this issue.
josecelano commentedon Dec 23, 2024
There are new errors that were not included in the initial list, probably because they were added after opening this issue.
josecelano commentedon Dec 23, 2024
We can continue with this issue after merging this PR and implementing this issue. After that, we can add assertions to the tests where these errors are produced.
Anyway, after merging PR, the errors won't be shown unless you run tests with
cargo -- --nocapture.josecelano commentedon Dec 23, 2024
I've decided to create a new issue for adding assertions in tests for logged errors and close this PR with this PR because the errors will not be shown anymore after merging it.
Merge #1149: New feature: capture recent logs for testing (rework)