aboutsummaryrefslogtreecommitdiff
path: root/test/kpod_kill.bats
blob: 15eaef92464b164e3762c0aa5afbcb48b840101c (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env bats

load helpers

function teardown() {
    cleanup_test
}

function start_sleep_container () {
    pod_id=$(crioctl pod run --config "$TESTDATA"/sandbox_config.json)
    ctr_id=$(crioctl ctr create --config "$TESTDATA"/container_config_sleep.json --pod "$pod_id")
    crioctl ctr start --id "$ctr_id"
}

@test "kill a bogus container" {
    run ${KPOD_BINARY} ${KPOD_OPTIONS} kill foobar
    echo "$output"
    [ "$status" -ne 0 ]
}

@test "kill a running container by id" {
    skip "Test needs to be converted to kpod run"
    start_crio
    ${KPOD_BINARY} ${KPOD_OPTIONS} pull docker.io/library/busybox:latest
    ctr_id=$( start_sleep_container )
    crioctl ctr status --id "$ctr_id"
    ${KPOD_BINARY} ${KPOD_OPTIONS} ps -a
    ${KPOD_BINARY} ${KPOD_OPTIONS} logs "$ctr_id"
    crioctl ctr status --id "$ctr_id"
    run ${KPOD_BINARY} ${KPOD_OPTIONS} kill "$ctr_id"
    echo "$output"
    [ "$status" -eq 0 ]
    cleanup_ctrs
    cleanup_pods
    stop_crio
}

@test "kill a running container by id with TERM" {
    skip "Test needs to be converted to kpod run"
    start_crio
    ${KPOD_BINARY} ${KPOD_OPTIONS} pull docker.io/library/busybox:latest
    ctr_id=$( start_sleep_container )
    crioctl ctr status --id "$ctr_id"
    ${KPOD_BINARY} ${KPOD_OPTIONS} ps -a
    ${KPOD_BINARY} ${KPOD_OPTIONS} logs "$ctr_id"
    crioctl ctr status --id "$ctr_id"
    run ${KPOD_BINARY} ${KPOD_OPTIONS} kill -s TERM "$ctr_id"
    echo "$output"
    [ "$status" -eq 0 ]
    cleanup_ctrs
    cleanup_pods
    stop_crio
}

@test "kill a running container by name" {
    skip "Test needs to be converted to kpod run"
    start_crio
    ${KPOD_BINARY} ${KPOD_OPTIONS} pull docker.io/library/busybox:latest
    ctr_id=$( start_sleep_container )
    crioctl ctr status --id "$ctr_id"
    ${KPOD_BINARY} ${KPOD_OPTIONS} ps -a
    ${KPOD_BINARY} ${KPOD_OPTIONS} logs "$ctr_id"
    crioctl ctr status --id "$ctr_id"
    ${KPOD_BINARY} ${KPOD_OPTIONS} ps -a
    run ${KPOD_BINARY} ${KPOD_OPTIONS} kill "k8s_container999_podsandbox1_redhat.test.crio_redhat-test-crio_1"
    echo "$output"
    [ "$status" -eq 0 ]
    cleanup_ctrs
    cleanup_pods
    stop_crio
}

@test "kill a running container by id with a bogus signal" {
    skip "Test needs to be converted to kpod run"
    start_crio
    ${KPOD_BINARY} ${KPOD_OPTIONS} pull docker.io/library/busybox:latest
    ctr_id=$( start_sleep_container )
    crioctl ctr status --id "$ctr_id"
    ${KPOD_BINARY} ${KPOD_OPTIONS} logs "$ctr_id"
    crioctl ctr status --id "$ctr_id"
    run ${KPOD_BINARY} ${KPOD_OPTIONS} kill -s foobar "$ctr_id"
    echo "$output"
    [ "$status" -ne 0 ]
    cleanup_ctrs
    cleanup_pods
    stop_crio
}