Skip to content

Commit

Permalink
metrics: Enables FIO test for kata containers
Browse files Browse the repository at this point in the history
FIO benchmark is enabled to measure IO in Kata
at different latencies using containerd client,
in order to complement the CI metrics testing set.

This PR asl deprecated the previous Fio bench
based on k8s.

Fixes: kata-containers#8080

Signed-off-by: David Esparza <[email protected]>
  • Loading branch information
dborquez committed Oct 4, 2023
1 parent a890ad3 commit a2159a6
Show file tree
Hide file tree
Showing 50 changed files with 316 additions and 1,533 deletions.
26 changes: 26 additions & 0 deletions tests/metrics/storage/fio-dockerfile/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (c) 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

# Set up an Ubuntu image with 'fio io tester' installed

FROM docker.io/library/ubuntu:22.04

# Version of the Dockerfile
LABEL DOCKERFILE_VERSION="1.0"

# URL for the fio tester
ENV FIO_TOOLING_URL "https://github.com/axboe/fio"

RUN apt-get update --quiet && \
apt-get install --quiet --no-install-recommends -y \
bash \
util-linux \
procps \
fio && \
apt-get clean && \
rm -rf /var/lib/apt/lists/

COPY workload/fio_bench.sh /
WORKDIR /
CMD ["/bin/bash"]
129 changes: 129 additions & 0 deletions tests/metrics/storage/fio-dockerfile/workload/fio_bench.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
#!/bin/bash
#
# Copyright (c) 2023 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0

# Description of the test:
# This test runs the 'fio benchmark' on kata containers
# https://fio.readthedocs.io/en/latest/

set -o pipefail

# FIO variable settings

# io-types supported:
# read, write, randread, randwrite, randrw, readwrite
io_type="read"
block_size="4k"
num_jobs="2"

# FIO default settings
readonly ioengine="libaio"
readonly rate_process="linear"
readonly disable_buffered="1"
readonly iodepth="2"
readonly runtime="10s"
# ramp time
readonly rt="10s"
readonly fname="test.fio"
readonly workload_dir="/"
readonly workload_file="${workload_dir}${fname}"
readonly workload_size="10G"
readonly summary_file_local="/results.json"

# Show help about this script
function help() {
cat << EOF
Usage: $0 <count>
Description:
Runs FIO test using ctr to excercise IO in kata containers.
Params: <Operation> <io-engine>
Operations are:
run-read-4k
run-write-4k
run-randread-4k
run-randwrite-4k
run-read-64k
run-write-64k
run-randread-64k
run-randwrite-64k
<Operation>: [Mandatory]
<io-engine> : [Optional] Any of the FIO supported ioengines, default: libaio.
EOF
}

# Run from the host
function setup_workload() {
# create workload file:
if [ ! -f ${workload_file} ]; then
pushd "${workload_dir}" > /dev/null 2>&1
dd if=/dev/urandom of="${workload_file}" bs=64M count=160 > /dev/null 2>&1
fi
}

# Run inside container
function launch_workload() {
# the parameters used in the test_name are accesible globally
local test_name="${io_type}_${block_size}_nj-${num_jobs}_${rate_process}_iodepth-${iodepth}_io-direct-${disable_buffered}"

setup_workload
rm -f "${summary_file_local}" > /dev/null 2>&1
fio \
--name="${test_name}" \
--output-format="json" \
--filename="${workload_file}" \
--size="${workload_size}" \
--rate_process="${rate_process}" \
--runtime="${runtime}" \
--ioengine="${ioengine}" \
--rw="${io_type}" \
--direct="${disable_buffered}" \
--numjobs="${num_jobs}" \
--blocksize="${block_size}" \
--ramp_time="${rt}" \
--iodepth="${iodepth}" \
--gtod_reduce="1" \
--randrepeat="1" \
| tee -a ${summary_file_local} > /dev/null 2>&1
}

function print_latest_results() {
[ ! -f "${summary_file_local}" ] && echo "Error: no results to display; you must run a test before requesting results display" && exit 1
echo "$(cat ${summary_file_local})"
}

function delete_workload() {
rm -f "${workload_file}" > /dev/null 2>&1
}

function main() {
local action="${1:-}"
num_jobs="${2:-1}"

[[ ! ${num_jobs} =~ ^[0-9]+$ ]] && die "The number of jobs must be a positive integer"

case "${action}" in
run-read-4k) launch_workload ;;
run-read-64k) block_size="64k" && launch_workload ;;

run-write-4k) io_type="write" && launch_workload ;;
run-write-64k) block_size="64k" && io_type="write" && launch_workload ;;

run-randread-4k) io_type="randread" && launch_workload ;;
run-randread-64k) block_size="64k" && io_type="randread" && launch_workload ;;

run-randwrite-4k) io_type="randwrite" && launch_workload ;;
run-randwrite-64k) block_size="64k" && io_type="randwrite" && launch_workload ;;

print-latest-results) print_latest_results ;;
delete-workload) delete_workload ;;

*) >&2 echo "Invalid argument" ; help ; exit 1;;
esac
}

main "$@"
1 change: 0 additions & 1 deletion tests/metrics/storage/fio-k8s/.gitignore

This file was deleted.

31 changes: 0 additions & 31 deletions tests/metrics/storage/fio-k8s/Makefile

This file was deleted.

30 changes: 0 additions & 30 deletions tests/metrics/storage/fio-k8s/README.md

This file was deleted.

27 changes: 0 additions & 27 deletions tests/metrics/storage/fio-k8s/cmd/fiotest/Makefile

This file was deleted.

24 changes: 0 additions & 24 deletions tests/metrics/storage/fio-k8s/cmd/fiotest/go.mod

This file was deleted.

31 changes: 0 additions & 31 deletions tests/metrics/storage/fio-k8s/cmd/fiotest/go.sum

This file was deleted.

Loading

0 comments on commit a2159a6

Please sign in to comment.