diff --git a/run.sh b/run.sh old mode 100644 new mode 100755 index 3c1a1b5..fd69a45 --- a/run.sh +++ b/run.sh @@ -1,8 +1,11 @@ #!/bin/bash +# Skip prompts so we can run unattended +export DEBIAN_FRONTEND=noninteractive + if [ $# -eq 0 ]; then - echo 'Missing argument, provider name' - exit 1 + echo 'Missing argument, provider name' + exit 1 fi; PROVIDER=$1 @@ -11,7 +14,10 @@ swapoff -a apt-get update apt-get upgrade -y -apt-get install sysbench apache2 mailutils mysql-server python -y +apt-get install sysbench nginx mysql-server python -y + +# Grabs the major version of sysbench so we can use the correct parameters for MySQL +SYSBENCH_MAJOR_VERSION=$(sysbench --version | cut -d ' ' -f 2 | cut -d '.' -f 1) wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py chmod +x speedtest-cli @@ -29,15 +35,23 @@ sysbench --test=fileio prepare sysbench --test=fileio --file-test-mode=rndrw run > results/fileio.log sysbench --test=fileio cleanup -mysql -uroot -e "CREATE DATABASE sbtest;" -sysbench --test=oltp --oltp-table-size=1000000 --mysql-user=root prepare -sysbench --test=oltp --oltp-table-size=1000000 --mysql-user=root run > results/mysql.log -sysbench --test=oltp --oltp-table-size=1000000 --mysql-user=root cleanup +if [ "$SYSBENCH_MAJOR_VERSION" == "0" ]; then + # Ubuntu 16.04 + mysql -uroot -e "CREATE DATABASE sbtest;" + sysbench --test=oltp --oltp-table-size=1000000 --mysql-user=root prepare + sysbench --test=oltp --oltp-table-size=1000000 --mysql-user=root run > results/mysql.log + sysbench --test=oltp --oltp-table-size=1000000 --mysql-user=root cleanup +else + # Ubuntu 18.04 + mysql -uroot -e "CREATE DATABASE sbtest;" + sysbench --db-driver=mysql --table-size=1000000 --mysql-user=root /usr/share/sysbench/oltp_read_write.lua prepare + sysbench --db-driver=mysql --table-size=1000000 --mysql-user=root /usr/share/sysbench/oltp_read_write.lua run > results/mysql.log + sysbench --db-driver=mysql --table-size=1000000 --mysql-user=root /usr/share/sysbench/oltp_read_write.lua cleanup +fi ./speedtest-cli --server=16089 > results/speedtest1.log ./speedtest-cli --server=16089 > results/speedtest2.log ./speedtest-cli --server=16089 > results/speedtest3.log -ab -kc 1000 -n 10000 http://127.0.0.1/ > results/ab.log - +# Wraps it all up in a nice package tar -zcvf "results-$PROVIDER.tgz" results