Skip to content

Commit

Permalink
Update unit-test && e2e to run on Mac
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaodong Ye <[email protected]>
  • Loading branch information
yeahdongcn committed Jun 4, 2024
1 parent fa0548f commit fc9252a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
20 changes: 8 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand All @@ -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;
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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/[email protected] ;\
GOOS=${OS} go install sigs.k8s.io/controller-tools/cmd/[email protected] ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
Expand All @@ -211,7 +207,7 @@ mod-download-go:

.PHONY: mirror-licenses
mirror-licenses: mod-download-go; \
go install istio.io/tools/cmd/[email protected]; \
GOOS=${OS} go install istio.io/tools/cmd/[email protected]; \
cd licenses; \
rm -rf `ls ./ | grep -v LICENSE`; \
cd -; \
Expand Down
2 changes: 1 addition & 1 deletion hack/generate-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
2 changes: 1 addition & 1 deletion hack/generate-internal-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$*"; }
Expand Down
4 changes: 2 additions & 2 deletions hack/lib/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
GOOS=${OS} go install sigs.k8s.io/[email protected]
else
echo -n "Found kind, version: " && kind version
fi
Expand All @@ -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
Expand Down
22 changes: 11 additions & 11 deletions hack/run-e2e-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit fc9252a

Please sign in to comment.