github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/metrics/storage/fio-k8s/scripts/dax-compare-test/compare-virtiofsd-dax.sh (about)

     1  #!/bin/bash
     2  #Copyright (c) 2021 Intel Corporation
     3  #
     4  #SPDX-License-Identifier: Apache-2.0
     5  #
     6  
     7  set -o errexit
     8  set -o nounset
     9  set -o pipefail
    10  set -o errtrace
    11  
    12  script_dir=$(dirname "$(readlink -f "$0")")
    13  
    14  runtime_path="/usr/local/bin/kata-runtime"
    15  kata_config_path="/usr/share/defaults/kata-containers/configuration.toml"
    16  
    17  results_dir="$(realpath ./)/results"
    18  
    19  KATA_RUNTIME="${KATA_RUNTIME_CLASS:-kata}"
    20  BAREMETAL_RUNTIME="runc"
    21  RUNTIME_CLASS=""
    22  
    23  FIO_SIZE="${FIO_SIZE:-500M}"
    24  FIO_BLOCKSIZE="${FIO_BLOCKSIZE:-4K}"
    25  VIRTIOFS_DAX_SIZE=${VIRTIOFS_DAX_SIZE:-600M}
    26  
    27  # set the base case for virtiofsd
    28  set_base_virtiofs_config() {
    29  	# Running kata-qemu-virtiofs
    30  	# Defaults for virtiofs
    31  	sudo crudini --set --existing "$kata_config_path" hypervisor.qemu virtio_fs_cache '"auto"'
    32  	sudo crudini --set --existing "$kata_config_path" hypervisor.qemu virtio_fs_cache_size ${VIRTIOFS_DAX_SIZE}
    33  }
    34  
    35  ## helper function: get name of current bash function
    36  fn_name() {
    37  	echo "${FUNCNAME[1]}"
    38  }
    39  
    40  # directory where results are stored
    41  get_results_dir() {
    42  	local test_name
    43  	local test_result_dir
    44  	test_name="${1}"
    45  	test_result_dir="${results_dir}/${test_name}"
    46  	mkdir -p "${test_result_dir}"
    47  	echo "${test_result_dir}"
    48  }
    49  
    50  # Collect kata env
    51  # save kata config toml
    52  # save output from kata-env
    53  kata_env() {
    54  	local suffix=${1}
    55  	local config_path
    56  	local kata_env_bk
    57  	local kata_config_bk
    58  	kata_env_bk="$(get_results_dir "${suffix}")/kata-env.toml"
    59  	kata_config_bk="$(get_results_dir "${suffix}")/kata-config.toml"
    60  
    61  	${runtime_path} kata-env >"${kata_env_bk}"
    62  	config_path="$(${runtime_path} kata-env --json | jq .Runtime.Config.Path -r)"
    63  	cp "${config_path}" "${kata_config_bk}"
    64  }
    65  
    66  # Collect the command used by virtiofsd
    67  collect_qemu_virtiofs_cmd() {
    68  	local rdir
    69  	local test_name
    70  	test_name="${1}"
    71  
    72  	rdir=$(get_results_dir "${test_name}")
    73  	# TODO
    74  }
    75  
    76  # Run metrics runner
    77  run_workload() {
    78  	local test_name
    79  	local test_result_file
    80  	local test_result_dir
    81  
    82  	test_name="${1}"
    83  
    84  	test_result_dir="$(get_results_dir "${test_name}")"
    85  	test_result_file="${test_result_dir}/test-out.txt"
    86  
    87  	echo "Running for kata config: ${test_name}"
    88  	collect_qemu_virtiofs_cmd "$test_name"
    89  
    90  	fio_runner_dir="${script_dir}/../../cmd/fiotest/"
    91  	fio_jobs="${script_dir}/../../configs/test-config/"
    92  	make -C "${fio_runner_dir}" build
    93  	pwd
    94  	set -x
    95  	"${fio_runner_dir}fio-k8s" \
    96  		--debug \
    97  		--fio.size "${FIO_SIZE}" \
    98  		--fio.block-size "${FIO_BLOCKSIZE}" \
    99  		--container-runtime "${RUNTIME_CLASS}" \
   100  		--test-name "${test_name}" \
   101  		--output-dir "$(dirname ${test_result_dir})" \
   102  		"${fio_jobs}" |
   103  		tee \
   104  			"${test_result_file}"
   105  	set +x
   106  }
   107  
   108  pool_0_cache_auto_dax() {
   109  	local suffix="$(fn_name)"
   110  
   111  	set_base_virtiofs_config
   112  	sudo crudini --set --existing "$kata_config_path" hypervisor.qemu virtio_fs_extra_args '["--thread-pool-size=0","-o","no_posix_lock","-o","xattr"]'
   113  	sudo crudini --set --existing "$kata_config_path" hypervisor.qemu virtio_fs_cache '"auto"'
   114  	sudo crudini --set --existing "$kata_config_path" hypervisor.qemu virtio_fs_cache_size 1024
   115  	kata_env "${suffix}"
   116  	RUNTIME_CLASS="${KATA_RUNTIME}"
   117  	run_workload "${suffix}"
   118  }
   119  
   120  pool_0_cache_auto_no_dax() {
   121  	local suffix="$(fn_name)"
   122  
   123  	set_base_virtiofs_config
   124  	sudo crudini --set --existing "$kata_config_path" hypervisor.qemu virtio_fs_extra_args '["--thread-pool-size=0","-o","no_posix_lock","-o","xattr"]'
   125  	sudo crudini --set --existing "$kata_config_path" hypervisor.qemu virtio_fs_cache '"auto"'
   126  	sudo crudini --set --existing "$kata_config_path" hypervisor.qemu virtio_fs_cache_size 0
   127  
   128  	kata_env "${suffix}"
   129  
   130  	RUNTIME_CLASS="${KATA_RUNTIME}"
   131  	run_workload "${suffix}"
   132  	echo "done"
   133  }
   134  
   135  k8s_baremetal() {
   136  	local suffix="$(fn_name)"
   137  
   138  	RUNTIME_CLASS="${BAREMETAL_RUNTIME}"
   139  	run_workload "${suffix}"
   140  }
   141  
   142  main() {
   143  
   144  	mkdir -p "${results_dir}"
   145  
   146  	k8s_baremetal
   147  	pool_0_cache_auto_dax
   148  	pool_0_cache_auto_no_dax
   149  }
   150  
   151  main $*