| [c2f543] | 1 | #!/bin/bash
 | 
|---|
 | 2 | 
 | 
|---|
 | 3 | read -d '' CHANGEME << "EOF"
 | 
|---|
 | 4 | 
 | 
|---|
 | 5 | # start service in background
 | 
|---|
 | 6 | ${AUTOTEST_PATH}/molecuilder_server --signal 2 --workerport $WORKERPORT --controllerport $CONTROLLERPORT &
 | 
|---|
 | 7 | server_pid=$!
 | 
|---|
 | 8 | AT_CHECK([sleep 2], 0, [ignore], [ignore], [kill $server_pid])
 | 
|---|
 | 9 | AT_CHECK([kill -s 0 $server_pid], 0, [ignore], [ignore], [kill $server_pid])
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 | # enlist a worker to work on jobs
 | 
|---|
 | 12 | ../../molecuilder_mpqc +v 5 ++signal 2 ++server 127.0.0.1:${WORKERPORT} ++hostname 127.0.0.1 ++listen $WORKERLISTENPORT &
 | 
|---|
 | 13 | worker_pid=$!
 | 
|---|
 | 14 | AT_CHECK([sleep 2], 0, [ignore], [ignore], [kill $server_pid $worker_pid])
 | 
|---|
 | 15 | AT_CHECK([kill -s 0 $worker_pid], 0, [ignore], [ignore], [kill $server_pid $worker_pid])
 | 
|---|
 | 16 | EOF
 | 
|---|
 | 17 | 
 | 
|---|
 | 18 | read -d '' CHANGETOO << "EOF"
 | 
|---|
 | 19 | 
 | 
|---|
 | 20 | # send removeall to server such that all workers shutdown
 | 
|---|
 | 21 | AT_CHECK([${AUTOTEST_PATH}/molecuilder_controller --server 127.0.0.1:$CONTROLLERPORT --command removeall], 0, [ignore], [ignore], [kill $server_pid $worker_pid])
 | 
|---|
 | 22 | 
 | 
|---|
 | 23 | # shutdown controller socket 
 | 
|---|
 | 24 | AT_CHECK([${AUTOTEST_PATH}/molecuilder_controller --server 127.0.0.1:$CONTROLLERPORT --command shutdown], 0, [stdout], [ignore], [kill $server_pid $worker_pid])
 | 
|---|
 | 25 | 
 | 
|---|
 | 26 | # check that worker is truly down
 | 
|---|
 | 27 | AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $server_pid $worker_pid])
 | 
|---|
 | 28 | AT_CHECK([kill $worker_pid], 1, [ignore], [ignore], [kill $server_pid])
 | 
|---|
 | 29 | 
 | 
|---|
 | 30 | # check that server is truly down
 | 
|---|
 | 31 | AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $server_pid])
 | 
|---|
 | 32 | AT_CHECK([kill $server_pid], 1, [ignore], [ignore])
 | 
|---|
 | 33 | 
 | 
|---|
 | 34 | # check calculated energy
 | 
|---|
 | 35 | AT_CHECK([cat energy_stdout | awk -v energy=$ENERGY 'function abs(x){return ((x < 0.0) ? -x : x)} {if (abs(($1 - energy)/energy) > 1e-5) exit(1)}'], 0, [stdout], [stderr])
 | 
|---|
 | 36 | EOF
 | 
|---|
 | 37 | 
 | 
|---|
 | 38 | wport=3000
 | 
|---|
 | 39 | for file in `find . -name 'testsuite-calculations-*.at'`; do
 | 
|---|
 | 40 | 
 | 
|---|
 | 41 | newfilename=`echo "$file" | sed -e "s#-calculations-#-calculations-jobmarket-#"`
 | 
|---|
 | 42 | 
 | 
|---|
 | 43 | 
 | 
|---|
 | 44 | let cport=$wport+1
 | 
|---|
 | 45 | let lport=$cport+1
 | 
|---|
 | 46 | 
 | 
|---|
 | 47 | firstline=` grep -n AT_SKIP $file | awk -F":" '{print $1}'`
 | 
|---|
 | 48 | secondline=` grep -n "AT_CHECK(\[cat stdout" $file | awk -F":" '{print $1}'`
 | 
|---|
 | 49 | 
 | 
|---|
 | 50 | sed -e "${firstline},1000d" $file >$newfilename
 | 
|---|
 | 51 | echo -e "\n# check that ports are unique over all tests such that they may run in parallel\nWORKERPORT=${wport}\nCONTROLLERPORT=${cport}\nWORKERLISTENPORT=${lport}\n" >>$newfilename
 | 
|---|
 | 52 | echo "$CHANGEME" >>$newfilename
 | 
|---|
 | 53 | sed -e "${secondline},1000d" -e "1,${firstline}d" -e "s#fragment-automation\(.*\)#fragment-automation --server-address 127.0.0.1 --server-port \$CONTROLLERPORT --DoLongrange 0 \1#" -e "/^.*--fragment-executable.*$/d" -e "/^.*--save-fragment-results.*$/d" -e "s#\(fragment-prefix .*\) \\\#\1],#" -e "s#\(exit(1)}'\], 0\)#\1, [stdout], [stderr]#" -e "s#\(0, \[stdout\], \[stderr\]\))#\1, [kill \$server_pid \$worker_pid])#" -e "s#awk '{print \$2}'#awk '{print \$2}' >energy_stdout#" $file >>$newfilename
 | 
|---|
 | 54 | echo -e "\n$CHANGETOO" >>$newfilename
 | 
|---|
 | 55 | sed -e "1,${secondline}d" $file >>$newfilename
 | 
|---|
 | 56 | 
 | 
|---|
 | 57 | let wport=$wport+10
 | 
|---|
 | 58 | 
 | 
|---|
 | 59 | done
 | 
|---|