-
Notifications
You must be signed in to change notification settings - Fork 13
Workaround in order to fix flaky tests #1106
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
base: main
Are you sure you want to change the base?
Changes from all commits
fdd7056
fa522af
bd8fffe
19aac8e
49e8bfc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright 2025-Present Datadog, Inc. https://www.datadoghq.com/ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
pub const TEST_COLLECTOR_TIMEOUT_MS: u32 = 10_000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is later used as a duration. Just make it one here, and avoid the conversion later There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment explaining how this value was chosen |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
// Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
mod constants; | ||
pub mod modes; | ||
|
||
pub use constants::*; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really care either way, but any reason that |
||
|
||
use std::{collections::HashMap, env, ops::DerefMut, path::PathBuf, process, sync::Mutex}; | ||
|
||
use once_cell::sync::OnceCell; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,35 @@ use std::collections::HashMap; | |
use std::io::{Read, Write}; | ||
use std::path::Path; | ||
use std::process; | ||
use std::{fs, path::PathBuf}; | ||
use std::{ | ||
fs, | ||
path::PathBuf, | ||
time::{Duration, Instant}, | ||
}; | ||
|
||
use anyhow::Context; | ||
use bin_tests::{build_artifacts, ArtifactType, ArtifactsBuild, BuildProfile}; | ||
use serde_json::Value; | ||
|
||
use bin_tests::TEST_COLLECTOR_TIMEOUT_MS; | ||
|
||
fn check_file_existence(path: &Path, timeout: Duration) -> bool { | ||
let start = Instant::now(); | ||
|
||
loop { | ||
match path.exists() { | ||
true => return true, | ||
false => { | ||
if start.elapsed() > timeout { | ||
return false; | ||
} else { | ||
std::thread::sleep(Duration::from_millis(100)); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[test] | ||
#[cfg_attr(miri, ignore)] | ||
fn test_crash_tracking_bin_debug() { | ||
|
@@ -184,6 +207,11 @@ fn test_crash_tracking_bin( | |
); | ||
assert_eq!(Ok(""), String::from_utf8(stdout).as_deref()); | ||
|
||
assert!(check_file_existence( | ||
fixtures.crash_profile_path.as_path(), | ||
Duration::from_secs(TEST_COLLECTOR_TIMEOUT_MS as u64) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment above about making |
||
)); | ||
|
||
// Check the crash data | ||
let crash_profile = fs::read(fixtures.crash_profile_path) | ||
.context("reading crashtracker profiling payload") | ||
|
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.
I assume this should be fixed before merge?