test-docker-py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env bash
  2. set -e
  3. source hack/make/.integration-test-helpers
  4. # The commit or tag to use for testing
  5. # TODO docker 17.06 cli client used in CI fails to build using a sha;
  6. # unable to prepare context: unable to 'git clone' to temporary context directory: error fetching: error: no such remote ref ead0bb9e08c13dd3d1712759491eee06bf5a5602
  7. #: exit status 128
  8. : ${DOCKER_PY_COMMIT:=4.0.2}
  9. (
  10. bundle .integration-daemon-start
  11. docker_host_scheme=`echo "${DOCKER_HOST}" | cut -d: -f1 -`
  12. case "${docker_host_scheme}" in
  13. unix)
  14. # trim the tcp:// scheme, and bind-mount the docker socket into the container
  15. run_opts="-v ${DOCKER_HOST#unix://}:/var/run/docker.sock"
  16. ;;
  17. tcp)
  18. # run container in host-mode networking so that it can connect to the
  19. # daemon from the current networking namespace (e.g., to connect to localhost)
  20. run_opts="--network=host -e DOCKER_HOST=${DOCKER_HOST}"
  21. ;;
  22. *)
  23. echo "WARN: Skipping test-docker-py: connecting to docker daemon using ${docker_host_scheme} (${DOCKER_HOST}) not supported"
  24. bundle .integration-daemon-stop
  25. return 0
  26. esac
  27. docker_py_image="docker-sdk-python3:${DOCKER_PY_COMMIT}"
  28. if ! docker image inspect "dockerPyImage" &> /dev/null; then
  29. echo INFO: Building ${docker_py_image}...
  30. (
  31. [ -n "${TESTDEBUG}" ] && set -x
  32. exec docker build --quiet -t ${docker_py_image} -f tests/Dockerfile "https://github.com/docker/docker-py.git#${DOCKER_PY_COMMIT}"
  33. )
  34. fi
  35. echo INFO: Starting docker-py tests...
  36. (
  37. [ -n "${TESTDEBUG}" ] && set -x
  38. exec docker run -t --rm ${run_opts} ${docker_py_image} py.test tests/integration
  39. )
  40. bundle .integration-daemon-stop
  41. ) 2>&1 | tee -a "$DEST/test.log"