2020-10-30 16:25:06 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2021-10-09 18:01:27 +08:00
|
|
|
# Licensed to the LF AI & Data foundation under one
|
|
|
|
# or more contributor license agreements. See the NOTICE file
|
|
|
|
# distributed with this work for additional information
|
|
|
|
# regarding copyright ownership. The ASF licenses this file
|
|
|
|
# to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance
|
|
|
|
# with the License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2021-11-17 10:37:16 +08:00
|
|
|
# Exit immediately for non zero status
|
2020-10-30 16:25:06 +08:00
|
|
|
set -e
|
|
|
|
|
2022-06-28 19:58:25 +08:00
|
|
|
BASEDIR=$(dirname "$0")
|
|
|
|
source $BASEDIR/setenv.sh
|
2022-06-24 21:12:15 +08:00
|
|
|
|
2022-04-28 21:03:47 +08:00
|
|
|
if [[ $(uname -s) == "Darwin" ]]; then
|
|
|
|
export MallocNanoZone=0
|
|
|
|
fi
|
|
|
|
|
2023-04-11 10:32:31 +08:00
|
|
|
# ignore MinIO,S3 unittests
|
2021-01-12 18:03:24 +08:00
|
|
|
MILVUS_DIR="${ROOT_DIR}/internal/"
|
2023-04-11 10:32:31 +08:00
|
|
|
PKG_DIR="${ROOT_DIR}/pkg/"
|
|
|
|
echo "Running go unittest under $MILVUS_DIR & $PKG_DIR"
|
2021-01-12 18:03:24 +08:00
|
|
|
|
2022-09-08 17:36:35 +08:00
|
|
|
TEST_ALL=1
|
|
|
|
TEST_TAG="ALL"
|
|
|
|
|
|
|
|
while getopts "t:h" arg; do
|
|
|
|
case $arg in
|
|
|
|
t)
|
|
|
|
TEST_ALL=0
|
|
|
|
TEST_TAG=$OPTARG
|
|
|
|
;;
|
|
|
|
h) # help
|
|
|
|
echo "
|
|
|
|
parameter:
|
|
|
|
-t: test tag(default: all)
|
|
|
|
-h: help
|
|
|
|
|
|
|
|
usage:
|
|
|
|
./go_run_unittest.sh -t \${TEST_TAG}
|
|
|
|
"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
?)
|
|
|
|
echo "ERROR! unknown argument"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
function test_proxy()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/proxy/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/distributed/proxy/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_querynode()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/querynodev2/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/distributed/querynode/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function test_kv()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/kv/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_mq()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic $(go list "${MILVUS_DIR}/mq/..." | grep -v kafka) -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_storage()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/storage" -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_allocator()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/allocator/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_tso()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/tso/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_config()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/config/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_util()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/util/funcutil/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/util/paramtable/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${PKG_DIR}/util/retry/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/util/sessionutil/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/util/typeutil/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/util/importutil/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2024-01-05 11:48:47 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/util/importutilv2/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2023-12-20 19:22:42 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/util/proxyutil/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
2023-04-11 10:32:31 +08:00
|
|
|
function test_pkg()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${PKG_DIR}/common/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${PKG_DIR}/config/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${PKG_DIR}/log/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${PKG_DIR}/mq/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${PKG_DIR}/tracer/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${PKG_DIR}/util/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2023-04-11 10:32:31 +08:00
|
|
|
}
|
|
|
|
|
2022-09-08 17:36:35 +08:00
|
|
|
function test_datanode
|
|
|
|
{
|
|
|
|
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/datanode/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/distributed/datanode/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function test_indexnode()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/indexnode/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_rootcoord()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/distributed/rootcoord/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/rootcoord" -failfast -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_datacoord()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/distributed/datacoord/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/datacoord/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_querycoord()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/distributed/querycoord/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/querycoordv2/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
2023-01-04 19:37:36 +08:00
|
|
|
#function test_indexcoord()
|
|
|
|
#{
|
2023-07-13 15:34:33 +08:00
|
|
|
#go test -race -cover -tags dynamic "${MILVUS_DIR}/indexcoord/..." -failfast
|
2023-01-04 19:37:36 +08:00
|
|
|
#}
|
2022-09-08 17:36:35 +08:00
|
|
|
|
|
|
|
function test_metastore()
|
|
|
|
{
|
2023-08-11 11:25:32 +08:00
|
|
|
go test -race -cover -tags dynamic "${MILVUS_DIR}/metastore/..." -failfast -count=1 -ldflags="-r ${RPATH}"
|
2022-09-08 17:36:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function test_all()
|
|
|
|
{
|
|
|
|
test_proxy
|
|
|
|
test_querynode
|
|
|
|
test_datanode
|
|
|
|
test_indexnode
|
|
|
|
test_rootcoord
|
|
|
|
test_querycoord
|
|
|
|
test_datacoord
|
2023-01-04 19:37:36 +08:00
|
|
|
#test_indexcoord
|
2022-09-08 17:36:35 +08:00
|
|
|
test_kv
|
|
|
|
test_mq
|
|
|
|
test_storage
|
|
|
|
test_allocator
|
|
|
|
test_tso
|
|
|
|
test_config
|
|
|
|
test_util
|
2023-04-11 10:32:31 +08:00
|
|
|
test_pkg
|
2022-09-08 17:36:35 +08:00
|
|
|
test_metastore
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case "${TEST_TAG}" in
|
|
|
|
proxy)
|
|
|
|
test_proxy
|
|
|
|
;;
|
|
|
|
querynode)
|
|
|
|
test_querynode
|
|
|
|
;;
|
|
|
|
datanode)
|
|
|
|
test_datanode
|
|
|
|
;;
|
|
|
|
indexnode)
|
|
|
|
test_indexnode
|
|
|
|
;;
|
|
|
|
rootcoord)
|
|
|
|
test_rootcoord
|
|
|
|
;;
|
|
|
|
querycoord)
|
|
|
|
test_querycoord
|
|
|
|
;;
|
|
|
|
datacoord)
|
|
|
|
test_datacoord
|
|
|
|
;;
|
2023-01-04 19:37:36 +08:00
|
|
|
# indexcoord)
|
|
|
|
# test_indexcoord
|
|
|
|
# ;;
|
2022-09-08 17:36:35 +08:00
|
|
|
kv)
|
|
|
|
test_kv
|
|
|
|
;;
|
|
|
|
mq)
|
|
|
|
test_mq
|
|
|
|
;;
|
|
|
|
storage)
|
|
|
|
test_storage
|
|
|
|
;;
|
|
|
|
allocator)
|
|
|
|
test_allocator
|
|
|
|
;;
|
|
|
|
tso)
|
|
|
|
test_tso
|
|
|
|
;;
|
|
|
|
config)
|
|
|
|
test_config
|
|
|
|
;;
|
|
|
|
util)
|
|
|
|
test_util
|
|
|
|
;;
|
2023-04-11 10:32:31 +08:00
|
|
|
pkg)
|
|
|
|
test_pkg
|
|
|
|
;;
|
2022-09-08 17:36:35 +08:00
|
|
|
metastore)
|
|
|
|
test_metastore
|
|
|
|
;;
|
|
|
|
*) echo "Test All";
|
|
|
|
test_all
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2021-10-06 19:28:47 +08:00
|
|
|
|
2021-10-09 18:01:27 +08:00
|
|
|
echo " Go unittest finished"
|