run.sh 891 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. set -eo pipefail
  3. dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. # Use a client image with curl for testing
  5. clientImage='buildpack-deps:trixie-curl'
  6. # ensure the clientImage is ready and available
  7. if ! docker image inspect "$clientImage" &> /dev/null; then
  8. docker pull "$clientImage" > /dev/null
  9. fi
  10. serverImage="$1"
  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":apache \
  21. "$clientImage" \
  22. curl -fsL -X"$method" "$@" "http://apache/$url"
  23. }
  24. # Make sure that Apache is listening and ready
  25. . "$dir/../../retry.sh" --tries 10 '_request GET / --output /dev/null'
  26. # Check that we can request / and that it contains the word "login" somewhere
  27. _request GET '/' | grep -i login > /dev/null