summaryrefslogtreecommitdiff
path: root/test/kpod_top.bats
blob: 9d54908bce8c59d7ea2a1e50f87ecce7ebbf9f28 (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
#!/usr/bin/env bats

load helpers

function teardown() {
    cleanup_test
}

function setup() {
    prepare_network_conf
    copy_images
}

@test "top without container name or id" {
    run ${KPOD_BINARY} ${KPOD_OPTIONS} top
    echo "$output"
    [ "$status" -eq 1 ]
}

@test "top a bogus container" {
    run ${KPOD_BINARY} ${KPOD_OPTIONS} top foobar
    echo "$output"
    [ "$status" -eq 1 ]
}

@test "top non-running container by id with defaults" {
    run ${KPOD_BINARY} ${KPOD_OPTIONS} create -d ${ALPINE} sleep 60
    [ "$status" -eq 0 ]
    ctr_id="$output"
    run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} top $ctr_id"
    echo "$output"
    [ "$status" -eq 1 ]
}

@test "top running container by id with defaults" {
    run ${KPOD_BINARY} ${KPOD_OPTIONS} run -dt ${ALPINE} /bin/sh
    [ "$status" -eq 0 ]
    ctr_id="$output"
    echo $ctr_id
    run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} top $ctr_id"
    echo "$output"
    [ "$status" -eq 0 ]
}

@test "top running container by id with ps opts" {
    run ${KPOD_BINARY} ${KPOD_OPTIONS} run -d ${ALPINE} sleep 60
    [ "$status" -eq 0 ]
    ctr_id="$output"
    run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} top $ctr_id -o fuser,f,comm,label"
    echo "$output"
    [ "$status" -eq 0 ]
}