Last active
August 16, 2017 08:56
-
-
Save pfcoperez/fd1e7e47443ee62dcac02af8de32bc5b to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
function launchIteration { | |
CMD=$1 | |
STOP_OUTPUT_PATTERN=$2 | |
OUTPUT_DIR=$3 | |
REMAINING_ITERATIONS=$4 | |
if [[ $REMAINING_ITERATIONS == "0" ]]; then | |
echo "Completed launch chain" | |
return 0 | |
fi | |
OUT_FILE="$OUTPUT_DIR/iteration${REMAINING_ITERATIONS}.out" | |
#eval $CMD > "$OUT_FILE" & | |
( eval $CMD > "$OUT_FILE" & ) | |
tail -f $OUT_FILE | while read l; do | |
if [[ $l == *"$STOP_OUTPUT_PATTERN"* ]]; then | |
break | |
fi | |
done | |
launchIteration "$CMD" "$STOP_OUTPUT_PATTERN" $OUTPUT_DIR $((REMAINING_ITERATIONS - 1)) | |
} | |
TRIGGER_PATTERN=$1 | |
N_PROCESSES=$2 | |
LOG_DIR=$3 | |
COMMAND=$4 | |
echo "Concurrent test" | |
echo " Stop output pattern: $TRIGGER_PATTERN" | |
echo " No. concurrent executions: $N_PROCESSES" | |
echo " Output log directory: $LOG_DIR" | |
echo " Command: $COMMAND" | |
launchIteration "$COMMAND" "$TRIGGER_PATTERN" $LOG_DIR $N_PROCESSES |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment