diff --git a/Makefile b/Makefile index 4202473212ed..1f33cdce5d94 100644 --- a/Makefile +++ b/Makefile @@ -113,6 +113,11 @@ BUILD_TAGS = $(shell git describe --tags --always --dirty="-dev") BUILD_TIME = $(shell date -u) GIT_COMMIT = $(shell git rev-parse --short HEAD) GO_VERSION = $(shell go version) +ifeq ($(OS),Darwin) +ifeq ($(ARCH),arm64) + APPLE_SILICON_FLAG = -tags dynamic +endif +endif print-build-info: @echo "Build Tag: $(BUILD_TAGS)" @@ -124,13 +129,13 @@ milvus: build-cpp print-build-info @echo "Building Milvus ..." @mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build \ -ldflags="-X '$(OBJPREFIX).BuildTags=$(BUILD_TAGS)' -X '$(OBJPREFIX).BuildTime=$(BUILD_TIME)' -X '$(OBJPREFIX).GitCommit=$(GIT_COMMIT)' -X '$(OBJPREFIX).GoVersion=$(GO_VERSION)'" \ - -o $(INSTALL_PATH)/milvus $(PWD)/cmd/main.go 1>/dev/null + ${APPLE_SILICON_FLAG} -o $(INSTALL_PATH)/milvus $(PWD)/cmd/main.go 1>/dev/null embd-milvus: build-cpp-embd print-build-info @echo "Building **Embedded** Milvus ..." @mkdir -p $(INSTALL_PATH) && go env -w CGO_ENABLED="1" && GO111MODULE=on $(GO) build \ -ldflags="-r /tmp/milvus/lib/ -X '$(OBJPREFIX).BuildTags=$(BUILD_TAGS)' -X '$(OBJPREFIX).BuildTime=$(BUILD_TIME)' -X '$(OBJPREFIX).GitCommit=$(GIT_COMMIT)' -X '$(OBJPREFIX).GoVersion=$(GO_VERSION)'" \ - -buildmode=c-shared -o $(INSTALL_PATH)/embd-milvus.so $(PWD)/pkg/embedded/embedded.go 1>/dev/null + ${APPLE_SILICON_FLAG} -buildmode=c-shared -o $(INSTALL_PATH)/embd-milvus.so $(PWD)/pkg/embedded/embedded.go 1>/dev/null build-go: milvus diff --git a/scripts/run_go_codecov.sh b/scripts/run_go_codecov.sh index 870896eed7ce..4a85ed8703bb 100755 --- a/scripts/run_go_codecov.sh +++ b/scripts/run_go_codecov.sh @@ -23,26 +23,17 @@ set -ex echo "mode: atomic" > ${FILE_COVERAGE_INFO} # run unittest -# TODO: "-race" is temporarily disabled for Mac Silicon. Add back when available. echo "Running unittest under ./internal" -if [[ "$(uname -s)" == "Darwin" ]]; then - export MallocNanoZone=0 - for d in $(go list ./internal/... | grep -v -e vendor -e kafka -e internal/querycoord -e /metricsinfo -e internal/proxy -e internal/querynode); do - go test -race -v -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d" - if [ -f profile.out ]; then - grep -v kafka profile.out | sed '1d' >> ${FILE_COVERAGE_INFO} - rm profile.out - fi - done -else - for d in $(go list ./internal/... | grep -v -e vendor -e kafka); do - go test -race -v -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d" - if [ -f profile.out ]; then - grep -v kafka profile.out | sed '1d' >> ${FILE_COVERAGE_INFO} - rm profile.out - fi - done +if [[ $(uname -s) == "Darwin" && "$(uname -m)" == "arm64" ]]; then + APPLE_SILICON_FLAG="-tags dynamic" fi +for d in $(go list ./internal/... | grep -v -e vendor -e kafka); do + go test -race ${APPLE_SILICON_FLAG} -v -coverpkg=./... -coverprofile=profile.out -covermode=atomic "$d" + if [ -f profile.out ]; then + grep -v kafka profile.out | sed '1d' >> ${FILE_COVERAGE_INFO} + rm profile.out + fi +done # generate html report go tool cover -html=./${FILE_COVERAGE_INFO} -o ./${FILE_COVERAGE_HTML} diff --git a/scripts/run_go_unittest.sh b/scripts/run_go_unittest.sh index 93fee6659dd8..a9f447bc3fcf 100755 --- a/scripts/run_go_unittest.sh +++ b/scripts/run_go_unittest.sh @@ -27,42 +27,35 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli done ROOT_DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" -unameOut="$(uname -s)" -if [[ "$unameOut" == "Darwin" ]]; then - export MallocNanoZone=0 +if [[ $(uname -s) == "Darwin" && "$(uname -m)" == "arm64" ]]; then + APPLE_SILICON_FLAG="-tags dynamic" fi # ignore MinIO,S3 unittes MILVUS_DIR="${ROOT_DIR}/internal/" echo "Running go unittest under $MILVUS_DIR" -go test -race -cover "${MILVUS_DIR}/allocator/..." -failfast -go test -race -cover "${MILVUS_DIR}/kv/..." -failfast -go test -race -cover $(go list "${MILVUS_DIR}/mq/..." | grep -v kafka) -failfast -go test -race -cover "${MILVUS_DIR}/storage" -failfast -go test -race -cover "${MILVUS_DIR}/tso/..." -failfast -go test -race -cover "${MILVUS_DIR}/util/funcutil/..." -failfast -go test -race -cover "${MILVUS_DIR}/util/paramtable/..." -failfast -go test -race -cover "${MILVUS_DIR}/util/retry/..." -failfast -go test -race -cover "${MILVUS_DIR}/util/sessionutil/..." -failfast -go test -race -cover "${MILVUS_DIR}/util/trace/..." -failfast -go test -race -cover "${MILVUS_DIR}/util/typeutil/..." -failfast -go test -race -cover "${MILVUS_DIR}/util/importutil/..." -failfast - -# TODO: remove to distributed -#go test -race -cover "${MILVUS_DIR}/proxy/..." -failfast -go test -race -cover "${MILVUS_DIR}/datanode/..." -failfast -go test -race -cover "${MILVUS_DIR}/indexnode/..." -failfast - -# TODO: enable ut on mac os -case "${unameOut}" in - Linux*) go test -race -cover "${MILVUS_DIR}/querynode/..." -failfast;; - *) echo "Skip querynode unit tests, unsupported os:${unameOut}"; -esac - -go test -race -cover "${MILVUS_DIR}/distributed/rootcoord" -failfast -go test -race -cover "${MILVUS_DIR}/rootcoord" -failfast -go test -race -cover "${MILVUS_DIR}/datacoord/..." -failfast -go test -race -cover "${MILVUS_DIR}/indexcoord/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/allocator/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/kv/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} $(go list "${MILVUS_DIR}/mq/..." | grep -v kafka) -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/storage" -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/tso/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/util/funcutil/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/util/paramtable/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/util/retry/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/util/sessionutil/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/util/trace/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/util/typeutil/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/util/importutil/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/proxy/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/datanode/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/indexnode/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/querynode/..." -failfast;; +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/distributed/rootcoord" -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/distributed/datacoord" -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/distributed/querycoord" -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/rootcoord" -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/datacoord/..." -failfast +go test -race -cover ${APPLE_SILICON_FLAG} "${MILVUS_DIR}/indexcoord/..." -failfast echo " Go unittest finished"