1
#!/usr/bin/env bats -*- bats -*-
5
@test "podman start --all - start all containers" {
7
run_podman run -d $IMAGE /bin/true
8
cid_none_implicit="$output"
9
run_podman run -d --restart=no $IMAGE /bin/false
10
cid_none_explicit="$output"
11
run_podman run -d --restart=on-failure $IMAGE /bin/true
12
cid_on_failure="$output"
15
run_podman run -d --restart=always $IMAGE sleep 20
18
run_podman wait $cid_none_implicit $cid_none_explicit $cid_on_failure
20
run_podman start --all
21
is "$output" ".*$cid_none_implicit" "started: container with no --restart"
22
is "$output" ".*$cid_none_explicit" "started: container with --restart=no"
23
is "$output" ".*$cid_on_failure" "started: container with --restart=on-failure"
24
assert "$output" !~ "$cid_always" \
25
"podman start --all should not restart a running container"
27
run_podman wait $cid_none_implicit $cid_none_explicit $cid_on_failure
29
run_podman rm $cid_none_implicit $cid_none_explicit $cid_on_failure
30
run_podman 0+w stop -t 1 $cid_always
32
require_warning "StopSignal SIGTERM failed to stop container .*, resorting to SIGKILL"
34
run_podman rm $cid_always
37
@test "podman start --all with incompatible options" {
38
expected="Error: either start all containers or the container(s) provided in the arguments"
39
run_podman 125 start --all 12333
40
is "$output" "$expected" "start --all, with args, throws error"
43
@test "podman start --filter - start only containers that match the filter" {
44
c1="c1_always_$(random_string 15)"
45
c2="c2_on_failure_$(random_string 15)"
46
c3="c3_always_$(random_string 15)"
48
run_podman create --name=$c1 --restart=always $IMAGE /bin/true
50
run_podman create --name=$c2 --restart=on-failure $IMAGE /bin/true
52
run_podman create --name=$c3 --restart=always $IMAGE /bin/true
56
run_podman start --filter restart-policy=always
58
is "$output" ".*$c1_id.*" "--filter finds container 1"
59
is "$output" ".*$c3_id.*" "--filter finds container 3"
62
run_podman start --filter restart-policy=on-failure $c2 $c3
63
is "$output" "$c2" "--filter finds container 2"
66
run_podman start --filter restart-policy=none --all
70
@test "podman start --filter invalid-restart-policy - return error" {
71
run_podman run -d $IMAGE /bin/true
73
run_podman 125 start --filter restart-policy=fakepolicy $cid
74
is "$output" "Error: fakepolicy invalid restart policy" \
75
"CID of restart-policy=<not-exists> container"
78
@test "podman start --all --filter" {
79
run_podman run -d $IMAGE /bin/true
80
cid_exited_0="$output"
81
run_podman run -d $IMAGE /bin/false
82
cid_exited_1="$output"
84
run_podman wait $cid_exited_0 $cid_exited_1
85
run_podman start --all --filter exited=0
86
is "$output" "$cid_exited_0"
89
@test "podman start print IDs or raw input" {
91
run_podman create $IMAGE top
93
run_podman start --all
97
cname=$(random_string)
98
run_podman create --name $cname $IMAGE top
99
run_podman start $cname
102
run_podman rm -t 0 -f $ctrID $cname
105
@test "podman start again with lower ulimit -u" {
106
skip_if_not_rootless "tests ulimit -u changes in the rootless scenario"
107
skip_if_remote "test relies on control of ulimit -u (not possible for remote)"
109
nrpoc_limit=$(ulimit -Hu)
112
run_podman create $IMAGE echo "hello"
116
run_podman inspect $ctrID
117
assert "$output" =~ '"Ulimits": \[\]' "Ulimits has to be empty after create"
120
run_podman start $ctrID
121
is "$output" "$ctrID"
124
run_podman inspect $ctrID --format '{{range .HostConfig.Ulimits}}{{if eq .Name "RLIMIT_NPROC" }}{{.Soft}}:{{.Hard}}{{end}}{{end}}'
125
assert "$output" == "${nrpoc_limit}:${nrpoc_limit}" "Ulimit has to match ulimit -Hu"
131
ulimit -u $nrpoc_limit
134
run_podman start $ctrID
135
is "$output" "$ctrID"
138
run_podman inspect $ctrID --format '{{range .HostConfig.Ulimits}}{{if eq .Name "RLIMIT_NPROC" }}{{.Soft}}:{{.Hard}}{{end}}{{end}}'
139
assert "$output" == "${nrpoc_limit}:${nrpoc_limit}" "Ulimit has to match new ulimit -Hu"
141
run_podman rm -t 0 -f $ctrID $cname