forked from docker-archive/runc
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhooks.bats
More file actions
48 lines (41 loc) · 1.41 KB
/
hooks.bats
File metadata and controls
48 lines (41 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bats
load helpers
function setup() {
setup_busybox
}
function teardown() {
teardown_bundle
}
@test "runc create [second createRuntime hook fails]" {
update_config '.hooks |= {"createRuntime": [{"path": "/bin/true"}, {"path": "/bin/false"}]}'
runc create --console-socket "$CONSOLE_SOCKET" test_hooks
[ "$status" -ne 0 ]
[[ "$output" == *"error running createRuntime hook #1:"* ]]
}
@test "runc create [hook fails]" {
for hook in prestart createRuntime createContainer; do
echo "testing hook $hook"
# shellcheck disable=SC2016
update_config '.hooks |= {"'$hook'": [{"path": "/bin/true"}, {"path": "/bin/false"}]}'
runc create --console-socket "$CONSOLE_SOCKET" test_hooks
[ "$status" -ne 0 ]
[[ "$output" == *"error running $hook hook #1:"* ]]
done
}
@test "runc run [hook fails]" {
update_config '.process.args = ["/bin/echo", "Hello World"]'
# All hooks except Poststop.
for hook in prestart createRuntime createContainer startContainer poststart; do
echo "testing hook $hook"
# shellcheck disable=SC2016
update_config '.hooks |= {"'$hook'": [{"path": "/bin/true"}, {"path": "/bin/false"}]}'
runc run "test_hook-$hook"
[ "$status" -ne 0 ]
[[ "$output" != *"Hello World"* ]]
[[ "$output" == *"error running $hook hook #1:"* ]]
# Check the container was never started.
runc delete "test_hook-$hook"
[ "$status" -eq 1 ]
[[ "$output" == *"container does not exist"* ]]
done
}