Skip to content

fix(tests): use global tokio runtime for tests [NR-520774]#2163

Draft
sigilioso wants to merge 1 commit intomainfrom
fix/server-flaky-test
Draft

fix(tests): use global tokio runtime for tests [NR-520774]#2163
sigilioso wants to merge 1 commit intomainfrom
fix/server-flaky-test

Conversation

@sigilioso
Copy link
Contributor

Summary

This PR introduces a global helper to initialize the tokio runtime on unit tests. Additionally, it updates the HTTP Status Server shutdown: now it tries to stop both the server and the event-consumer even if the first stop operation fails.

Notes for reviewers

The #[serial] macro wasn't actually needed in the HTTP Status Server tests (it has been removed in this PR). When removing serial the test became more flaky and the issue was easy to reproduce using:

for i in {1..15}; do echo "=== Run $i ===" && cargo test --package newrelic_agent_control --lib http_server::runner::tests 2>&1 || break; done

We already had a global helper for integration tests although it wasn't used everywhere (the corresponding integration tests are also updated in this PR). Considering the tokio runtime documentation and the fact of that we use a single runtime in Agent Control code, it seems the right path to follow.

@sigilioso sigilioso requested a review from a team as a code owner February 9, 2026 08:10
@sigilioso
Copy link
Contributor Author

sigilioso commented Feb 9, 2026

There is something else 😓

image

I'll look into it!

@sigilioso sigilioso marked this pull request as draft February 9, 2026 08:31
@sigilioso
Copy link
Contributor Author

Reproducible locally with enough repetitions

for i in {1..50}; do echo "=== Run $i ===" && cargo test --package newrelic_agent_control --lib -- --skip on_host 2>&1 || break; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant