run.sh 815 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. set -eo pipefail
  3. dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. image="$1"
  5. # since the "slim" tomcat variants don't have wget, we'll use buildpack-deps
  6. clientImage='buildpack-deps:stretch-curl'
  7. serverImage="$1"
  8. # Create an instance of the container-under-test
  9. cid="$(docker run -d "$serverImage")"
  10. trap "docker rm -vf $cid > /dev/null" EXIT
  11. _request() {
  12. local url="${1#/}"
  13. shift
  14. docker run --rm --link "$cid":tomcat "$clientImage" \
  15. wget -q -O - "$@" "http://tomcat:8080/$url"
  16. }
  17. # Make sure that Tomcat is listening
  18. . "$dir/../../retry.sh" '_request / &> /dev/null'
  19. # Check that we can request /
  20. [ -n "$(_request '/')" ]
  21. # Check that the example "Hello World" servlet works
  22. helloWorld="$(_request '/examples/servlets/servlet/HelloWorldExample')"
  23. [[ "$helloWorld" == *'Hello World!'* ]]