aboutsummaryrefslogtreecommitdiff
path: root/test/system/045-start.bats
blob: 3e0118dba89b1f3adffa137d2f4307845fb89917 (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env bats   -*- bats -*-

load helpers

@test "podman start --all - start all containers" {
    # Run a bunch of short-lived containers, with different --restart settings
    run_podman run -d $IMAGE /bin/true
    cid_none_implicit="$output"
    run_podman run -d --restart=no $IMAGE /bin/false
    cid_none_explicit="$output"
    run_podman run -d --restart=on-failure $IMAGE /bin/true
    cid_on_failure="$output"

    # Run one longer-lived one.
    run_podman run -d --restart=always $IMAGE sleep 20
    cid_always="$output"

    run_podman wait $cid_none_implicit $cid_none_explicit $cid_on_failure

    run_podman start --all
    is "$output" ".*$cid_none_implicit" "started: container with no --restart"
    is "$output" ".*$cid_none_explicit" "started: container with --restart=no"
    is "$output" ".*$cid_on_failure" "started: container with --restart=on-failure"
    if [[ $output =~ $cid_always ]]; then
        die "podman start --all restarted a running container"
    fi

    run_podman wait $cid_none_implicit $cid_none_explicit $cid_on_failure

    run_podman rm $cid_none_implicit $cid_none_explicit $cid_on_failure
    run_podman stop -t 1 $cid_always
    run_podman rm $cid_always
}

@test "podman start --all with incompatible options" {
    expected="Error: either start all containers or the container(s) provided in the arguments"
    run_podman 125 start --all 12333
    is "$output" "$expected" "start --all, with args, throws error"
    if ! is_remote; then
        run_podman 125 start --all --latest
        is "$output" "$expected" "podman start --all --latest"
    fi
}

@test "podman start --filter - start only containers that match the filter" {
    run_podman run -d $IMAGE /bin/true
    cid="$output"
    run_podman start --filter restart-policy=always $cid "CID of restart-policy=always container"
    is "$output" ""

    run_podman start --filter restart-policy=none $cid "CID of restart-policy=none container"
    is "$output" "$cid"
}

@test "podman start --filter invalid-restart-policy - return error" {
    run_podman run -d $IMAGE /bin/true
    cid="$output"
    run_podman 125 start --filter restart-policy=fakepolicy $cid "CID of restart-policy=<not-exists> container"
    is "$output" "Error: fakepolicy invalid restart policy"
}

# vim: filetype=sh