test_celeryd.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/sh
  2. # If you make changes to the celeryd init script,
  3. # you can use this test script to verify you didn't break the universe
  4. SERVICE="celeryd"
  5. SERVICE_CMD="sudo /sbin/service $SERVICE"
  6. run_test() {
  7. local msg="$1"
  8. local cmd="$2"
  9. local expected_retval="${3:-0}"
  10. local n=${#msg}
  11. echo
  12. echo `printf "%$((${n}+4))s" | tr " " "#"`
  13. echo "# $msg #"
  14. echo `printf "%$((${n}+4))s" | tr " " "#"`
  15. $cmd
  16. local retval=$?
  17. if [[ "$retval" == "$expected_retval" ]]; then
  18. echo "[PASSED]"
  19. else
  20. echo "[FAILED]"
  21. echo "Exit status: $retval, but expected: $expected_retval"
  22. exit $retval
  23. fi
  24. }
  25. run_test "stop should succeed" "$SERVICE_CMD stop" 0
  26. run_test "status on a stopped service should return 1" "$SERVICE_CMD status" 1
  27. run_test "stopping a stopped celery should not fail" "$SERVICE_CMD stop" 0
  28. run_test "start should succeed" "$SERVICE_CMD start" 0
  29. run_test "status on a running service should return 0" "$SERVICE_CMD status" 0
  30. run_test "starting a running service should fail" "$SERVICE_CMD start" 1
  31. run_test "restarting a running service should succeed" "$SERVICE_CMD restart" 0
  32. run_test "status on a restarted service should return 0" "$SERVICE_CMD status" 0
  33. run_test "stop should succeed" "$SERVICE_CMD stop" 0
  34. echo "All tests passed!"