summaryrefslogtreecommitdiff
path: root/automated
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2016-11-09 13:16:41 +0000
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2016-11-15 19:30:42 +0000
commit06f6c6ddebc6f63db46c3672ab93b41719f74caa (patch)
tree5ba77e6136d5c4fef206bee45db4a04158374177 /automated
parentbe830ebbb393c92bff362f7679b99a96c98f836a (diff)
automated: added nginx-apache-bench
The test runs apache-bench against ngingx webserver Change-Id: I8f18d04dad791b4e408c71fc64db58ce2cd8a853 Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
Diffstat (limited to 'automated')
-rwxr-xr-xautomated/linux/nginx-apache-bench/apache-bench.sh84
-rw-r--r--automated/linux/nginx-apache-bench/apache-bench.yaml33
2 files changed, 117 insertions, 0 deletions
diff --git a/automated/linux/nginx-apache-bench/apache-bench.sh b/automated/linux/nginx-apache-bench/apache-bench.sh
new file mode 100755
index 0000000..f4c774c
--- /dev/null
+++ b/automated/linux/nginx-apache-bench/apache-bench.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+
+
+. ../../lib/sh-test-lib
+OUTPUT="$(pwd)/output"
+RESULT_FILE="${OUTPUT}/result.txt"
+LOGFILE="${OUTPUT}/ablog.txt"
+
+usage() {
+ echo "Usage: $0 [-s <true|false>] [-n <numer_or_requests>] [-c <number_of_requests_at_a_time>] " 1>&2
+ exit 1
+}
+
+NUMBER=1000
+CONCURENT=100
+
+while getopts "s:n:c:" o; do
+ case "$o" in
+ n) NUMBER="${OPTARG}" ;;
+ c) CONCURENT="${OPTARG}" ;;
+ s) SKIP_INSTALL="${OPTARG}" ;;
+ *) usage ;;
+ esac
+done
+
+! check_root && error_msg "This script must be run as root"
+[ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)"
+mkdir -p "${OUTPUT}"
+
+dist_name
+# Install and configure LEMP.
+# systemctl available on Debian 8, CentOS 7 and newer releases.
+# shellcheck disable=SC2154
+case "${dist}" in
+ Debian)
+ pkgs="nginx apache2-utils"
+ install_deps "${pkgs}" "${SKIP_INSTALL}"
+
+ # Stop apache server in case it is installed and running.
+ systemctl stop apache2 > /dev/null 2>&1 || true
+
+ systemctl restart nginx
+ ;;
+ CentOS)
+ # x86_64 nginx package can be installed from epel repo. However, epel
+ # project doesn't support ARM arch yet. RPB repo should provide nginx.
+ [ "$(uname -m)" = "x86_64" ] && install_deps "epel-release" "${SKIP_INSTALL}"
+ pkgs="nginx httpd-tools"
+ install_deps "${pkgs}" "${SKIP_INSTALL}"
+
+ # Stop apache server in case it is installed and running.
+ systemctl stop httpd.service > /dev/null 2>&1 || true
+
+ systemctl restart nginx
+ ;;
+ *)
+ info_msg "Supported distributions: Debian, CentOS"
+ error_msg "Unsupported distribution: ${dist}"
+ ;;
+esac
+
+# Test Apachebench on NGiNX.
+# Default index page should be OK to run ab test
+ab -n "${NUMBER}" -c "${CONCURENT}" "http://localhost/index.html" | tee "${LOGFILE}"
+# shellcheck disable=SC2129
+grep "Time taken for tests:" "${LOGFILE}" | awk '{print "Time-taken-for-tests pass " $5 " s"}' >> "${RESULT_FILE}"
+# shellcheck disable=SC2129
+grep "Complete requests:" "${LOGFILE}" | awk '{print "Complete-requests pass " $3 " items"}' >> "${RESULT_FILE}"
+# shellcheck disable=SC2129
+grep "Failed requests:" "${LOGFILE}" | awk '{ORS=""} {print "Failed-requests "; if ($3==0) {print "pass "} else {print "fail "}; print $3 " items\n" }' >> "${RESULT_FILE}"
+# shellcheck disable=SC2129
+grep "Write errors:" "${LOGFILE}" | awk '{ORS=""} {print "Write-errors "; if ($3==0) {print "pass "} else {print "fail "}; print $3 " items\n" }' >> "${RESULT_FILE}"
+# shellcheck disable=SC2129
+grep "Total transferred:" "${LOGFILE}" | awk '{print "Total-transferred pass " $3 " bytes"}' >> "${RESULT_FILE}"
+# shellcheck disable=SC2129
+grep "HTML transferred:" "${LOGFILE}" | awk '{print "HTML-transferred pass " $3 " bytes"}' >> "${RESULT_FILE}"
+# shellcheck disable=SC2129
+grep "Requests per second:" "${LOGFILE}" | awk '{print "Requests-per-second pass " $4 " #/s"}' >> "${RESULT_FILE}"
+# shellcheck disable=SC2129
+grep "Time per request:" "${LOGFILE}" | grep -v "across" | awk '{print "Time-per-request-mean pass " $4 " ms"}' >> "${RESULT_FILE}"
+# shellcheck disable=SC2129
+grep "Time per request:" "${LOGFILE}" | grep "across" | awk '{print "Time-per-request-concurent pass " $4 " ms"}' >> "${RESULT_FILE}"
+# shellcheck disable=SC2129
+grep "Transfer rate:" "${LOGFILE}" | awk '{print "Transfer-rate pass " $3 " kb/s"}' >> "${RESULT_FILE}"
diff --git a/automated/linux/nginx-apache-bench/apache-bench.yaml b/automated/linux/nginx-apache-bench/apache-bench.yaml
new file mode 100644
index 0000000..3e76f1b
--- /dev/null
+++ b/automated/linux/nginx-apache-bench/apache-bench.yaml
@@ -0,0 +1,33 @@
+metadata:
+ format: Lava-Test Test Definition 1.0
+ name: ngingx-apache-bench
+ description: "Apachebench is a benchmark created to measure
+ the webserver performance on HTTP protocol. This
+ test runs apachebench against apache nginx"
+ maintainer:
+ - milosz.wasilewski@linaro.org
+ os:
+ - debian
+ - centos
+ scope:
+ - performance
+ devices:
+ - mustang
+ - overdrive
+ - thunderX
+ - d02
+ - d03
+ - d05
+
+params:
+ SKIP_INSTALL: "False"
+ # Number of requests to perform
+ NUMBER: 1000
+ # Number of multiple requests to make at a time
+ CONCURENT: 100
+
+run:
+ steps:
+ - cd ./automated/linux/nginx-apache-bench/
+ - ./apache-bench.sh -s "${SKIP_INSTALL}" -n "${NUMBER}" -c "${CONCURENT}"
+ - ../../utils/send-to-lava.sh ./output/result.txt