run-operator-tests.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. set -euo pipefail
  3. # TODO(aslonnie): refactor this test to be hermetic.
  4. echo "--- Build image"
  5. bazel run //ci/ray_ci:build_in_docker -- docker \
  6. --platform cpu --canonical-tag kuberay-test
  7. docker tag rayproject/ray:kuberay-test ray-ci:kuberay-test
  8. echo "--- Setup k8s environment"
  9. bash ci/k8s/prep-k8s-environment.sh
  10. kind load docker-image ray-ci:kuberay-test
  11. # The following is essentially running
  12. # python python/ray/tests/kuberay/setup/setup_kuberay.py
  13. bash python/ray/autoscaler/kuberay/init-config.sh
  14. kubectl create -k python/ray/autoscaler/kuberay/config/default
  15. echo "--- Test ray cluster creation"
  16. kubectl apply -f python/ray/tests/kuberay/setup/raycluster_test.yaml
  17. kubectl get rayclusters.ray.io
  18. kubectl delete -f python/ray/tests/kuberay/setup/raycluster_test.yaml
  19. echo "--- Wait until all pods of test cluster are deleted"
  20. kubectl get pods -o custom-columns=POD:metadata.name --no-headers
  21. for i in {1..120}; do
  22. if [[ "$(kubectl get pods -o custom-columns=POD:metadata.name --no-headers | wc -l)" == "0" ]]; then
  23. break
  24. fi
  25. if [[ $i == 120 ]]; then
  26. echo "Timed out waiting for pods to be deleted"
  27. exit 1
  28. fi
  29. sleep 1
  30. done
  31. echo "--- Run bazel tests"
  32. # Needs to send in the kubeconfig file in base64 encoding.
  33. bazel run //ci/ray_ci:test_in_docker -- //python/ray/tests/... kuberay \
  34. --build-name k8sbuild \
  35. --network host \
  36. --test-env=RAY_IMAGE=docker.io/library/ray-ci:kuberay-test \
  37. --test-env=PULL_POLICY=Never \
  38. --test-env=KUBECONFIG=/tmp/rayci-kubeconfig \
  39. "--test-env=KUBECONFIG_BASE64=$(base64 -w0 "$HOME/.kube/config")"
  40. # Test for autoscaler v2.
  41. bazel run //ci/ray_ci:test_in_docker -- //python/ray/tests/... kuberay \
  42. --build-name k8sbuild \
  43. --network host \
  44. --test-env=RAY_IMAGE=docker.io/library/ray-ci:kuberay-test \
  45. --test-env=PULL_POLICY=Never \
  46. --test-env=AUTOSCALER_V2=True \
  47. --test-env=KUBECONFIG=/tmp/rayci-kubeconfig \
  48. "--test-env=KUBECONFIG_BASE64=$(base64 -w0 "$HOME/.kube/config")"