-
Notifications
You must be signed in to change notification settings - Fork 347
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 #2646 from lengrongfu/test/io-priority
add io priority e2e test
- Loading branch information
Showing
6 changed files
with
146 additions
and
1 deletion.
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
78 changes: 78 additions & 0 deletions
78
tests/contest/contest/src/tests/io_priority/io_priority_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,78 @@ | ||
use crate::utils::test_inside_container; | ||
use anyhow::{Context, Result}; | ||
use oci_spec::runtime::{ | ||
IOPriorityClass, LinuxIOPriorityBuilder, ProcessBuilder, Spec, SpecBuilder, | ||
}; | ||
use test_framework::{test_result, Test, TestGroup, TestResult}; | ||
|
||
fn create_spec( | ||
io_priority_class: IOPriorityClass, | ||
execute_test: &str, | ||
priority: i64, | ||
) -> Result<Spec> { | ||
let io_p = LinuxIOPriorityBuilder::default() | ||
.class(io_priority_class) | ||
.priority(priority) | ||
.build() | ||
.unwrap(); | ||
SpecBuilder::default() | ||
.process( | ||
ProcessBuilder::default() | ||
.args( | ||
["runtimetest", execute_test] | ||
.iter() | ||
.map(|s| s.to_string()) | ||
.collect::<Vec<String>>(), | ||
) | ||
.io_priority(io_p) | ||
.build()?, | ||
) | ||
.build() | ||
.context("failed to create spec") | ||
} | ||
|
||
fn io_priority_class_rt_test() -> TestResult { | ||
let spec = test_result!(create_spec( | ||
IOPriorityClass::IoprioClassRt, | ||
"io_priority_class_rt", | ||
1, | ||
)); | ||
test_inside_container(spec, &|_| Ok(())) | ||
} | ||
|
||
fn io_priority_class_be_test() -> TestResult { | ||
let spec = test_result!(create_spec( | ||
IOPriorityClass::IoprioClassBe, | ||
"io_priority_class_be", | ||
2, | ||
)); | ||
test_inside_container(spec, &|_| Ok(())) | ||
} | ||
|
||
fn io_priority_class_idle_test() -> TestResult { | ||
let spec = test_result!(create_spec( | ||
IOPriorityClass::IoprioClassIdle, | ||
"io_priority_class_idle", | ||
3, | ||
)); | ||
test_inside_container(spec, &|_| Ok(())) | ||
} | ||
|
||
pub fn get_io_priority_test() -> TestGroup { | ||
let mut io_priority_group = TestGroup::new("set_io_priority"); | ||
let io_priority_class_rt = | ||
Test::new("io_priority_class_rt", Box::new(io_priority_class_rt_test)); | ||
let io_priority_class_be = | ||
Test::new("io_priority_class_be", Box::new(io_priority_class_be_test)); | ||
let io_priority_class_idle = Test::new( | ||
"io_priority_class_idle", | ||
Box::new(io_priority_class_idle_test), | ||
); | ||
|
||
io_priority_group.add(vec![ | ||
Box::new(io_priority_class_rt), | ||
Box::new(io_priority_class_be), | ||
Box::new(io_priority_class_idle), | ||
]); | ||
io_priority_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mod io_priority_test; | ||
|
||
pub use io_priority_test::get_io_priority_test; |
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