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

In test envs shut down tracker immediately after finishing the test #1087

Open
josecelano opened this issue Nov 15, 2024 · 0 comments
Open
Labels
- Developer - Torrust Improvement Experience Optimization Make it Faster Testing Checking Torrust

Comments

@josecelano
Copy link
Member

In some tests, we run the tracker, for example:

        #[tokio::test]
        async fn should_fail_when_the_uploaded_param_is_invalid() {
            INIT.call_once(|| {
                tracing_stderr_init(LevelFilter::ERROR);
            });

            let env = Started::new(&configuration::ephemeral().into()).await;

            let mut params = QueryBuilder::default().query().params();

            let invalid_values = ["-1", "1.1", "a"];

            for invalid_value in invalid_values {
                params.set("uploaded", invalid_value);

                let response = Client::new(*env.bind_address()).get(&format!("announce?{params}")).await;

                assert_bad_announce_request_error_response(response, "invalid param value").await;
            }

            env.stop().await;
        }

When we stop the env (env.stop().await) we should shut it down immediately. It does not make sense to wait 90 seconds for tests.

#[instrument(skip(handle, rx_halt, message))]
pub async fn graceful_shutdown(handle: axum_server::Handle, rx_halt: tokio::sync::oneshot::Receiver<Halted>, message: String) {
    shutdown_signal_with_message(rx_halt, message).await;

    tracing::debug!("Sending graceful shutdown signal");
    handle.graceful_shutdown(Some(Duration::from_secs(90)));

    println!("!! shuting down in 90 seconds !!");

    loop {
        sleep(Duration::from_secs(1)).await;

        tracing::info!("remaining alive connections: {}", handle.connection_count());
    }
}

cc @da2ce7

@josecelano josecelano added - Developer - Torrust Improvement Experience Optimization Make it Faster Testing Checking Torrust labels Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Developer - Torrust Improvement Experience Optimization Make it Faster Testing Checking Torrust
Projects
None yet
Development

No branches or pull requests

1 participant