summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/kpod_stats.bats101
1 files changed, 24 insertions, 77 deletions
diff --git a/test/kpod_stats.bats b/test/kpod_stats.bats
index b98c83c90..8eb112496 100644
--- a/test/kpod_stats.bats
+++ b/test/kpod_stats.bats
@@ -10,104 +10,51 @@ function setup() {
copy_images
}
-@test "stats single output" {
- skip "Test needs to be converted to kpod run"
- start_crio
- run crioctl pod run --config "$TESTDATA"/sandbox_config.json
+@test "stats should run with no containers" {
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream
echo "$output"
[ "$status" -eq 0 ]
- pod_id="$output"
- run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
+}
+
+@test "stats with bogus container id" {
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream 123
echo "$output"
- [ "$status" -eq 0 ]
+ [ "$status" -eq 1 ]
+}
+
+@test "stats on a running container" {
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} run -d -t ${ALPINE} sleep 99
ctr_id="$output"
- run crioctl ctr start --id "$ctr_id"
echo "$output"
- [ "$status" -eq 0 ]
- run bash -c ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream "$ctr_id"
+ run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream $ctr_id"
echo "$output"
[ "$status" -eq 0 ]
- cleanup_ctrs
- cleanup_pods
- stop_crio
}
-@test "stats does not output stopped container" {
- skip "Test needs to be converted to kpod run"
- start_crio
- run crioctl pod run --config "$TESTDATA"/sandbox_config.json
- echo "$output"
- [ "$status" -eq 0 ]
- pod_id="$output"
- run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
- echo "$output"
- [ "$status" -eq 0 ]
- ctr_id="$output"
- run bash -c ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream
+@test "stats on a running container no id" {
+ ${KPOD_BINARY} ${KPOD_OPTIONS} run -d -t ${ALPINE} sleep 99
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream
echo "$output"
[ "$status" -eq 0 ]
- cleanup_ctrs
- cleanup_pods
- stop_crio
}
-@test "stats outputs stopped container with all flag" {
- skip "Test needs to be converted to kpod run"
- start_crio
- run crioctl pod run --config "$TESTDATA"/sandbox_config.json
+@test "stats on all containers" {
+ ${KPOD_BINARY} ${KPOD_OPTIONS} run -d -t ${ALPINE} ls
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream -a
echo "$output"
[ "$status" -eq 0 ]
- pod_id="$output"
- run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
- echo "$output"
- [ "$status" -eq 0 ]
- ctr_id="$output"
- run bash -c ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream --all
- echo "$output"
- [ "$status" -eq 0 ]
- cleanup_ctrs
- cleanup_pods
- stop_crio
}
-@test "stats output only id" {
- skip "Test needs to be converted to kpod run"
- start_crio
- run crioctl pod run --config "$TESTDATA"/sandbox_config.json
- echo "$output"
- [ "$status" -eq 0 ]
- pod_id="$output"
- run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
- echo "$output"
- [ "$status" -eq 0 ]
- ctr_id="$output"
- run crioctl ctr start --id "$ctr_id"
+@test "stats only output IDs" {
+ ${KPOD_BINARY} ${KPOD_OPTIONS} run -d -t ${ALPINE} sleep 99
+ run ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream --format "{{.Container}}"
echo "$output"
[ "$status" -eq 0 ]
- run bash -c ${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream --format {{.ID}} "$ctr_id"
- echo "$output"
- [ "$status" -eq 0 ]
- # once ps is implemented, run ps -q and see if that equals the output from above
- cleanup_ctrs
- cleanup_pods
- stop_crio
}
-@test "stats streaming output" {
- skip "Test needs to be converted to kpod run"
- start_crio
- run crioctl pod run --config "$TESTDATA"/sandbox_config.json
- echo "$output"
- [ "$status" -eq 0 ]
- pod_id="$output"
- run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
+@test "stats json output" {
+ ${KPOD_BINARY} ${KPOD_OPTIONS} run -d -t ${ALPINE} ls
+ run bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} stats --no-stream -a --format json | python -m json.tool"
echo "$output"
[ "$status" -eq 0 ]
- ctr_id="$output"
- run timeout 5s bash -c "${KPOD_BINARY} ${KPOD_OPTIONS} stats --all"
- echo "$output"
- [ "$status" -eq 124 ] #124 is the status set by timeout when it has to kill the command at the end of the given time
- cleanup_ctrs
- cleanup_pods
- stop_crio
}