Skip to content

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ variables:
# These are gitlab variables so that it's easier to do a manual deploy
# If these are set witih value and description, then it gives you UI elements
DOWNSTREAM_BRANCH:
value: "main"
value: "julio/trigger-release-pr"
Copy link
Contributor

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?

description: "downstream jobs are triggered on this branch"

include:
Expand Down
3 changes: 1 addition & 2 deletions bin_tests/src/bin/crashtracker_bin_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ mod unix {
use std::env;
use std::path::Path;

use bin_tests::TEST_COLLECTOR_TIMEOUT_MS;
use datadog_crashtracker::{
self as crashtracker, CrashtrackerConfiguration, CrashtrackerReceiverConfig, Metadata,
};
use ddcommon::{tag, Endpoint};

const TEST_COLLECTOR_TIMEOUT_MS: u32 = 10_000;

#[inline(never)]
pub unsafe fn cause_segfault() -> anyhow::Result<()> {
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Expand Down
4 changes: 4 additions & 0 deletions bin_tests/src/constants.rs
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;
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment explaining how this value was chosen

3 changes: 3 additions & 0 deletions bin_tests/src/lib.rs
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::*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really care either way, but any reason that modes is pub mod, while constants is pub use *?


use std::{collections::HashMap, env, ops::DerefMut, path::PathBuf, process, sync::Mutex};

use once_cell::sync::OnceCell;
Expand Down
30 changes: 29 additions & 1 deletion bin_tests/tests/crashtracker_bin_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above about making TEST_COLLECTOR_TIMEOUT_MS a Duration

));

// Check the crash data
let crash_profile = fs::read(fixtures.crash_profile_path)
.context("reading crashtracker profiling payload")
Expand Down
Loading