Last active
August 29, 2015 14:02
-
-
Save dkua/add85fdb4db267c73e14 to your computer and use it in GitHub Desktop.
Test script to test exit cases in QMD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Sample POST request to /scripts/qmd_bench.sh | |
## | |
## { | |
## "args": ["1", "10"], | |
## "callback_url": "http://192.168.88.88:9090" | |
## } | |
MIN=$1 | |
MAX=$2 | |
PID=$$ | |
echo "Running under PID #$PID" | |
echo "Making file in tmp dir at $QMD_TMP" | |
'Test #$PID' >> $QMD_TMP/$PID | |
echo "Making file in store dir at $QMD_STORE" | |
'Test #$PID' >> $QMD_STORE/$PID | |
while [ $MAX -eq $MAX ] | |
do | |
NUM=`shuf -i $MIN-$MAX -n 1` | |
echo "Randomly selected $NUM" | |
if [ $NUM -eq 7 ] | |
then | |
# Success | |
echo "Job well done!" | |
exit 0 | |
elif [ $NUM -eq 4 ] | |
then | |
# Error | |
echo "Error! Error!" | |
exit 1 | |
elif [ $NUM -eq $MAX ] | |
then | |
# Crash the script | |
echo "Abandon ship! Abandon ship! Everyone for themselves!" | |
kill -SIGHUP $$ | |
else | |
# Sleep | |
echo "zzzzzzzzzzzzzzzzz" | |
sleep $NUM | |
echo "zzzzzz..I'M AWAKE" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment