From fc9252a8e40e5a9a126d9471b15d1321b7bba9c8 Mon Sep 17 00:00:00 2001 From: Xiaodong Ye Date: Mon, 3 Jun 2024 17:37:39 +0800 Subject: [PATCH] Update unit-test && e2e to run on Mac Signed-off-by: Xiaodong Ye --- Makefile | 20 ++++++++------------ hack/generate-groups.sh | 2 +- hack/generate-internal-groups.sh | 2 +- hack/lib/install.sh | 4 ++-- hack/run-e2e-kind.sh | 22 +++++++++++----------- 5 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 264bdf7573..6eab4eb142 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ else GOBIN=$(shell go env GOBIN) endif -OS=$(shell uname -s) +OS=$(shell uname -s | tr '[:upper:]' '[:lower:]') # Get OS architecture OSARCH=$(shell uname -m) @@ -85,11 +85,7 @@ vc-webhook-manager: init CC=${CC} CGO_ENABLED=0 go build -ldflags ${LD_FLAGS} -o ${BIN_DIR}/vc-webhook-manager ./cmd/webhook-manager vcctl: init - if [ ${OS} = 'Darwin' ];then\ - CC=${CC} CGO_ENABLED=0 GOOS=darwin go build -ldflags ${LD_FLAGS} -o ${BIN_DIR}/vcctl ./cmd/cli;\ - else\ - CC=${CC} CGO_ENABLED=0 go build -ldflags ${LD_FLAGS} -o ${BIN_DIR}/vcctl ./cmd/cli;\ - fi; + CC=${CC} CGO_ENABLED=0 GOOS=${OS} go build -ldflags ${LD_FLAGS} -o ${BIN_DIR}/vcctl ./cmd/cli image_bins: vc-scheduler vc-controller-manager vc-webhook-manager @@ -115,8 +111,8 @@ manifests: controller-gen unit-test: go clean -testcache - if [ ${OS} = 'Darwin' ];then\ - GOOS=darwin go list ./... | grep -v "/e2e" | xargs go test;\ + if [ ${OS} = 'darwin' ];then\ + go list ./... | grep -v "/e2e" | GOOS=${OS} xargs go test;\ else\ go test -p 8 -race $$(find pkg cmd -type f -name '*_test.go' | sed -r 's|/[^/]+$$||' | sort | uniq | sed "s|^|volcano.sh/volcano/|");\ fi; @@ -146,8 +142,8 @@ generate-yaml: init manifests ./hack/generate-yaml.sh TAG=${RELEASE_VER} CRD_VERSION=${CRD_VERSION} generate-charts: init manifests - ./hack/generate-charts.sh - + ./hack/generate-charts.sh + release-env: ./hack/build-env.sh release @@ -190,7 +186,7 @@ ifeq (, $(shell which controller-gen)) CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\ cd $$CONTROLLER_GEN_TMP_DIR ;\ go mod init tmp ;\ - go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 ;\ + GOOS=${OS} go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 ;\ rm -rf $$CONTROLLER_GEN_TMP_DIR ;\ } CONTROLLER_GEN=$(GOBIN)/controller-gen @@ -211,7 +207,7 @@ mod-download-go: .PHONY: mirror-licenses mirror-licenses: mod-download-go; \ - go install istio.io/tools/cmd/license-lint@1.19.7; \ + GOOS=${OS} go install istio.io/tools/cmd/license-lint@1.19.7; \ cd licenses; \ rm -rf `ls ./ | grep -v LICENSE`; \ cd -; \ diff --git a/hack/generate-groups.sh b/hack/generate-groups.sh index cfc2576a85..529c3ea3a3 100755 --- a/hack/generate-groups.sh +++ b/hack/generate-groups.sh @@ -50,7 +50,7 @@ shift 4 # To support running this script from anywhere, first cd into this directory, # and then install with forced module mode on and fully qualified name. cd "$(dirname "${0}")" - GO111MODULE=on go install k8s.io/code-generator/cmd/{defaulter-gen,client-gen,lister-gen,informer-gen,deepcopy-gen} + GO111MODULE=on GOOS=${OS} go install k8s.io/code-generator/cmd/{defaulter-gen,client-gen,lister-gen,informer-gen,deepcopy-gen} ) # Go installs the above commands to get installed in $GOBIN if defined, and $GOPATH/bin otherwise: GOBIN="$(go env GOBIN)" diff --git a/hack/generate-internal-groups.sh b/hack/generate-internal-groups.sh index 2c114a3703..7ffbb3fc31 100755 --- a/hack/generate-internal-groups.sh +++ b/hack/generate-internal-groups.sh @@ -51,7 +51,7 @@ shift 5 # To support running this script from anywhere, first cd into this directory, # and then install with forced module mode on and fully qualified name. cd "$(dirname "${0}")" - GO111MODULE=on go install k8s.io/code-generator/cmd/{defaulter-gen,conversion-gen,client-gen,lister-gen,informer-gen,deepcopy-gen,openapi-gen} + GO111MODULE=on GOOS=${OS} go install k8s.io/code-generator/cmd/{defaulter-gen,conversion-gen,client-gen,lister-gen,informer-gen,deepcopy-gen,openapi-gen} ) function codegen::join() { local IFS="$1"; shift; echo "$*"; } diff --git a/hack/lib/install.sh b/hack/lib/install.sh index 5b5efcd896..3f420944c4 100644 --- a/hack/lib/install.sh +++ b/hack/lib/install.sh @@ -69,7 +69,7 @@ function check-kind { which kind >/dev/null 2>&1 if [[ $? -ne 0 ]]; then echo "Installing kind ..." - go install sigs.k8s.io/kind@v0.21.0 + GOOS=${OS} go install sigs.k8s.io/kind@v0.21.0 else echo -n "Found kind, version: " && kind version fi @@ -94,7 +94,7 @@ function install-ginkgo-if-not-exist { which ginkgo >/dev/null 2>&1 if [[ $? -ne 0 ]]; then echo "Installing ginkgo ..." - go install github.com/onsi/ginkgo/v2/ginkgo + GOOS=${OS} go install github.com/onsi/ginkgo/v2/ginkgo else echo -n "Found ginkgo, version: " && ginkgo version fi diff --git a/hack/run-e2e-kind.sh b/hack/run-e2e-kind.sh index 3b4a530ce6..3b7bcc9e64 100755 --- a/hack/run-e2e-kind.sh +++ b/hack/run-e2e-kind.sh @@ -133,35 +133,35 @@ install-ginkgo-if-not-exist case ${E2E_TYPE} in "ALL") echo "Running e2e..." - 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/ - KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/jobseq/ - KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingbase/ - KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingaction/ - KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/vcctl/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --nodes=4 --compilers=4 --randomize-all --randomize-suites --fail-on-pending --cover --trace --race --slow-spec-threshold='30s' --progress ./test/e2e/jobp/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/jobseq/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingbase/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingaction/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/vcctl/ ;; "JOBP") echo "Running parallel job e2e suite..." - 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/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --nodes=4 --compilers=4 --randomize-all --randomize-suites --fail-on-pending --cover --trace --race --slow-spec-threshold='30s' --progress ./test/e2e/jobp/ ;; "JOBSEQ") echo "Running sequence job e2e suite..." - KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/jobseq/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/jobseq/ ;; "SCHEDULINGBASE") echo "Running scheduling base e2e suite..." - KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingbase/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingbase/ ;; "SCHEDULINGACTION") echo "Running scheduling action e2e suite..." - KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingaction/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/schedulingaction/ ;; "VCCTL") echo "Running vcctl e2e suite..." - KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/vcctl/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/vcctl/ ;; "STRESS") echo "Running stress e2e suite..." - KUBECONFIG=${KUBECONFIG} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/stress/ + KUBECONFIG=${KUBECONFIG} GOOS=${OS} ginkgo -r --slow-spec-threshold='30s' --progress ./test/e2e/stress/ ;; esac