gotest-dockerized.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # Copyright 2015 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. set -o errexit
  16. set -o nounset
  17. set -o pipefail
  18. set -o xtrace
  19. export REPO_DIR=${REPO_DIR:-$(pwd)}
  20. export HOST_ARTIFACTS_DIR=${WORKSPACE}/_artifacts
  21. mkdir -p "${HOST_ARTIFACTS_DIR}"
  22. # Run the kubekins container, mapping in docker (so we can launch containers),
  23. # the repo directory, and the artifacts output directory.
  24. #
  25. # Note: We pass in the absolute path to the repo on the host as an env var incase
  26. # any tests that get run need to launch containers that also map volumes.
  27. # This is required because if you do
  28. #
  29. # $ docker run -v $PATH:/container/path ...
  30. #
  31. # From _inside_ a container that has the host's docker mapped in, the $PATH
  32. # provided must be resolvable on the *HOST*, not the container.
  33. docker run --rm=true \
  34. --privileged=true \
  35. -v /var/run/docker.sock:/var/run/docker.sock \
  36. -v "${REPO_DIR}":/go/src/k8s.io/kubernetes \
  37. -v "${WORKSPACE}/_artifacts":/workspace/artifacts \
  38. -v /etc/localtime:/etc/localtime:ro \
  39. -e "KUBE_FORCE_VERIFY_CHECKS=${KUBE_FORCE_VERIFY_CHECKS:-}" \
  40. -e "KUBE_VERIFY_GIT_BRANCH=${KUBE_VERIFY_GIT_BRANCH:-}" \
  41. -e "REPO_DIR=${REPO_DIR}" \
  42. -e "HOST_ARTIFACTS_DIR=${HOST_ARTIFACTS_DIR}" \
  43. -i gcr.io/google_containers/kubekins-test:v20160822 \
  44. bash -c "cd kubernetes && ${KUBE_TEST_SCRIPT:-./hack/jenkins/test-dockerized.sh}"