runtime-check.sh 992 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. wait_for() {
  3. host="${1}"
  4. port="${2}"
  5. name="${3}"
  6. timeout="30"
  7. if command -v nc > /dev/null ; then
  8. netcat="nc"
  9. elif command -v netcat > /dev/null ; then
  10. netcat="netcat"
  11. else
  12. printf "Unable to find a usable netcat command.\n"
  13. return 1
  14. fi
  15. printf "Waiting for %s on %s:%s ... " "${name}" "${host}" "${port}"
  16. sleep 30
  17. i=0
  18. while ! ${netcat} -z "${host}" "${port}"; do
  19. sleep 1
  20. if [ "$i" -gt "$timeout" ]; then
  21. printf "Timed out!\n"
  22. return 2
  23. fi
  24. i="$((i + 1))"
  25. done
  26. printf "OK\n"
  27. }
  28. wait_for localhost 19999 netdata
  29. case $? in
  30. 1) exit 2 ;;
  31. 2) exit 3 ;;
  32. esac
  33. curl -sfS http://127.0.0.1:19999/api/v1/info > ./response || exit 1
  34. cat ./response
  35. jq '.version' ./response || exit 1
  36. curl -sfS http://127.0.0.1:19999/index.html || exit 1
  37. curl -sfS http://127.0.0.1:19999/v0/index.html || exit 1
  38. curl -sfS http://127.0.0.1:19999/v1/index.html || exit 1
  39. curl -sfS http://127.0.0.1:19999/v2/index.html || exit 1