run.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env bash
  2. set -Eeuo pipefail
  3. dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. serverImage="$1"
  5. # Use a client image with curl for testing
  6. clientImage='buildpack-deps:trixie-curl'
  7. # ensure the clientImage is ready and available
  8. if ! docker image inspect "$clientImage" &> /dev/null; then
  9. docker pull "$clientImage" > /dev/null
  10. fi
  11. # Create an instance of the container-under-test
  12. cid="$(docker run -d "$serverImage")"
  13. trap "docker rm -vf $cid > /dev/null" EXIT
  14. _request() {
  15. local method="$1"
  16. shift
  17. local url="${1#/}"
  18. shift
  19. docker run --rm \
  20. --link "$cid":redmine \
  21. "$clientImage" \
  22. curl -fs -X"$method" "$@" "http://redmine:3000/$url"
  23. }
  24. # Make sure that Redmine is listening and ready
  25. # (give it plenty of time, since it needs to do a lot of database migrations)
  26. . "$dir/../../retry.sh" --tries 40 '_request GET / --output /dev/null'
  27. # Check that / include the text "Redmine" somewhere
  28. _request GET '/' | grep Redmine > /dev/null
  29. # Check that /account/register include the text "Password" somewhere
  30. _request GET '/account/register' | grep Password > /dev/null