-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2987 from saku3/add-test-process_oom_score_adj
add e2e test for process_oom_score_adj
- Loading branch information
Showing
6 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mod process_oom_score_adj_test; | ||
pub use process_oom_score_adj_test::get_process_oom_score_adj_test; |
46 changes: 46 additions & 0 deletions
46
tests/contest/contest/src/tests/process_oom_score_adj/process_oom_score_adj_test.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use anyhow::{Context, Ok, Result}; | ||
use oci_spec::runtime::{ProcessBuilder, Spec, SpecBuilder}; | ||
use rand::Rng; | ||
use test_framework::{test_result, Test, TestGroup, TestResult}; | ||
|
||
use crate::utils::test_inside_container; | ||
|
||
fn generate_random_number() -> i32 { | ||
let mut rng = rand::thread_rng(); | ||
rng.gen_range(300..=700) | ||
} | ||
|
||
fn create_spec() -> Result<Spec> { | ||
let spec = SpecBuilder::default() | ||
.process( | ||
ProcessBuilder::default() | ||
.args(vec![ | ||
"runtimetest".to_string(), | ||
"process_oom_score_adj".to_string(), | ||
]) | ||
.oom_score_adj(generate_random_number()) | ||
.build() | ||
.expect("error in creating process config"), | ||
) | ||
.build() | ||
.context("failed to build spec")?; | ||
|
||
Ok(spec) | ||
} | ||
|
||
fn process_oom_score_adj_test() -> TestResult { | ||
let spec = test_result!(create_spec()); | ||
test_inside_container(spec, &|_| Ok(())) | ||
} | ||
|
||
pub fn get_process_oom_score_adj_test() -> TestGroup { | ||
let mut process_oom_score_adj_test_group = TestGroup::new("process_oom_score_adj"); | ||
|
||
let test = Test::new( | ||
"process_oom_score_adj", | ||
Box::new(process_oom_score_adj_test), | ||
); | ||
process_oom_score_adj_test_group.add(vec![Box::new(test)]); | ||
|
||
process_oom_score_adj_test_group | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters