volcano.sh/volcano@v1.9.0/hack/run-e2e-kind.sh (about) 1 #!/bin/bash 2 3 # 4 # Copyright 2021 The Volcano Authors. 5 # 6 # Licensed under the Apache License, Version 2.0 (the "License"); 7 # you may not use this file except in compliance with the License. 8 # You may obtain a copy of the License at 9 # 10 # http://www.apache.org/licenses/LICENSE-2.0 11 # 12 # Unless required by applicable law or agreed to in writing, software 13 # distributed under the License is distributed on an "AS IS" BASIS, 14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 # See the License for the specific language governing permissions and 16 # limitations under the License. 17 # 18 19 export VK_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/.. 20 export VC_BIN=${VK_ROOT}/${BIN_DIR}/${BIN_OSARCH} 21 export LOG_LEVEL=3 22 export SHOW_VOLCANO_LOGS=${SHOW_VOLCANO_LOGS:-1} 23 export CLEANUP_CLUSTER=${CLEANUP_CLUSTER:-1} 24 export E2E_TYPE=${E2E_TYPE:-"ALL"} 25 26 if [[ "${CLUSTER_NAME}xxx" == "xxx" ]];then 27 CLUSTER_NAME="integration" 28 fi 29 30 export CLUSTER_CONTEXT="--name ${CLUSTER_NAME}" 31 32 export KIND_OPT=${KIND_OPT:="--config ${VK_ROOT}/hack/e2e-kind-config.yaml"} 33 34 function get-k8s-server-version { 35 echo $(kubectl version --short=true | grep Server | sed "s/.*: v//" | tr "." " ") 36 } 37 38 function install-volcano { 39 install-helm 40 41 # judge crd version 42 serverVersion=($(get-k8s-server-version)) 43 major=${serverVersion[0]} 44 minor=${serverVersion[1]} 45 crd_version="v1" 46 # if k8s version less than v1.18, crd version use v1beta 47 if [ "$major" -le "1" ]; then 48 if [ "$minor" -lt "18" ]; then 49 crd_version="v1beta1" 50 fi 51 fi 52 53 echo "Ensure create namespace" 54 kubectl apply -f installer/namespace.yaml 55 56 echo "Install volcano chart with crd version $crd_version" 57 helm install ${CLUSTER_NAME} installer/helm/chart/volcano --namespace volcano-system --kubeconfig ${KUBECONFIG} \ 58 --set basic.image_pull_policy=IfNotPresent \ 59 --set basic.image_tag_version=${TAG} \ 60 --set basic.scheduler_config_file=config/volcano-scheduler-ci.conf \ 61 --set basic.crd_version=${crd_version} \ 62 --wait 63 } 64 65 function uninstall-volcano { 66 helm uninstall ${CLUSTER_NAME} -n kube-system 67 } 68 69 function generate-log { 70 echo "Generating volcano log files" 71 kubectl logs deployment/${CLUSTER_NAME}-admission -n kube-system > volcano-admission.log 72 kubectl logs deployment/${CLUSTER_NAME}-controllers -n kube-system > volcano-controller.log 73 kubectl logs deployment/${CLUSTER_NAME}-scheduler -n kube-system > volcano-scheduler.log 74 } 75 76 function show-log() { 77 log_files=("volcano-admission.log" "volcano-controller.log" "volcano-scheduler.log") 78 for log_file in "${log_files[@]}"; do 79 if [ -f "$log_file" ]; then 80 echo "Showing ${log_file}..." 81 cat "$log_file" 82 else 83 echo "${log_file} not found" 84 fi 85 done 86 } 87 88 89 # clean up 90 function cleanup { 91 uninstall-volcano 92 93 echo "Running kind: [kind delete cluster ${CLUSTER_CONTEXT}]" 94 kind delete cluster ${CLUSTER_CONTEXT} 95 96 if [[ ${SHOW_VOLCANO_LOGS} -eq 1 ]]; then 97 show-log 98 fi 99 } 100 101 echo $* | grep -E -q "\-\-help|\-h" 102 if [[ $? -eq 0 ]]; then 103 echo "Customize the kind-cluster name: 104 105 export CLUSTER_NAME=<custom cluster name> # default: integration 106 107 Customize kind options other than --name: 108 109 export KIND_OPT=<kind options> 110 111 Disable displaying volcano component logs: 112 113 export SHOW_VOLCANO_LOGS=0 114 " 115 exit 0 116 fi 117 118 if [[ $CLEANUP_CLUSTER -eq 1 ]]; then 119 trap cleanup EXIT 120 fi 121 122 source "${VK_ROOT}/hack/lib/install.sh" 123 124 check-prerequisites 125 kind-up-cluster 126 127 if [[ -z ${KUBECONFIG+x} ]]; then 128 export KUBECONFIG="${HOME}/.kube/config" 129 fi 130 131 install-volcano 132 133 # Run e2e test 134 cd ${VK_ROOT} 135 136 install-ginkgo-if-not-exist 137 138 case ${E2E_TYPE} in 139 "ALL") 140 echo "Running e2e..." 141 KUBECONFIG=${KUBECONFIG} ginkgo -r --nodes=4 --compilers=4 --randomize-all --randomize-suites --fail-on-pending --cover --trace --race --slow-spec-threshold='30s' --progress ./test/e2e/jobp/ 142 KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/jobseq/ 143 KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingbase/ 144 KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingaction/ 145 KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/vcctl/ 146 ;; 147 "JOBP") 148 echo "Running parallel job e2e suite..." 149 KUBECONFIG=${KUBECONFIG} ginkgo -r --nodes=4 --compilers=4 --randomize-all --randomize-suites --fail-on-pending --cover --trace --race --slow-spec-threshold='30s' --progress ./test/e2e/jobp/ 150 ;; 151 "JOBSEQ") 152 echo "Running sequence job e2e suite..." 153 KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/jobseq/ 154 ;; 155 "SCHEDULINGBASE") 156 echo "Running scheduling base e2e suite..." 157 KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingbase/ 158 ;; 159 "SCHEDULINGACTION") 160 echo "Running scheduling action e2e suite..." 161 KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingaction/ 162 ;; 163 "VCCTL") 164 echo "Running vcctl e2e suite..." 165 KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/vcctl/ 166 ;; 167 "STRESS") 168 echo "Running stress e2e suite..." 169 KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/stress/ 170 ;; 171 esac 172 173 if [[ $? -ne 0 ]]; then 174 generate-log 175 exit 1 176 fi