real-run.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. set -Eeo pipefail
  3. dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. serverImage="$1"
  5. # Use a client image with curl for testing
  6. clientImage='buildpack-deps:buster-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. #trap "docker logs $cid" ERR
  15. _request() {
  16. local method="$1"
  17. shift
  18. local url="${1#/}"
  19. shift
  20. docker run --rm \
  21. --link "$cid":apache \
  22. "$clientImage" \
  23. curl -fsL -X"$method" "$@" "http://apache/$url"
  24. }
  25. # Make sure that Apache is listening and ready
  26. . "$dir/../../retry.sh" --tries 30 '_request GET / --output /dev/null'
  27. # Check that we can request / and that it contains the pattern "Install" somewhere
  28. # <input type="submit" class="primary" value="Install" data-finishing="Installing …">
  29. _request GET '/' | grep -i '"Install"' > /dev/null
  30. # (https://github.com/nextcloud/server/blob/68b2463107774bed28ee9e77b44e7395d49dacee/core/templates/installation.php#L164)