summaryrefslogtreecommitdiff
path: root/automated/linux
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2017-01-09 16:28:04 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-01-19 11:58:17 +0000
commitdc409a3ba962d1dca98f1cae6ab8c87627a68cd9 (patch)
treeecfdd0b1d2bb7ca87abace65225d6ead7331adf0 /automated/linux
parent9aac9f8dd6ae10f9186edaca58fe43df3203ac63 (diff)
downloadtest-definitions-pipe-dc409a3ba962d1dca98f1cae6ab8c87627a68cd9.tar.gz
automated: linux: add sysbench test
Change-Id: Ia09a192f011124902b76523bed81acbdfb250e6c Signed-off-by: Chase Qi <chase.qi@linaro.org>
Diffstat (limited to 'automated/linux')
-rwxr-xr-xautomated/linux/sysbench/sysbench.sh183
-rw-r--r--automated/linux/sysbench/sysbench.yaml42
2 files changed, 225 insertions, 0 deletions
diff --git a/automated/linux/sysbench/sysbench.sh b/automated/linux/sysbench/sysbench.sh
new file mode 100755
index 0000000..6c54a84
--- /dev/null
+++ b/automated/linux/sysbench/sysbench.sh
@@ -0,0 +1,183 @@
+#!/bin/sh -e
+
+# SysBench is a modular, cross-platform and multi-threaded benchmark tool.
+# Current features allow to test the following system parameters:
+# * file I/O performance
+# * scheduler performance
+# * memory allocation and transfer speed
+# * POSIX threads implementation performance
+# * database server performance
+
+# shellcheck disable=SC1091
+. ../../lib/sh-test-lib
+
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+export RESULT_FILE
+SKIP_INSTALL="false"
+
+# sysbench test parameters.
+NUM_THREADS="1"
+TESTS="cpu memory threads mutex fileio oltp"
+
+usage() {
+ echo "usage: $0 [-n <num-threads>] [-t <test>] [-s <true|false>] 1>&2"
+ exit 1
+}
+
+while getopts "n:t:s:h" opt; do
+ case "${opt}" in
+ n) NUM_THREADS="${OPTARG}" ;;
+ t) TESTS="${OPTARG}" ;;
+ s) SKIP_INSTALL="${OPTARG}" ;;
+ h|*) usage ;;
+ esac
+done
+
+install_sysbench() {
+ git clone https://github.com/akopytov/sysbench
+ cd sysbench
+ git checkout 0.4
+ ./autogen.sh
+ ./configure "$1"
+ make install
+ cd ../
+}
+
+! check_root && error_msg "Please run this script as root."
+[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)"
+mkdir -p "${OUTPUT}"
+cd "${OUTPUT}"
+
+# Test installation.
+if [ "${SKIP_INSTALL}" = "true" ] || [ "${SKIP_INSTALL}" = "True" ]; then
+ info_msg "sysbench installation skipped"
+else
+ dist_name
+ # shellcheck disable=SC2154
+ case "${dist}" in
+ Debian|Ubuntu)
+ install_deps "git build-essential automake libtool"
+ if echo "${TESTS}" | grep "oltp"; then
+ install_deps "libmysqlclient-dev mysql-server"
+ systemctl start mysql
+ install_sysbench
+ else
+ install_sysbench "--without-mysql"
+ fi
+ ;;
+ Fedora|CentOS)
+ install_deps "git gcc make automake libtool"
+ if echo "${TESTS}" | grep "oltp"; then
+ install_deps "mysql-devel mariadb-server mariadb"
+ systemctl start mariadb
+ install_sysbench
+ else
+ install_sysbench "--without-mysql"
+ fi
+ ;;
+ Unknown)
+ warn_msg "Unsupported distro: package install skipped"
+ ;;
+ esac
+fi
+
+# Verify test installation.
+sysbench --version
+
+general_parser() {
+ ms=$(grep -m 1 "total time" "${logfile}" | awk '{print substr($NF,1,length($NF)-1)}')
+ add_metric "${tc}-total-time" "pass" "${ms}" "s"
+
+ ms=$(grep "total number of events" "${logfile}" | awk '{print $NF}')
+ add_metric "${tc}-total-number-of-events" "pass" "${ms}" "times"
+
+ ms=$(grep "total time taken by event execution" "${logfile}" | awk '{print $NF}')
+ add_metric "${tc}-total-time-taken-by-event-execution" "pass" "${ms}" "s"
+
+ for i in min avg max approx; do
+ ms=$(grep -m 1 "$i" "${logfile}" | awk '{print substr($NF,1,length($NF)-2)}')
+ add_metric "${tc}-response-time-$i" "pass" "${ms}" "ms"
+ done
+
+ ms=$(grep "events (avg/stddev)" "${logfile}" | awk '{print $NF}')
+ add_metric "${tc}-events-avg/stddev" "pass" "${ms}" "times"
+
+ ms=$(grep "execution time (avg/stddev)" "${logfile}" | awk '{print $NF}')
+ add_metric "${tc}-execution-time-avg/stddev" "pass" "${ms}" "s"
+}
+
+# Test run.
+for tc in ${TESTS}; do
+ echo
+ info_msg "Running sysbench ${tc} test..."
+ logfile="${OUTPUT}/sysbench-${tc}.txt"
+ case "${tc}" in
+ cpu|threads|mutex)
+ sysbench --num-threads="${NUM_THREADS}" --test="${tc}" run | tee "${logfile}"
+ general_parser
+ ;;
+ memory)
+ sysbench --num-threads="${NUM_THREADS}" --test=memory run | tee "${logfile}"
+ general_parser
+
+ ms=$(grep "Operations" "${logfile}" | awk '{print substr($4,2)}')
+ add_metric "${tc}-ops" "pass" "${ms}" "ops"
+
+ ms=$(grep "transferred" "${logfile}" | awk '{print substr($4, 2)}')
+ units=$(grep "transferred" "${logfile}" | awk '{print substr($5,1,length($NF)-1)}')
+ add_metric "${tc}-transfer" "pass" "${ms}" "${units}"
+ ;;
+ fileio)
+ mkdir fileio && cd fileio
+ for mode in seqwr seqrewr seqrd rndrd rndwr rndrw; do
+ tc="fileio-${mode}"
+ logfile="${OUTPUT}/sysbench-${tc}.txt"
+ sync
+ echo 3 > /proc/sys/vm/drop_caches
+ sleep 5
+ sysbench --num-threads="${NUM_THREADS}" --test=fileio --file-total-size=2G --file-test-mode="${mode}" prepare
+ # --file-extra-flags=direct is needed when file size is smaller then RAM.
+ sysbench --num-threads="${NUM_THREADS}" --test=fileio --file-extra-flags=direct --file-total-size=2G --file-test-mode="${mode}" run | tee "${logfile}"
+ sysbench --num-threads="${NUM_THREADS}" --test=fileio --file-total-size=2G --file-test-mode="${mode}" cleanup
+ general_parser
+
+ ms=$(grep "transferred" "${logfile}" | awk '{print substr($NF, 2,(length($NF)-8))}')
+ units=$(grep "transferred" "${logfile}" | awk '{print substr($NF,(length($NF)-6),6)}')
+ add_metric "${tc}-transfer" "pass" "${ms}" "${units}"
+
+ ms=$(grep "Requests/sec" "${logfile}" | awk '{print $1}')
+ add_metric "${tc}-ops" "pass" "${ms}" "ops"
+ done
+ cd ../
+ ;;
+ oltp)
+ # Use the same passwd as lamp and lemp tests.
+ mysqladmin -u root password lxmptest > /dev/null 2>&1 || true
+ # Delete sysbench in case it exists.
+ mysql --user='root' --password='lxmptest' -e 'DROP DATABASE sysbench' > /dev/null 2>&1 || true
+ # Create sysbench database.
+ mysql --user="root" --password="lxmptest" -e "CREATE DATABASE sysbench"
+
+ sysbench --num-threads="${NUM_THREADS}" --test=oltp --db-driver=mysql --oltp-table-size=1000000 --mysql-db=sysbench --mysql-user=root --mysql-password=lxmptest prepare
+ sysbench --num-threads="${NUM_THREADS}" --test=oltp --db-driver=mysql --oltp-table-size=1000000 --mysql-db=sysbench --mysql-user=root --mysql-password=lxmptest run | tee "${logfile}"
+
+ # Parse test log.
+ general_parser
+
+ for i in "read" write other total; do
+ ms=$(grep "${i}:" "${logfile}" | awk '{print $NF}')
+ add_metric "${tc}-${i}-queries" "pass" "${ms}" "queries"
+ done
+
+ for i in transactions deadlocks "read/write requests" "other operations"; do
+ ms=$(grep "${i}:" sysbench-oltp.txt | awk '{print substr($(NF-2),2)}')
+ i=$(echo "$i" | sed 's/ /-/g')
+ add_metric "${tc}-${i}" "pass" "${ms}" "ops"
+ done
+
+ # cleanup
+ mysql --user='root' --password='lxmptest' -e 'DROP DATABASE sysbench'
+ ;;
+ esac
+done
diff --git a/automated/linux/sysbench/sysbench.yaml b/automated/linux/sysbench/sysbench.yaml
new file mode 100644
index 0000000..453eb74
--- /dev/null
+++ b/automated/linux/sysbench/sysbench.yaml
@@ -0,0 +1,42 @@
+metadata:
+ name: sysbench
+ format: "Lava-Test-Shell Test Definition 1.0"
+ description: "SysBench is a modular, cross-platform and multi-threaded
+ benchmark tool for evaluating OS parameters that are
+ important for a system running a database under intensive
+ load. Current features allow to test fileio, cpu, memory,
+ threads, mutex and oltp."
+ maintainer:
+ - chase.qi@linaro.org
+ os:
+ - debian
+ - ubuntu
+ - fedora
+ - centos
+ scope:
+ - performance
+ environment:
+ - lava-test-shell
+ devices:
+ - hi6220-hikey
+ - apq8016-sbc
+ - mustang
+ - moonshot
+ - thunderX
+ - d03
+ - d05
+
+params:
+ # "${TESTS}" could be one more of the following tests.
+ # TESTS: "oltp"
+ # TESTS: "fileio oltp"
+ TESTS: "cpu memory threads mutex fileio oltp"
+ # Number of threads to use.
+ NUM_THREADS: "1"
+ SKIP_INSTALL: "false"
+
+run:
+ steps:
+ - cd ./automated/linux/sysbench/
+ - ./sysbench.sh -n "${NUM_THREADS}" -t "${TESTS}" -s "${SKIP_INSTALL}"
+ - ../../utils/send-to-lava.sh ./output/result.txt