From 7886189bce7196663f4d6075110ffa4bd64cec72 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 20 Dec 2013 13:14:52 +0100 Subject: [PATCH] Add script to stress-test templates API --- tools/performance/stresstest_templates.sh | 53 +++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 tools/performance/stresstest_templates.sh diff --git a/tools/performance/stresstest_templates.sh b/tools/performance/stresstest_templates.sh new file mode 100755 index 00000000..d6888cf0 --- /dev/null +++ b/tools/performance/stresstest_templates.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +verbose=no +tiler_url=http://dev.localhost.lan:8181/tiles/template +apikey=${CDB_APIKEY} + +while test -n "$1"; do + if test "$1" = "-k"; then + shift + apikey="$1" + elif test "$1" = "-u"; then + shift + tiler_url="$1" + elif test -z "$tpl"; then + tpl="$1" + else + echo "Unused parameter $1" >&2 + fi + shift +done + +if test -z "$tpl"; then + echo "Usage: $0 [-v] [-k ] [-u ] " >&2 + echo "Default is ${tiler_url}" >&2 + echo "Default is read from CDB_APIKEY env variable" >&2 + exit 1 +fi + +basedir=$(cd $(dirname $0); cd ..; pwd) +export CDB_APIKEY=${apikey} +max=3000000 +i=0 +while test "$i" -le "$max"; do + tpl_id=`${basedir}/create_template -u ${tiler_url} ${tpl}` + if test $? -ne 0; then + echo $tpl_id >&2 + break + fi + tpl_id=`${basedir}/update_template -u ${tiler_url} ${tpl_id} ${tpl}` + if test $? -ne 0; then + echo $tpl_id >&2 + break + fi + out=`${basedir}/delete_template -u ${tiler_url} ${tpl_id}` + if test $? -ne 0; then + echo $out >&2 + break + fi + i=$((i+1)) + if test `expr $i % 100` -eq 0; then + echo -n "." + fi +done