So I got the job of testing the new java engine. The programmer who created it made me a test jar file so I can test some crashmoments and loadbalancing.
I know it's a load of text here, but I hope someone can give me a great answer! Thanks in advance for reading!
I wanted to automate the testing process so I created a bash file.
So far what it does is loop for a couple of times, in which it starts the jar file:
java -jar /mnt/nas/i/testsail/clusteng.jar 2>> /dev/null &
After that it gets the processId of the just started java app:
process_ids[$i]=$!
So eventually I have like 5 instances of that jar, all with their related processId.
Now my problem is, the programmer added a little shell around the app, in which I can tell it at what moment to crash. If I just start the engine from the commandline, it shows me that shell and I can just type 'fail moment_Of_Faillure' and it will ungracefully fail there.
Ofcourse now I want to give each instance another failmoment, and I want to randomize that from the bash script.
My question is; How can I give commands to each instance from within the bash script?
I will post the complete bash script here:
#!/bin/bash
# Engine testing script; Starts multiple engine instances and shoots one every 20 seconds
clear
echo "#####################"
echo "# Start $1 processes #"
echo "#####################"
echo ""
# create number of processes
for (( i = 1 ; i <= $1; i++ ))
do
if test $i == 1
then
echo "Starting process: $i -> Master Process"
else
echo "Starting process: $i"
fi
#$! = last started process
java -jar /mnt/nas/i/testsail/clusteng.jar 2>> /dev/null &
process_ids[$i]=$!
echo "PID $!"
echo ""
sleep 20
done
sleep 20
for (( i = 1 ; i <= $1; i++ ))
do
echo "Kill PID:${process_ids[$i]}"
#ech `FAIL BEFORE_RANK_DISTRIBUTION` > fifo$i
kill -9 ${process_ids[$i]}
echo ""
if test $i != $1
then
sleep 20
fi
done
# run errorcheck
. `./checklogs`