| [0bdd51b] | 1 | ### fragment the molecule and check the number of configs
 | 
|---|
 | 2 | 
 | 
|---|
| [e70b9d] | 3 | AT_SETUP([Fragmentation - Automation: Server/Worker])
 | 
|---|
 | 4 | AT_KEYWORDS([fragmentation automation server worker])
 | 
|---|
| [0bdd51b] | 5 | 
 | 
|---|
| [03195a] | 6 | # check that ports are unique over all tests such that they may run in parallel
 | 
|---|
| [db03d9] | 7 | WORKERPORT=1025
 | 
|---|
 | 8 | CONTROLLERPORT=1026
 | 
|---|
| [0bdd51b] | 9 | 
 | 
|---|
 | 10 | # start service in background
 | 
|---|
| [db03d9] | 11 | ${AUTOTEST_PATH}/Fragmentation/Automation/Server $WORKERPORT $CONTROLLERPORT &
 | 
|---|
| [03195a] | 12 | server_pid=$!
 | 
|---|
 | 13 | AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $server_pid])
 | 
|---|
| [0bdd51b] | 14 | 
 | 
|---|
| [7ca772e] | 15 | # add two jobs 
 | 
|---|
 | 16 | AT_CHECK([${AUTOTEST_PATH}/Fragmentation/Automation/Controller 127.0.0.1 $CONTROLLERPORT sendjobs], 0, [ignore], [ignore], [kill $server_pid])
 | 
|---|
| [778abb] | 17 | 
 | 
|---|
| [db03d9] | 18 | # first worker has a job
 | 
|---|
| [03195a] | 19 | AT_CHECK([${AUTOTEST_PATH}/Fragmentation/Automation/Worker 127.0.0.1 $WORKERPORT], 0, [stdout], [ignore], [kill $server_pid])
 | 
|---|
 | 20 | AT_CHECK([fgrep "Job id: 1" stdout], 0, [ignore], [ignore], [kill $server_pid])
 | 
|---|
| [db03d9] | 21 | 
 | 
|---|
| [7ca772e] | 22 | # second worker has a job
 | 
|---|
 | 23 | AT_CHECK([${AUTOTEST_PATH}/Fragmentation/Automation/Worker 127.0.0.1 $WORKERPORT], 0, [stdout], [ignore], [kill $server_pid])
 | 
|---|
 | 24 | AT_CHECK([fgrep "Job id: 2" stdout], 0, [ignore], [ignore], [kill $server_pid])
 | 
|---|
 | 25 | 
 | 
|---|
| [167b63] | 26 | # check number of done jobs 
 | 
|---|
| [7ca772e] | 27 | AT_CHECK([${AUTOTEST_PATH}/Fragmentation/Automation/Controller 127.0.0.1 $CONTROLLERPORT checkresults], 0, [stdout], [ignore], [kill $server_pid])
 | 
|---|
 | 28 | AT_CHECK([fgrep "2 jobs are calculated so far" stdout], 0, [ignore], [ignore], [kill $server_pid])
 | 
|---|
| [3c4a5e] | 29 | 
 | 
|---|
| [7ca772e] | 30 | # shutdown controller socket 
 | 
|---|
 | 31 | AT_CHECK([${AUTOTEST_PATH}/Fragmentation/Automation/Controller 127.0.0.1 $CONTROLLERPORT shutdown], 0, [stdout], [ignore], [kill $server_pid])
 | 
|---|
| [0196c6] | 32 | 
 | 
|---|
| [0bdd51b] | 33 | # check that server is truely down
 | 
|---|
| [03195a] | 34 | AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $server_pid])
 | 
|---|
 | 35 | AT_CHECK([kill $server_pid], 1, [ignore], [ignore])
 | 
|---|
| [0bdd51b] | 36 | 
 | 
|---|
 | 37 | AT_CLEANUP
 | 
|---|