Merge pull request #7486 from kata-containers/topic/addsysbench

metrics: Add sysbench performance test
This commit is contained in:
GabyCT 2023-08-01 10:17:48 -06:00 committed by GitHub
commit a0a524efc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 109 additions and 0 deletions

View File

@ -51,3 +51,8 @@ For more details see the [footprint test documentation](footprint_data.md).
Measures the memory statistics *inside* the container. This allows evaluation of Measures the memory statistics *inside* the container. This allows evaluation of
the overhead the VM kernel and rootfs are having on the memory that was requested the overhead the VM kernel and rootfs are having on the memory that was requested
by the container co-ordination system, and thus supplied to the VM. by the container co-ordination system, and thus supplied to the VM.
## `k8s-sysbench`
`Sysbench`is an open-source and multi-purpose benchmark utility that evaluates parameters features tests for `CPU`, memory
and I/O. Currently the `k8s-sysbench` test is measuring the `CPU` performance.

View File

@ -0,0 +1,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 "$@"

View File

@ -0,0 +1,18 @@
#
# Copyright (c) 2018-2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
apiVersion: v1
kind: Pod
metadata:
name: test-sysbench
spec:
terminationGracePeriodSeconds: 0
runtimeClassName: kata
containers:
- name: test-sysbench
image: localhost:5000/sysbench-kata:latest
command:
- sleep
- "60"

View File

@ -0,0 +1,17 @@
# Copyright (c) 2022-2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
# Usage: FROM [image name]
FROM ubuntu:20.04
# Version of the Dockerfile
LABEL DOCKERFILE_VERSION="1.0"
RUN apt-get update && \
apt-get install -y build-essential git curl sudo && \
apt-get remove -y unattended-upgrades && \
curl -OkL https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh && \
apt-get install -y sysbench
CMD ["/bin/bash"]