Skip to content
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 .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
no_output_timeout: 30s
environment:
# tests that manipulate the cgroupfs don't work in the CI container, because it has no systemd user slice, so the tests cannot create cgroups
SKIP_CGROUPFS_TESTS: true
RUN_CGROUPFS_TESTS: false

# Caching "target" is not worth it because it is costly to extract the huge cache.
# So, we only cache some cargo data.
Expand Down
6 changes: 3 additions & 3 deletions plugins/cgroups/k8s/tests/k8s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const TOKEN_CONTENT: &str = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMj

#[test]
fn test_k8s_cgroupv2() -> anyhow::Result<()> {
if std::env::var_os("SKIP_CGROUPFS_TESTS").is_some() {
println!("skipped because SKIP_CGROUPFS_TESTS is set");
let Ok("true" | "yes" | "1") = std::env::var("RUN_CGROUPFS_TESTS").as_deref() else {
println!("skipped because RUN_CGROUPFS_TESTS is not set");
return Ok(());
}
};

let _ = env_logger::Builder::from_default_env().try_init();

Expand Down
12 changes: 6 additions & 6 deletions plugins/cgroups/oar/tests/oar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const TOLERANCE: Duration = Duration::from_millis(500);
#[test]
#[serial]
fn test_oar3() -> anyhow::Result<()> {
if std::env::var_os("SKIP_CGROUPFS_TESTS").is_some() {
println!("skipped because SKIP_CGROUPFS_TESTS is set");
let Ok("true" | "yes" | "1") = std::env::var("RUN_CGROUPFS_TESTS").as_deref() else {
println!("skipped because RUN_CGROUPFS_TESTS is not set");
return Ok(());
}
};

let _ = env_logger::Builder::from_default_env().try_init();

Expand Down Expand Up @@ -107,10 +107,10 @@ fn test_oar3() -> anyhow::Result<()> {
#[test]
#[serial]
fn test_oar2() -> anyhow::Result<()> {
if std::env::var_os("SKIP_CGROUPFS_TESTS").is_some() {
println!("skipped because SKIP_CGROUPFS_TESTS is set");
let Ok("true" | "yes" | "1") = std::env::var("RUN_CGROUPFS_TESTS").as_deref() else {
println!("skipped because RUN_CGROUPFS_TESTS is not set");
return Ok(());
}
};

let _ = env_logger::Builder::from_default_env().try_init();

Expand Down
6 changes: 3 additions & 3 deletions plugins/cgroups/raw/tests/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ const TOLERANCE: Duration = Duration::from_millis(500);

#[test]
fn test_raw_cgroupv2() -> anyhow::Result<()> {
if std::env::var_os("SKIP_CGROUPFS_TESTS").is_some() {
println!("skipped because SKIP_CGROUPFS_TESTS is set");
let Ok("true" | "yes" | "1") = std::env::var("RUN_CGROUPFS_TESTS").as_deref() else {
println!("skipped because RUN_CGROUPFS_TESTS is not set");
return Ok(());
}
};

let _ = env_logger::Builder::from_default_env().try_init();

Expand Down
30 changes: 15 additions & 15 deletions plugins/cgroups/util-cgroups-plugins/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ impl AlumetPlugin for DumbOARPlugin2 {

#[test]
fn test_correct_transform() -> anyhow::Result<()> {
if std::env::var_os("SKIP_CGROUPFS_TESTS").is_some() {
println!("skipped because SKIP_CGROUPFS_TESTS is set");
let Ok("true" | "yes" | "1") = std::env::var("RUN_CGROUPFS_TESTS").as_deref() else {
println!("skipped because RUN_CGROUPFS_TESTS is not set");
return Ok(());
}
};

let app_slice = find_user_app_slice(Path::new(SYSFS_CGROUP))?;

Expand Down Expand Up @@ -228,10 +228,10 @@ fn test_correct_transform() -> anyhow::Result<()> {

#[test]
fn test_cgroups_files_not_created() -> anyhow::Result<()> {
if std::env::var_os("SKIP_CGROUPFS_TESTS").is_some() {
println!("skipped because SKIP_CGROUPFS_TESTS is set");
let Ok("true" | "yes" | "1") = std::env::var("RUN_CGROUPFS_TESTS").as_deref() else {
println!("skipped because RUN_CGROUPFS_TESTS is not set");
return Ok(());
}
};

let app_slice = find_user_app_slice(Path::new(SYSFS_CGROUP)).unwrap();

Expand Down Expand Up @@ -294,10 +294,11 @@ fn test_cgroups_files_not_created() -> anyhow::Result<()> {

#[test]
fn test_cgroup_v2_hierarchy_not_created() -> anyhow::Result<()> {
if std::env::var_os("SKIP_CGROUPFS_TESTS").is_some() {
println!("skipped because SKIP_CGROUPFS_TESTS is set");
let Ok("true" | "yes" | "1") = std::env::var("RUN_CGROUPFS_TESTS").as_deref() else {
println!("skipped because RUN_CGROUPFS_TESTS is not set");
return Ok(());
}
};

let app_slice = find_user_app_slice(Path::new(SYSFS_CGROUP)).unwrap();

// Create cgroupv2 hierarchy
Expand Down Expand Up @@ -409,11 +410,12 @@ fn test_no_cgroupv2_at_all() -> anyhow::Result<()> {
}

#[test]
fn test_on_cgroupfs_mounted() -> () {
if std::env::var_os("SKIP_CGROUPFS_TESTS").is_some() {
println!("skipped because SKIP_CGROUPFS_TESTS is set");
fn test_on_cgroupfs_mounted() {
let Ok("true" | "yes" | "1") = std::env::var("RUN_CGROUPFS_TESTS").as_deref() else {
println!("skipped because RUN_CGROUPFS_TESTS is not set");
return ();
}
};

let app_slice = find_user_app_slice(Path::new(SYSFS_CGROUP)).unwrap();
// Create cgroupv2 hierarchy
let cgroup_dir_parent = tempfile::tempdir_in(&app_slice)
Expand All @@ -432,8 +434,6 @@ fn test_on_cgroupfs_mounted() -> () {
)];
let ret = shared_hierarchy.on_cgroupfs_mounted(&cgroup_hierarchy);
assert!(ret.is_ok());

()
}

fn prepare_mock_measurements(ctx: &mut TransformCheckInputContext, path: PathBuf) -> anyhow::Result<MeasurementBuffer> {
Expand Down
Loading