| 1 | ### fragment the molecule and check the number of configs | 
|---|
| 2 |  | 
|---|
| 3 | AT_SETUP([Fragmentation - Getting number of workers]) | 
|---|
| 4 | AT_KEYWORDS([fragmentation numberworkers server worker]) | 
|---|
| 5 |  | 
|---|
| 6 | # check that ports are unique over all tests such that they may run in parallel | 
|---|
| 7 | WORKERPORT=11085 | 
|---|
| 8 | CONTROLLERPORT=11086 | 
|---|
| 9 | WORKERLISTENPORT=11087 | 
|---|
| 10 |  | 
|---|
| 11 | # start service in background | 
|---|
| 12 | ${AUTOTEST_PATH}/JobMarketServer --workerport $WORKERPORT --controllerport $CONTROLLERPORT & | 
|---|
| 13 | server_pid=$! | 
|---|
| 14 | AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $server_pid]) | 
|---|
| 15 |  | 
|---|
| 16 | # enlist a worker to work on jobs | 
|---|
| 17 | ${AUTOTEST_PATH}/JobMarketPoolWorker -v 5 --signal 2 --server 127.0.0.1:${WORKERPORT} --hostname 127.0.0.1 --listen $WORKERLISTENPORT & | 
|---|
| 18 | worker_pid=$! | 
|---|
| 19 | AT_CHECK([sleep 2], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) | 
|---|
| 20 |  | 
|---|
| 21 | # check number of workers | 
|---|
| 22 | AT_CHECK([${AUTOTEST_PATH}/JobMarketController --server 127.0.0.1:$CONTROLLERPORT --command numberworkers], 0, [stdout], [ignore], [kill $server_pid]) | 
|---|
| 23 | AT_CHECK([fgrep "0 are busy and 1 are idle" stdout], 0, [ignore], [ignore], [kill $server_pid $worker_pid]) | 
|---|
| 24 |  | 
|---|
| 25 | # send kill signal to worker such that it shuts down | 
|---|
| 26 | AT_CHECK([kill -INT $worker_pid], 0, [stdout], [ignore], [kill $server_pid $worker_pid]) | 
|---|
| 27 |  | 
|---|
| 28 | # check number of workers | 
|---|
| 29 | AT_CHECK([${AUTOTEST_PATH}/JobMarketController --server 127.0.0.1:$CONTROLLERPORT --command numberworkers], 0, [stdout], [ignore], [kill $server_pid]) | 
|---|
| 30 | AT_CHECK([fgrep "0 are busy and 0 are idle" stdout], 0, [ignore], [ignore], [kill $server_pid]) | 
|---|
| 31 |  | 
|---|
| 32 | # shutdown controller socket | 
|---|
| 33 | AT_CHECK([${AUTOTEST_PATH}/JobMarketController --server 127.0.0.1:$CONTROLLERPORT --command shutdown], 0, [stdout], [ignore], [kill $server_pid]) | 
|---|
| 34 |  | 
|---|
| 35 | # check that server is truely down | 
|---|
| 36 | AT_CHECK([sleep 1], 0, [ignore], [ignore], [kill $server_pid]) | 
|---|
| 37 | AT_CHECK([kill $server_pid], 1, [ignore], [ignore]) | 
|---|
| 38 |  | 
|---|
| 39 | AT_CLEANUP | 
|---|