diff options
Diffstat (limited to 'helper_scripts')
-rwxr-xr-x | helper_scripts/glusterfs-precreate.sh | 32 | ||||
-rwxr-xr-x | helper_scripts/untar-remove.sh | 103 |
2 files changed, 135 insertions, 0 deletions
diff --git a/helper_scripts/glusterfs-precreate.sh b/helper_scripts/glusterfs-precreate.sh new file mode 100755 index 0000000..c5b62a2 --- /dev/null +++ b/helper_scripts/glusterfs-precreate.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e; + +if [ $# -eq 0 ]; then + echo "Usage: $0 <dir1> [dir2 [dir3 [dir4 ...]]]"; + exit 1 +fi + +for dir in "$@"; do + if [ ! -d "$dir" ]; then + echo "$0: $dir not a directory" + exit 1; + fi +done + +subdirs="{00" +for i in {1..255}; do + n=$(printf "%02x" $i); + subdirs="$subdirs,$n"; +done +subdirs="$subdirs}" + +mkdir -vp "$dir/.glusterfs"; + +for dir in $@; do + for i in {0..255}; do + n=$(printf "%02x" $i); + mkdir -vp "$dir/.glusterfs/$n" + eval "mkdir -vp $dir/.glusterfs/$n/$subdirs" + done +done
\ No newline at end of file diff --git a/helper_scripts/untar-remove.sh b/helper_scripts/untar-remove.sh new file mode 100755 index 0000000..3b7bad3 --- /dev/null +++ b/helper_scripts/untar-remove.sh @@ -0,0 +1,103 @@ +#!/bin/bash + +function _init () +{ + set -e; + + if [ $# -lt 2 ]; then + echo "Continuing tests with current working directory." + M=$PWD; + else + if [ ! -d $2 ]; then + echo "2nd argument needs to be a valid directory." + exit 42; + else + M=$2; + fi + fi + + if echo $1 | egrep -q '^[0-9]+$'; then + T=$1; + else + echo "First argument was not a number, continuing with default" + T=600; + fi + echo $T + export pid_untar; + export pid_remove; +} + +function run_tests() +{ + old_PWD=$PWD; + cd $M; + + sleep 1; + untar & + sleep 2; + remove_kernel & + + sleep $T; + + cd $old_PWD; +} + +function untar () +{ + cd $M; + while true + do + tar -xjf /opt/qa/tools/linux-2.6.31.1.tar.bz2 & + pid_untar=$!; + wait $pid_untar; + done +} + +function remove_kernel () +{ + while true + do + rm -rf $M/linux-2.6.31.1 & + pid_remove=$!; + wait $pid_remove; + done +} + +function watchdog () +{ + # insurance against hangs during the test + + sleep $1; + + echo "Kicking in watchdog after $1 secs"; +} + + +function finish () +{ + for i in $(jobs -pr) + do + echo "killing jobs" + kill -KILL $i; + sleep 2; + done + + sleep 10; + + rm -rf $M/linux-2.6.31.1 & + cleanup_remove=$!; + wait $cleanup_remove; +} + +function main () +{ + watchdog $T & + + trap finish INT EXIT; + + set -x; + + run_tests; +} + +_init "$@" && main "$@"; |