summaryrefslogtreecommitdiff
path: root/automated
diff options
context:
space:
mode:
authorMilosz Wasilewski <milosz.wasilewski@linaro.org>2016-11-03 23:51:53 +0000
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2016-11-08 18:04:04 +0000
commit16e827cb54e7a82d5b77a49ef2f299a6aeaf552c (patch)
treea74c56b6ca893d17e21f14b4e2d806cca92a95e7 /automated
parentdc79285fe3617185e5151ee2173e248a5ee424c1 (diff)
automated: added apache-bench
This tests runs apache-bench (ab) against apache2 webserver. Change-Id: I9dc13a17d8e1db3f23f88cd77e7e89c227411025 Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
Diffstat (limited to 'automated')
-rwxr-xr-xautomated/linux/apache-apache-bench/apache-bench.sh76
-rw-r--r--automated/linux/apache-apache-bench/apache-bench.yaml33
-rw-r--r--automated/linux/apache-apache-bench/html/index.html11
3 files changed, 120 insertions, 0 deletions
diff --git a/automated/linux/apache-apache-bench/apache-bench.sh b/automated/linux/apache-apache-bench/apache-bench.sh
new file mode 100755
index 0000000..551ce7f
--- /dev/null
+++ b/automated/linux/apache-apache-bench/apache-bench.sh
@@ -0,0 +1,76 @@
+#!/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>]" 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}"
+
+# Install apache and use systemctl for service management. Tested on Ubuntu 16.04,
+# Debian 8, CentOS 7 and Fedora 24. systemctl should available on newer releases
+# as well.
+if [ "${SKIP_INSTALL}" = "True" ] || [ "${SKIP_INSTALL}" = "true" ]; then
+ warn_msg "Apache package installation skipped"
+else
+ dist_name
+ # shellcheck disable=SC2154
+ case "${dist}" in
+ Debian|Ubuntu)
+ pkgs="apache2 apache2-utils"
+ install_deps "${pkgs}"
+ systemctl restart apache2
+ ;;
+ CentOS|Fedora)
+ pkgs="httpd httpd-tools"
+ install_deps "${pkgs}"
+ systemctl start httpd.service
+ ;;
+ *)
+ error_msg "Unsupported distribution!"
+ esac
+fi
+
+cp ./html/* /var/www/html/
+
+# Test Apachebench on Apache.
+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/apache-apache-bench/apache-bench.yaml b/automated/linux/apache-apache-bench/apache-bench.yaml
new file mode 100644
index 0000000..df5942f
--- /dev/null
+++ b/automated/linux/apache-apache-bench/apache-bench.yaml
@@ -0,0 +1,33 @@
+metadata:
+ format: Lava-Test Test Definition 1.0
+ name: apache-apache-bench
+ description: "Apachebench is a benchmark created to measure
+ the webserver performance on HTTP protocol. This
+ test runs apachebench against apache webserver"
+ maintainer:
+ - milosz.wasilewski@linaro.org
+ os:
+ - debian
+ - ubuntu
+ - centos
+ - fedora
+ scope:
+ - functional
+ devices:
+ - mustang
+ - overdrive
+ - d02
+ - d03
+
+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/apache-apache-bench/
+ - ./apache-bench.sh -s "${SKIP_INSTALL}" -n "${NUMBER}" -c "${CONCURENT}"
+ - ../../utils/send-to-lava.sh ./output/result.txt
diff --git a/automated/linux/apache-apache-bench/html/index.html b/automated/linux/apache-apache-bench/html/index.html
new file mode 100644
index 0000000..4529cd4
--- /dev/null
+++ b/automated/linux/apache-apache-bench/html/index.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title></title>
+</head>
+<body>
+
+<h1>Test Page for the Apache HTTP Server</h1>
+
+</body>
+</html>