forked from kata-containers/kata-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
k8s-sysbench.sh
executable file
·69 lines (57 loc) · 1.49 KB
/
k8s-sysbench.sh
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
#!/bin/bash
#
# Copyright (c) 2022-2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
set -o errexit
set -o nounset
set -o pipefail
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
source "${SCRIPT_PATH}/../lib/common.bash"
sysbench_file=$(mktemp sysbenchresults.XXXXXXXXXX)
TEST_NAME="${TEST_NAME:-sysbench}"
CI_JOB="${CI_JOB:-}"
IMAGE="docker.io/library/local-sysbench:latest"
DOCKERFILE="${SCRIPT_PATH}/sysbench-dockerfile/Dockerfile"
function remove_tmp_file() {
rm -rf "${sysbench_file}"
}
trap remove_tmp_file EXIT
function sysbench_memory() {
kubectl exec -i "$pod_name" -- sh -c "sysbench memory --threads=2 run" > "${sysbench_file}"
metrics_json_init
local memory_latency_sum=$(cat "$sysbench_file" | grep sum | cut -f2 -d':' | sed 's/[[:blank:]]//g')
metrics_json_start_array
local json="$(cat << EOF
{
"memory-latency-sum": {
"Result" : $memory_latency_sum,
"Units" : "ms"
}
}
EOF
)"
metrics_json_add_array_element "$json"
metrics_json_end_array "Results"
metrics_json_save
}
function sysbench_start_deployment() {
cmds=("bc" "jq")
check_cmds "${cmds[@]}"
# Check no processes are left behind
check_processes
export pod_name="test-sysbench"
kubectl create -f "${SCRIPT_PATH}/runtimeclass_workloads/sysbench-pod.yaml"
kubectl wait --for=condition=Ready --timeout=120s pod "$pod_name"
}
function sysbench_cleanup() {
kubectl delete pod "$pod_name"
check_processes
}
function main() {
init_env
sysbench_start_deployment
sysbench_memory
sysbench_cleanup
}
main "$@"