#!/bin/bash # $HeadURL$ $LastChangedRevision$ echo "setting up environment ..." export JS_NAME=$(tr -dc A-Za-z0-9 /dev/null jsc chres $RESOURCE:$QUANTITY } echo "submitting several jobs, of which only one will run, then increasing available resources ..." jsd -r slots:1 & JSD_PID=$! sleep $((SLEEP_FACTOR*1)) # settle time for I in {1..3}; do jss -r slots:1 "sleep $((SLEEP_FACTOR*4))" done sleep $((SLEEP_FACTOR*1)) echo "running (expect 1): $(jsq | sed 1,3d | grep -c running)" chres slots 10 sleep $((SLEEP_FACTOR*1)) echo "running (expect 3): $(jsq | sed 1,3d | grep -c running)" echo "waiting for jobs to complete ..." wait_for_jobs echo "cleaning up ..." jsc quit wait $JSD_PID echo "submitting several jobs, of which all will run, then decreasing available resources ..." jsd -r slots:3 & JSD_PID=$! sleep $((SLEEP_FACTOR*1)) # settle time for I in {1..3}; do jss -r slots:1 "sleep $((SLEEP_FACTOR*4))" done sleep $((SLEEP_FACTOR*1)) echo "running (expect 3): $(jsq | sed 1,3d | grep -c running)" chres slots 2 jsc ping > /dev/null sleep $((SLEEP_FACTOR*1)) for I in {1..3}; do jss -r slots:1 "sleep $((SLEEP_FACTOR*4))" done echo "running (expect 3): $(jsq | sed 1,3d | grep -c running)" echo "waiting for jobs to complete ..." wait_for_jobs echo "cleaning up ..." jsc quit wait $JSD_PID echo "submitting several jobs so queue full, waiting for low numbered ones to exit, decreasing resources to match, queuing more jobs (which should not start even though low numbered slots free) ..." jsd -r slots:6 & JSD_PID=$! sleep $((SLEEP_FACTOR*1)) # settle time # Submit short jobs jss -r slots:1 "sleep $((SLEEP_FACTOR*2))" jss -r slots:1 "sleep $((SLEEP_FACTOR*2))" jss -r slots:1 "sleep $((SLEEP_FACTOR*2))" # Submit long jobs jss -r slots:1 "sleep $((SLEEP_FACTOR*4))" jss -r slots:1 "sleep $((SLEEP_FACTOR*4))" jss -r slots:1 "sleep $((SLEEP_FACTOR*4))" # Submit more jobs that will just get queued jss -r slots:1 "sleep $((SLEEP_FACTOR*4))" jss -r slots:1 "sleep $((SLEEP_FACTOR*4))" jss -r slots:1 "sleep $((SLEEP_FACTOR*4))" echo "running (expect 6): $(jsq | sed 1,3d | grep -c running)" chres slots 3 sleep $((SLEEP_FACTOR*3)) # long enough for the short jobs to exit echo "running (expect 3): $(jsq | sed 1,3d | grep -c running)" echo "waiting for jobs to complete ..." wait_for_jobs echo "cleaning up ..." jsc quit wait $JSD_PID echo "all done"