-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(tests): Make tests pass with cargo test
#23520
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
Conversation
cargo test
@jorgehermo9 this touches some tests you added in case you want to take a look |
@@ -329,6 +329,7 @@ async fn test_drop_receiver() { | |||
|
|||
#[tokio::test] | |||
#[cfg(unix)] | |||
#[cfg_attr(target_os = "macos", ignore)] // Flaky when running `cargo test` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we know the reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not, tried to debug briefly but didn't get anywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok no worries, we should create an issue and add a link to it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment wasn't addressed but the thread was resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was, I just never linked the issue to the PR. #23672
I didn't have any problem while running those tests on linux, could you point me some reproducible example, CI fail or something? It is very weird that we have this problem with |
I wonder if the utility itself hits a race condition. |
This is not failing on CI since CI is using
Not sure. I think we're hitting this issue since |
3fd15d6
to
23d2bd9
Compare
![]() I can't reproduce it, every test is working for me. Executed it a few times and didn't fail... Running it on Linux 6.15.6-arch1-1 If the problem is the utility, maybe we should include the lock in The usual way of atomically bind to a port is using the port number
https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.bind However, I'm hesitant of fixing it the way you did, with the lock placed there inside the tests. Maybe we should add a test_util primitive that both gets the address with |
Alternative, I think we should have Something like static ADDR_LOCK: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(()));
pub async fn next_addr_for_ip(ip: IpAddr) -> (MutexGuard,SocketAddr) {
let guard = ADDR_LOCK.lock().await;
let port = pick_unused_port(ip);
(guard,SocketAddr::new(ip, port))
} But I think tokio's We can use instead |
Sorry, I thought the issue was reproducible in Linux but it isn't. Going to run the test suite on Linux before merging this just to make sure there are no issues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. We can introduce a generic test coordinator component in the future to clean this up.
Waiting for an ubuntu run...
This reverts commit eed7a3878a5c0c74b3e759c8c470d42b353964d7.
|
Worth creating an issue so we can keep track of it. And as a FYI to the community. |
Summary
cargo test
would hang/fail on master both on MacOS and Linux.Vector configuration
NA
How did you test this PR?
cargo test
Change Type
Is this a breaking change?
Does this PR include user facing changes?
no-changelog
label to this PR.References
cargo test
sometimes fails to run on master #23189Notes
@vectordotdev/vector
to reach out to us regarding this PR.pre-push
hook, please see this template.cargo fmt --all
cargo clippy --workspace --all-targets -- -D warnings
cargo nextest run --workspace
(alternatively, you can runcargo test --all
)git merge origin master
andgit push
.Cargo.lock
), pleaserun
cargo vdev build licenses
to regenerate the license inventory and commit the changes (if any). More details here.