run.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. [ "$DEBUG" ] && set -x
  3. set -eo pipefail
  4. dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
  5. image="$1"
  6. # Use a client image with curl for testing
  7. clientImage='buildpack-deps:stretch-curl'
  8. # Create an instance of the container-under-test
  9. serverImage="$("$dir/../image-name.sh" librarytest/rapidoid-hello-web "$image")"
  10. "$dir/../docker-build.sh" "$dir" "$serverImage" <<EOD
  11. FROM $image
  12. RUN mkdir -p /app/static
  13. COPY dir/index.html /app/static/
  14. EOD
  15. cid="$(docker run -d "$serverImage" app.services=ping)"
  16. trap "docker rm -vf $cid > /dev/null" EXIT
  17. _request() {
  18. local method="$1"
  19. shift
  20. local url="${1#/}"
  21. shift
  22. docker run --rm --link "$cid":rapidoid "$clientImage" \
  23. curl -fs -X"$method" "$@" "http://rapidoid:8888/$url"
  24. }
  25. # Make sure that Rapidoid is listening on port 8888
  26. . "$dir/../../retry.sh" --tries 40 --sleep 0.25 '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]'
  27. # Make sure that Rapidoid serves the static page index.html
  28. [ "$(_request GET "/")" = "Hello world!" ]
  29. [ "$(_request GET "/index.html")" = "Hello world!" ]
  30. # Make sure that Rapidoid's built-in Ping service works correctly
  31. [ "$(_request GET "/rapidoid/ping")" = "OK" ]