Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
argo
cuttr
Commits
dd276c77
Commit
dd276c77
authored
Sep 24, 2018
by
Alexis Janon
Browse files
Integration test for spawn command with no name field
parent
13a18184
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/transaction_tests.rs
View file @
dd276c77
extern
crate
cuttr
;
use
cuttr
::
random
::
random_string
;
use
std
::
fs
;
use
std
::
path
;
use
std
::
rc
::
Rc
;
...
...
@@ -233,3 +234,45 @@ fn test_spawn_cpuset() {
assert
!
(
fs
::
remove_file
(
&
result_path
)
.is_ok
());
assert
!
(
paths
.iter
()
.all
(|
p
|
!
p
.exists
()));
}
#[test]
// TODO: need cpuset cgroup: make it more generic (or robust)
fn
test_spawn_cpuset_no_name
()
{
let
result_file
=
format!
(
"{}{}"
,
SPAWN_CPUSET_RESULT_FILE
,
random_string
(
12
));
let
json
=
format!
(
r#"
{{
"commands":[
{{
"command":"spawn",
"args":[
"cpuset"
],
"properties":{{
"cpuset.mems":"0",
"cpuset.cpus":"0"
}},
"cmd":"bash",
"cmd_args":[
"-c", "echo $(nproc) > {}"
]
}}
]
}}
"#
,
result_file
);
let
controllers
=
Rc
::
new
(
configuration
::
sysfscontroller
::
get_sys_fs_controllers
()
.unwrap
());
let
paths
=
controllers
.values
()
.map
(
SysFsController
::
get_path
)
.map
(
path
::
Path
::
to_path_buf
)
.map
(|
path
|
path
.join
(
SPAWN_CPUSET_NAME
))
.collect
::
<
Vec
<
_
>>
();
let
mut
commands
=
parsing
::
parse_json
(
&
json
,
controllers
)
.unwrap
();
assert
!
(
commands
.exec
()
.is_ok
());
let
result_path
=
path
::
Path
::
new
(
&
result_file
);
assert_eq!
(
fs
::
read_to_string
(
&
result_path
)
.unwrap
()
.trim
(),
"1"
);
assert
!
(
fs
::
remove_file
(
&
result_path
)
.is_ok
());
assert
!
(
paths
.iter
()
.all
(|
p
|
!
p
.exists
()));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment