run.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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/jetty-hello-web "$image")"
  10. "$dir/../docker-build.sh" "$dir" "$serverImage" <<EOD
  11. FROM $image
  12. COPY dir/index.jsp /var/lib/jetty/webapps/ROOT/
  13. EOD
  14. cid="$(docker run -d "$serverImage")"
  15. trap "docker rm -vf $cid > /dev/null" EXIT
  16. _request() {
  17. local method="$1"
  18. shift
  19. local url="${1#/}"
  20. shift
  21. docker run --rm --link "$cid":jetty "$clientImage" \
  22. curl -fs -X"$method" "$@" "http://jetty:8080/$url"
  23. }
  24. # Make sure that Jetty is listening on port 8080
  25. . "$dir/../../retry.sh" --tries 40 --sleep 0.25 '[ "$(_request GET / --output /dev/null || echo $?)" != 7 ]'
  26. # Check that we can request /index.jsp with no params
  27. [ "$(_request GET "/" | tail -1)" = "null" ]
  28. # Check that our index.jsp echoes the value of the "hello" param
  29. hello="world-$RANDOM-$RANDOM"
  30. [ "$(_request GET "/?hello=$hello" | tail -1)" = "$hello" ]