Skip to content

Commit

Permalink
Fix build and tests for Mac M1, also enabled more tests for OSX syste…
Browse files Browse the repository at this point in the history
…ms (#16552)

issue: #16500

/kind enhancement

Signed-off-by: Yuchen Gao <yuchen.gao@zilliz.com>
  • Loading branch information
soothing-rain committed Apr 20, 2022
1 parent 65e01bc commit f93862f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 51 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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

Expand Down
27 changes: 9 additions & 18 deletions scripts/run_go_codecov.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
55 changes: 24 additions & 31 deletions scripts/run_go_unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit f93862f

Please sign in to comment.