diff options
author | Rob Kendrick (humdrum) <rob.kendrick@codethink.co.uk> | 2014-02-13 09:40:56 +0000 |
---|---|---|
committer | Rob Kendrick (humdrum) <rob.kendrick@codethink.co.uk> | 2014-02-13 09:40:56 +0000 |
commit | ca9987f399217e6d163a0aaf4b80fb08329e441c (patch) | |
tree | e1ff14a81b41ac0bad4ff3147991b5edc584f1ed /tests | |
parent | 394a6c619cd9458fbd659a70963485b9519cbc04 (diff) | |
download | trove-overseer-ca9987f399217e6d163a0aaf4b80fb08329e441c.tar.gz |
Trove Overseer initial work, and plugins
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/diskfree | 8 | ||||
-rwxr-xr-x | tests/git | 7 | ||||
-rwxr-xr-x | tests/http | 3 | ||||
-rwxr-xr-x | tests/loadavg | 9 | ||||
-rwxr-xr-x | tests/memfree | 3 | ||||
-rwxr-xr-x | tests/morphcache | 31 |
6 files changed, 61 insertions, 0 deletions
diff --git a/tests/diskfree b/tests/diskfree new file mode 100755 index 0000000..d6d29b5 --- /dev/null +++ b/tests/diskfree @@ -0,0 +1,8 @@ +#!/bin/sh + +if [ "x$1" = "x" ]; then + echo expected partition as first argument + exit 1 +fi + +df -P $1 | tail -n1 | awk '{ print $4 * 1024 }' diff --git a/tests/git b/tests/git new file mode 100755 index 0000000..adcecd8 --- /dev/null +++ b/tests/git @@ -0,0 +1,7 @@ +#!/bin/sh + +TEMPDIR=$(mktemp -d) || exit 1 + +git clone --quiet --no-checkout $1 $TEMPDIR || exit 2 + +rm -rf $TEMPDIR diff --git a/tests/http b/tests/http new file mode 100755 index 0000000..a9b2f1d --- /dev/null +++ b/tests/http @@ -0,0 +1,3 @@ +#!/bin/sh + +exec wget --quiet -O /dev/null $1 diff --git a/tests/loadavg b/tests/loadavg new file mode 100755 index 0000000..ad99506 --- /dev/null +++ b/tests/loadavg @@ -0,0 +1,9 @@ +#!/bin/sh + +if [ "x$1" = "x" ]; then + POS=1 +else + POS=$1 +fi + +cut -d' ' -f$POS /proc/loadavg diff --git a/tests/memfree b/tests/memfree new file mode 100755 index 0000000..21bc619 --- /dev/null +++ b/tests/memfree @@ -0,0 +1,3 @@ +#!/bin/sh + +grep "^MemFree:" /proc/meminfo | awk ' { print $2 * 1024 } ' diff --git a/tests/morphcache b/tests/morphcache new file mode 100755 index 0000000..1b355b0 --- /dev/null +++ b/tests/morphcache @@ -0,0 +1,31 @@ +#!/bin/bash + +if [ "$#" -ne 4 ]; then + echo usage: $0 CACHE_SERVER_IP REPO REF FILENAME + exit 1 +fi + +rawurlencode() { + local string="${1}" + local strlen=${#string} + local encoded="" + + for (( pos=0 ; pos<strlen ; pos++ )); do + c=${string:$pos:1} + case "$c" in + [-_.~a-zA-Z0-9] ) o="${c}" ;; + * ) + printf -v o '%%%02x' "'$c" + esac + encoded+="${o}" + done + + echo "${encoded}" +} + +CACHE_SERVER_IP=$1 +REPO=$(rawurlencode "$2") +REF=$(rawurlencode "$3") +FILENAME=$(rawurlencode "$4") + +exec wget -O /dev/null "http://${CACHE_SERVER_IP}:8080/1.0/files?repo=${REPO}&ref=${REF}&filename=${FILENAME}" |