run.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. set -eo pipefail
  3. dir="$(dirname "$(readlink -f "$BASH_SOURCE")")"
  4. # since we have curl in the php image, we'll use that
  5. clientImage="$1"
  6. mysqlImage='mysql:5.7'
  7. serverImage="$1"
  8. # Create an instance of the container-under-test
  9. mysqlCid="$(docker run -d -e MYSQL_ROOT_PASSWORD="test-$RANDOM-password-$RANDOM-$$" "$mysqlImage")"
  10. trap "docker rm -vf $mysqlCid > /dev/null" EXIT
  11. cid="$(docker run -d --link "$mysqlCid":mysql "$serverImage")"
  12. trap "docker rm -vf $cid $mysqlCid > /dev/null" EXIT
  13. _request() {
  14. local method="$1"
  15. shift
  16. local url="${1#/}"
  17. shift
  18. docker run --rm --link "$cid":apache "$clientImage" \
  19. curl -fsL -X"$method" "$@" "http://apache/$url"
  20. }
  21. # Make sure that Apache is listening and ready
  22. . "$dir/../../retry.sh" --tries 30 '_request GET / --output /dev/null'
  23. # (give it a bit long since it won't start until MySQL is started and ready)
  24. # Check that we can request / and that it contains the word "setup" somewhere
  25. # <form id="setup" method="post" action="?step=1"><label class='screen-reader-text' for='language'>Select a default language</label>
  26. _request GET '/' |tac|tac| grep -iq setup
  27. # (without "|tac|tac|" we get "broken pipe" since "grep" closes the pipe before "curl" is done reading it)