提交 f143f899 编写于 作者: J jinhai

Merge branch '0.5.0' into '0.5.0'

Merge from github

See merge request megasearch/milvus!777

Former-commit-id: bdf4de50fc482c43814529b190e55a18e42661cb
pipeline {
agent none
options {
timestamps()
}
parameters{
choice choices: ['Release', 'Debug'], description: '', name: 'BUILD_TYPE'
string defaultValue: 'cf1434e7-5a4b-4d25-82e8-88d667aef9e5', description: 'GIT CREDENTIALS ID', name: 'GIT_CREDENTIALS_ID', trim: true
string defaultValue: 'registry.zilliz.com', description: 'DOCKER REGISTRY URL', name: 'DOKCER_REGISTRY_URL', trim: true
string defaultValue: 'ba070c98-c8cc-4f7c-b657-897715f359fc', description: 'DOCKER CREDENTIALS ID', name: 'DOCKER_CREDENTIALS_ID', trim: true
string defaultValue: 'http://192.168.1.202/artifactory/milvus', description: 'JFROG ARTFACTORY URL', name: 'JFROG_ARTFACTORY_URL', trim: true
string defaultValue: '1a527823-d2b7-44fd-834b-9844350baf14', description: 'JFROG CREDENTIALS ID', name: 'JFROG_CREDENTIALS_ID', trim: true
}
environment {
PROJECT_NAME = "milvus"
LOWER_BUILD_TYPE = params.BUILD_TYPE.toLowerCase()
SEMVER = "${BRANCH_NAME}"
JOBNAMES = env.JOB_NAME.split('/')
PIPELINE_NAME = "${JOBNAMES[0]}"
}
stages {
stage("Ubuntu 18.04") {
environment {
OS_NAME = "ubuntu18.04"
PACKAGE_VERSION = VersionNumber([
versionNumberString : '${SEMVER}-${LOWER_BUILD_TYPE}-ubuntu18.04-x86_64-${BUILD_DATE_FORMATTED, "yyyyMMdd"}-${BUILDS_TODAY}'
]);
DOCKER_VERSION = "${SEMVER}-${OS_NAME}-${LOWER_BUILD_TYPE}"
}
stages {
stage("Run Build") {
agent {
kubernetes {
label 'build'
defaultContainer 'jnlp'
yamlFile 'ci/jenkins/pod/milvus-build-env-pod.yaml'
}
}
stages {
stage('Build') {
steps {
container('milvus-build-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/build.groovy"
}
}
}
}
stage('Code Coverage') {
steps {
container('milvus-build-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/coverage.groovy"
}
}
}
}
stage('Upload Package') {
steps {
container('milvus-build-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/package.groovy"
}
}
}
}
}
}
stage("Publish docker images") {
agent {
kubernetes {
label 'publish'
defaultContainer 'jnlp'
yamlFile 'ci/jenkins/pod/docker-pod.yaml'
}
}
stages {
stage('Publish') {
steps {
container('publish-images'){
script {
load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/publishImages.groovy"
}
}
}
}
}
}
stage("Deploy to Development") {
agent {
kubernetes {
label 'dev-test'
defaultContainer 'jnlp'
yamlFile 'ci/jenkins/pod/testEnvironment.yaml'
}
}
stages {
stage("Deploy to Dev") {
steps {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/deploySingle2Dev.groovy"
}
}
}
}
stage("Dev Test") {
steps {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/singleDevTest.groovy"
}
}
}
}
stage ("Cleanup Dev") {
steps {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/cleanupSingleDev.groovy"
}
}
}
}
}
post {
unsuccessful {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/cleanupSingleDev.groovy"
}
}
}
}
}
}
}
}
}
timeout(time: 60, unit: 'MINUTES') {
dir ("ci/jenkins/scripts") {
sh "./build.sh -l"
withCredentials([usernamePassword(credentialsId: "${params.JFROG_CREDENTIALS_ID}", usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) {
sh "export JFROG_ARTFACTORY_URL='${params.JFROG_ARTFACTORY_URL}' && export JFROG_USER_NAME='${USERNAME}' && export JFROG_PASSWORD='${PASSWORD}' && ./build.sh -t ${params.BUILD_TYPE} -o /opt/milvus -d /opt/milvus -j -u -c"
}
}
}
try {
sh "helm del --purge ${env.PIPELINE_NAME}-${env.BUILD_NUMBER}-single-gpu"
} catch (exc) {
def helmResult = sh script: "helm status ${env.PIPELINE_NAME}-${env.BUILD_NUMBER}-single-gpu", returnStatus: true
if (!helmResult) {
sh "helm del --purge ${env.PIPELINE_NAME}-${env.BUILD_NUMBER}-single-gpu"
}
throw exc
}
timeout(time: 60, unit: 'MINUTES') {
dir ("ci/jenkins/scripts") {
sh "./coverage.sh -o /opt/milvus -u root -p 123456 -t \$POD_IP"
// Set some env variables so codecov detection script works correctly
withCredentials([[$class: 'StringBinding', credentialsId: "${env.PIPELINE_NAME}-codecov-token", variable: 'CODECOV_TOKEN']]) {
sh 'curl -s https://codecov.io/bash | bash -s - -f output_new.info || echo "Codecov did not collect coverage reports"'
}
}
}
try {
sh 'helm init --client-only --skip-refresh --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts'
sh 'helm repo update'
dir ('milvus-helm') {
checkout([$class: 'GitSCM', branches: [[name: "0.5.0"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_CREDENTIALS_ID}", url: "https://github.com/milvus-io/milvus-helm.git", name: 'origin', refspec: "+refs/heads/0.5.0:refs/remotes/origin/0.5.0"]]])
dir ("milvus-gpu") {
sh "helm install --wait --timeout 300 --set engine.image.tag=${DOCKER_VERSION} --set expose.type=clusterIP --name ${env.PIPELINE_NAME}-${env.BUILD_NUMBER}-single-gpu -f ci/values.yaml --namespace milvus ."
}
}
} catch (exc) {
echo 'Helm running failed!'
sh "helm del --purge ${env.PIPELINE_NAME}-${env.BUILD_NUMBER}-single-gpu"
throw exc
}
timeout(time: 5, unit: 'MINUTES') {
sh "tar -zcvf ./${PROJECT_NAME}-${PACKAGE_VERSION}.tar.gz -C /opt/ milvus"
withCredentials([usernamePassword(credentialsId: "${params.JFROG_CREDENTIALS_ID}", usernameVariable: 'JFROG_USERNAME', passwordVariable: 'JFROG_PASSWORD')]) {
def uploadStatus = sh(returnStatus: true, script: "curl -u${JFROG_USERNAME}:${JFROG_PASSWORD} -T ./${PROJECT_NAME}-${PACKAGE_VERSION}.tar.gz ${params.JFROG_ARTFACTORY_URL}/milvus/package/${PROJECT_NAME}-${PACKAGE_VERSION}.tar.gz")
if (uploadStatus != 0) {
error("\" ${PROJECT_NAME}-${PACKAGE_VERSION}.tar.gz \" upload to \" ${params.JFROG_ARTFACTORY_URL}/milvus/package/${PROJECT_NAME}-${PACKAGE_VERSION}.tar.gz \" failed!")
}
}
}
container('publish-images') {
timeout(time: 15, unit: 'MINUTES') {
dir ("docker/deploy/${OS_NAME}") {
def binaryPackage = "${PROJECT_NAME}-${PACKAGE_VERSION}.tar.gz"
withCredentials([usernamePassword(credentialsId: "${params.JFROG_CREDENTIALS_ID}", usernameVariable: 'JFROG_USERNAME', passwordVariable: 'JFROG_PASSWORD')]) {
def downloadStatus = sh(returnStatus: true, script: "curl -u${JFROG_USERNAME}:${JFROG_PASSWORD} -O ${params.JFROG_ARTFACTORY_URL}/milvus/package/${binaryPackage}")
if (downloadStatus != 0) {
error("\" Download \" ${params.JFROG_ARTFACTORY_URL}/milvus/package/${binaryPackage} \" failed!")
}
}
sh "tar zxvf ${binaryPackage}"
def imageName = "${PROJECT_NAME}/engine:${DOCKER_VERSION}"
try {
def isExistSourceImage = sh(returnStatus: true, script: "docker inspect --type=image ${imageName} 2>&1 > /dev/null")
if (isExistSourceImage == 0) {
def removeSourceImageStatus = sh(returnStatus: true, script: "docker rmi ${imageName}")
}
def customImage = docker.build("${imageName}")
def isExistTargeImage = sh(returnStatus: true, script: "docker inspect --type=image ${params.DOKCER_REGISTRY_URL}/${imageName} 2>&1 > /dev/null")
if (isExistTargeImage == 0) {
def removeTargeImageStatus = sh(returnStatus: true, script: "docker rmi ${params.DOKCER_REGISTRY_URL}/${imageName}")
}
docker.withRegistry("https://${params.DOKCER_REGISTRY_URL}", "${params.DOCKER_CREDENTIALS_ID}") {
customImage.push()
}
} catch (exc) {
throw exc
} finally {
def isExistSourceImage = sh(returnStatus: true, script: "docker inspect --type=image ${imageName} 2>&1 > /dev/null")
if (isExistSourceImage == 0) {
def removeSourceImageStatus = sh(returnStatus: true, script: "docker rmi ${imageName}")
}
def isExistTargeImage = sh(returnStatus: true, script: "docker inspect --type=image ${params.DOKCER_REGISTRY_URL}/${imageName} 2>&1 > /dev/null")
if (isExistTargeImage == 0) {
def removeTargeImageStatus = sh(returnStatus: true, script: "docker rmi ${params.DOKCER_REGISTRY_URL}/${imageName}")
}
}
}
}
}
timeout(time: 30, unit: 'MINUTES') {
dir ("tests/milvus_python_test") {
sh 'python3 -m pip install -r requirements.txt'
sh "pytest . --alluredir=\"test_out/dev/single/sqlite\" --level=1 --ip ${env.PIPELINE_NAME}-${env.BUILD_NUMBER}-single-gpu-milvus-gpu-engine.milvus.svc.cluster.local"
}
// mysql database backend test
load "${env.WORKSPACE}/ci/jenkins/jenkinsfile/cleanupSingleDev.groovy"
if (!fileExists('milvus-helm')) {
dir ("milvus-helm") {
checkout([$class: 'GitSCM', branches: [[name: "0.5.0"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_CREDENTIALS_ID}", url: "https://github.com/milvus-io/milvus-helm.git", name: 'origin', refspec: "+refs/heads/0.5.0:refs/remotes/origin/0.5.0"]]])
}
}
dir ("milvus-helm") {
dir ("milvus-gpu") {
sh "helm install --wait --timeout 300 --set engine.image.tag=${DOCKER_VERSION} --set expose.type=clusterIP --name ${env.PIPELINE_NAME}-${env.BUILD_NUMBER}-single-gpu -f ci/db_backend/mysql_values.yaml --namespace milvus ."
}
}
dir ("tests/milvus_python_test") {
sh "pytest . --alluredir=\"test_out/dev/single/mysql\" --level=1 --ip ${env.PIPELINE_NAME}-${env.BUILD_NUMBER}-single-gpu-milvus-gpu-engine.milvus.svc.cluster.local"
}
}
apiVersion: v1
kind: Pod
metadata:
labels:
app: publish
componet: docker
spec:
containers:
- name: publish-images
image: registry.zilliz.com/library/docker:v1.0.0
securityContext:
privileged: true
command:
- cat
tty: true
volumeMounts:
- name: docker-sock
mountPath: /var/run/docker.sock
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
apiVersion: v1
kind: Pod
metadata:
name: milvus-build-env
labels:
app: milvus
componet: build-env
spec:
containers:
- name: milvus-build-env
image: registry.zilliz.com/milvus/milvus-build-env:v0.5.0-ubuntu18.04
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
command:
- cat
tty: true
resources:
limits:
memory: "32Gi"
cpu: "8.0"
nvidia.com/gpu: 1
requests:
memory: "16Gi"
cpu: "4.0"
- name: milvus-mysql
image: mysql:5.6
env:
- name: MYSQL_ROOT_PASSWORD
value: 123456
ports:
- containerPort: 3306
name: mysql
apiVersion: v1
kind: Pod
metadata:
labels:
app: milvus
componet: test-env
spec:
containers:
- name: milvus-test-env
image: registry.zilliz.com/milvus/milvus-test-env:v0.1
command:
- cat
tty: true
volumeMounts:
- name: kubeconf
mountPath: /root/.kube/
readOnly: true
volumes:
- name: kubeconf
secret:
secretName: test-cluster-config
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SCRIPTS_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
CMAKE_BUILD_DIR="${SCRIPTS_DIR}/../../../core/cmake_build"
BUILD_TYPE="Debug"
BUILD_UNITTEST="OFF"
INSTALL_PREFIX="/opt/milvus"
BUILD_COVERAGE="OFF"
DB_PATH="/opt/milvus"
PROFILING="OFF"
USE_JFROG_CACHE="OFF"
RUN_CPPLINT="OFF"
CUSTOMIZATION="OFF" # default use ori faiss
CUDA_COMPILER=/usr/local/cuda/bin/nvcc
CUSTOMIZED_FAISS_URL="${FAISS_URL:-NONE}"
wget -q --method HEAD ${CUSTOMIZED_FAISS_URL}
if [ $? -eq 0 ]; then
CUSTOMIZATION="ON"
else
CUSTOMIZATION="OFF"
fi
while getopts "o:d:t:ulcgjhx" arg
do
case $arg in
o)
INSTALL_PREFIX=$OPTARG
;;
d)
DB_PATH=$OPTARG
;;
t)
BUILD_TYPE=$OPTARG # BUILD_TYPE
;;
u)
echo "Build and run unittest cases" ;
BUILD_UNITTEST="ON";
;;
l)
RUN_CPPLINT="ON"
;;
c)
BUILD_COVERAGE="ON"
;;
g)
PROFILING="ON"
;;
j)
USE_JFROG_CACHE="ON"
;;
x)
CUSTOMIZATION="OFF" # force use ori faiss
;;
h) # help
echo "
parameter:
-o: install prefix(default: /opt/milvus)
-d: db data path(default: /opt/milvus)
-t: build type(default: Debug)
-u: building unit test options(default: OFF)
-l: run cpplint, clang-format and clang-tidy(default: OFF)
-c: code coverage(default: OFF)
-g: profiling(default: OFF)
-j: use jfrog cache build directory(default: OFF)
-h: help
usage:
./build.sh -p \${INSTALL_PREFIX} -t \${BUILD_TYPE} [-u] [-l] [-r] [-c] [-g] [-j] [-h]
"
exit 0
;;
?)
echo "ERROR! unknown argument"
exit 1
;;
esac
done
if [[ ! -d ${CMAKE_BUILD_DIR} ]]; then
mkdir ${CMAKE_BUILD_DIR}
fi
cd ${CMAKE_BUILD_DIR}
# remove make cache since build.sh -l use default variables
# force update the variables each time
make rebuild_cache
CMAKE_CMD="cmake \
-DBUILD_UNIT_TEST=${BUILD_UNITTEST} \
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_CUDA_COMPILER=${CUDA_COMPILER} \
-DBUILD_COVERAGE=${BUILD_COVERAGE} \
-DMILVUS_DB_PATH=${DB_PATH} \
-DMILVUS_ENABLE_PROFILING=${PROFILING} \
-DUSE_JFROG_CACHE=${USE_JFROG_CACHE} \
-DCUSTOMIZATION=${CUSTOMIZATION} \
-DFAISS_URL=${CUSTOMIZED_FAISS_URL} \
.."
echo ${CMAKE_CMD}
${CMAKE_CMD}
if [[ ${RUN_CPPLINT} == "ON" ]]; then
# cpplint check
make lint
if [ $? -ne 0 ]; then
echo "ERROR! cpplint check failed"
exit 1
fi
echo "cpplint check passed!"
# clang-format check
make check-clang-format
if [ $? -ne 0 ]; then
echo "ERROR! clang-format check failed"
exit 1
fi
echo "clang-format check passed!"
# # clang-tidy check
# make check-clang-tidy
# if [ $? -ne 0 ]; then
# echo "ERROR! clang-tidy check failed"
# rm -f CMakeCache.txt
# exit 1
# fi
# echo "clang-tidy check passed!"
else
# compile and build
make -j8 || exit 1
make install || exit 1
fi
#!/bin/bash
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SCRIPTS_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
INSTALL_PREFIX="/opt/milvus"
CMAKE_BUILD_DIR="${SCRIPTS_DIR}/../../../core/cmake_build"
MYSQL_USER_NAME=root
MYSQL_PASSWORD=123456
MYSQL_HOST='127.0.0.1'
MYSQL_PORT='3306'
while getopts "o:u:p:t:h" arg
do
case $arg in
o)
INSTALL_PREFIX=$OPTARG
;;
u)
MYSQL_USER_NAME=$OPTARG
;;
p)
MYSQL_PASSWORD=$OPTARG
;;
t)
MYSQL_HOST=$OPTARG
;;
h) # help
echo "
parameter:
-o: milvus install prefix(default: /opt/milvus)
-u: mysql account
-p: mysql password
-t: mysql host
-h: help
usage:
./coverage.sh -o \${INSTALL_PREFIX} -u \${MYSQL_USER} -p \${MYSQL_PASSWORD} -t \${MYSQL_HOST} [-h]
"
exit 0
;;
?)
echo "ERROR! unknown argument"
exit 1
;;
esac
done
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${INSTALL_PREFIX}/lib
LCOV_CMD="lcov"
# LCOV_GEN_CMD="genhtml"
FILE_INFO_BASE="base.info"
FILE_INFO_MILVUS="server.info"
FILE_INFO_OUTPUT="output.info"
FILE_INFO_OUTPUT_NEW="output_new.info"
DIR_LCOV_OUTPUT="lcov_out"
DIR_GCNO="${CMAKE_BUILD_DIR}"
DIR_UNITTEST="${INSTALL_PREFIX}/unittest"
# delete old code coverage info files
rm -rf lcov_out
rm -f FILE_INFO_BASE FILE_INFO_MILVUS FILE_INFO_OUTPUT FILE_INFO_OUTPUT_NEW
MYSQL_DB_NAME=milvus_`date +%s%N`
function mysql_exc()
{
cmd=$1
mysql -h${MYSQL_HOST} -u${MYSQL_USER_NAME} -p${MYSQL_PASSWORD} -e "${cmd}"
if [ $? -ne 0 ]; then
echo "mysql $cmd run failed"
fi
}
mysql_exc "CREATE DATABASE IF NOT EXISTS ${MYSQL_DB_NAME};"
mysql_exc "GRANT ALL PRIVILEGES ON ${MYSQL_DB_NAME}.* TO '${MYSQL_USER_NAME}'@'%';"
mysql_exc "FLUSH PRIVILEGES;"
mysql_exc "USE ${MYSQL_DB_NAME};"
# get baseline
${LCOV_CMD} -c -i -d ${DIR_GCNO} -o "${FILE_INFO_BASE}"
if [ $? -ne 0 ]; then
echo "gen baseline coverage run failed"
exit -1
fi
for test in `ls ${DIR_UNITTEST}`; do
echo $test
case ${test} in
test_db)
# set run args for test_db
args="mysql://${MYSQL_USER_NAME}:${MYSQL_PASSWORD}@${MYSQL_HOST}:${MYSQL_PORT}/${MYSQL_DB_NAME}"
;;
*test_*)
args=""
;;
esac
# run unittest
${DIR_UNITTEST}/${test} "${args}"
if [ $? -ne 0 ]; then
echo ${args}
echo ${DIR_UNITTEST}/${test} "run failed"
fi
done
mysql_exc "DROP DATABASE IF EXISTS ${MYSQL_DB_NAME};"
# gen code coverage
${LCOV_CMD} -d ${DIR_GCNO} -o "${FILE_INFO_MILVUS}" -c
# merge coverage
${LCOV_CMD} -a ${FILE_INFO_BASE} -a ${FILE_INFO_MILVUS} -o "${FILE_INFO_OUTPUT}"
# remove third party from tracefiles
${LCOV_CMD} -r "${FILE_INFO_OUTPUT}" -o "${FILE_INFO_OUTPUT_NEW}" \
"/usr/*" \
"*/boost/*" \
"*/cmake_build/*_ep-prefix/*" \
"*/src/index/cmake_build*" \
"*/src/index/thirdparty*" \
"*/src/grpc*" \
"*/src/metrics/MetricBase.h" \
"*/src/server/Server.cpp" \
"*/src/server/DBWrapper.cpp" \
"*/src/server/grpc_impl/GrpcServer.cpp" \
"*/src/utils/easylogging++.h" \
"*/src/utils/easylogging++.cc"
# gen html report
# ${LCOV_GEN_CMD} "${FILE_INFO_OUTPUT_NEW}" --output-directory ${DIR_LCOV_OUTPUT}/
FROM nvidia/cuda:10.1-devel-ubuntu16.04
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
RUN apt-get update && apt-get install -y --no-install-recommends wget && \
wget -qO- "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local && \
wget -P /tmp https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
apt-key add /tmp/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list' && \
apt-get update && apt-get install -y --no-install-recommends \
git flex bison gfortran \
curl libtool automake libboost1.58-all-dev libssl-dev pkg-config libcurl4-openssl-dev \
clang-format-6.0 clang-tidy-6.0 \
lcov mysql-client libmysqlclient-dev intel-mkl-gnu-2019.4-243 intel-mkl-core-2019.4-243 && \
apt-get remove --purge -y && \
rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so
RUN sh -c 'echo export LD_LIBRARY_PATH=/opt/intel/compilers_and_libraries_2019.4.243/linux/mkl/lib/intel64:\$LD_LIBRARY_PATH > /etc/profile.d/mkl.sh'
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
ENTRYPOINT [ "/app/docker-entrypoint.sh" ]
CMD [ "start" ]
#!/bin/bash
set -e
if [ "$1" = 'start' ]; then
tail -f /dev/null
fi
exec "$@"
FROM nvidia/cuda:10.1-devel-ubuntu18.04
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
RUN apt-get update && apt-get install -y --no-install-recommends wget && \
wget -qO- "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local && \
wget -P /tmp https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
apt-key add /tmp/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2019.PUB && \
sh -c 'echo deb https://apt.repos.intel.com/mkl all main > /etc/apt/sources.list.d/intel-mkl.list' && \
apt-get update && apt-get install -y --no-install-recommends \
git flex bison gfortran \
curl libtool automake libboost-all-dev libssl-dev pkg-config libcurl4-openssl-dev \
clang-format-6.0 clang-tidy-6.0 \
lcov mysql-client libmysqlclient-dev intel-mkl-gnu-2019.4-243 intel-mkl-core-2019.4-243 && \
apt-get remove --purge -y && \
rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so
RUN sh -c 'echo export LD_LIBRARY_PATH=/opt/intel/compilers_and_libraries_2019.4.243/linux/mkl/lib/intel64:\$LD_LIBRARY_PATH > /etc/profile.d/mkl.sh'
COPY docker-entrypoint.sh /app/docker-entrypoint.sh
ENTRYPOINT [ "/app/docker-entrypoint.sh" ]
CMD [ "start" ]
#!/bin/bash
set -e
if [ "$1" = 'start' ]; then
tail -f /dev/null
fi
exec "$@"
FROM nvidia/cuda:10.1-devel-ubuntu16.04
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
RUN rm -rf /etc/apt/sources.list.d/nvidia-ml.list && rm -rf /etc/apt/sources.list.d/cuda.list
RUN apt-get update && apt-get install -y --no-install-recommends \
gfortran libsqlite3-dev libmysqlclient-dev libcurl4-openssl-dev python3 && \
apt-get remove --purge -y && \
rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so
COPY ./docker-entrypoint.sh /opt
COPY ./milvus /opt/milvus
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/milvus/lib"
ENTRYPOINT [ "/opt/docker-entrypoint.sh" ]
CMD [ "start" ]
EXPOSE 19530
#!/bin/bash
set -e
if [ "$1" == 'start' ]; then
cd /opt/milvus/scripts && ./start_server.sh
fi
exec "$@"
FROM nvidia/cuda:10.1-devel-ubuntu18.04
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
RUN rm -rf /etc/apt/sources.list.d/nvidia-ml.list && rm -rf /etc/apt/sources.list.d/cuda.list
RUN apt-get update && apt-get install -y --no-install-recommends \
gfortran libsqlite3-dev libmysqlclient-dev libcurl4-openssl-dev python3 && \
apt-get remove --purge -y && \
rm -rf /var/lib/apt/lists/*
RUN ln -s /usr/lib/x86_64-linux-gnu/libmysqlclient.so /usr/lib/x86_64-linux-gnu/libmysqlclient_r.so
COPY ./docker-entrypoint.sh /opt
COPY ./milvus /opt/milvus
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/milvus/lib"
ENTRYPOINT [ "/opt/docker-entrypoint.sh" ]
CMD [ "start" ]
EXPOSE 19530
#!/bin/bash
set -e
if [ "$1" == 'start' ]; then
cd /opt/milvus/scripts && ./start_server.sh
fi
exec "$@"
# Requirements
- jdk-1.8
- testng
# How to use this Test Project
1. package and install
```shell
mvn clean install
```
2. start or deploy your milvus server
3. run tests
```shell
java -cp \"target/MilvusSDkJavaTest-1.0-SNAPSHOT.jar:lib/*\" com.MainClass -h 127.0.0.1
```
4. get test report
```shell
firefox test-output/index.html
```
# Contribution getting started
Add test cases under testng framework
\ No newline at end of file
......@@ -99,12 +99,12 @@
<dependency>
<groupId>io.milvus</groupId>
<artifactId>milvus-sdk-java</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.2.0-SNAPSHOT</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>io.grpc</groupId>-->
<!-- <artifactId>grpc-netty-shaded</artifactId>-->
<!-- <artifactId>grpc-netty-sher staded</artifactId>-->
<!-- <scope>runtime</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
......
......@@ -16,8 +16,8 @@ import java.util.List;
public class MainClass {
private static String host = "127.0.0.1";
private static String port = "19530";
public Integer index_file_size = 50;
public Integer dimension = 128;
private int index_file_size = 50;
public int dimension = 128;
public static void setHost(String host) {
MainClass.host = host;
......@@ -33,7 +33,7 @@ public class MainClass {
}
@DataProvider(name="ConnectInstance")
public Object[][] connectInstance(){
public Object[][] connectInstance() throws ConnectFailedException {
MilvusClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder()
.withHost(host)
......@@ -45,7 +45,7 @@ public class MainClass {
}
@DataProvider(name="DisConnectInstance")
public Object[][] disConnectInstance(){
public Object[][] disConnectInstance() throws ConnectFailedException {
// Generate connection instance
MilvusClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder()
......@@ -63,10 +63,10 @@ public class MainClass {
}
@DataProvider(name="Table")
public Object[][] provideTable(){
public Object[][] provideTable() throws ConnectFailedException {
Object[][] tables = new Object[2][2];
MetricType metricTypes[] = { MetricType.L2, MetricType.IP };
for (Integer i = 0; i < metricTypes.length; ++i) {
MetricType[] metricTypes = { MetricType.L2, MetricType.IP };
for (int i = 0; i < metricTypes.length; ++i) {
String tableName = metricTypes[i].toString()+"_"+RandomStringUtils.randomAlphabetic(10);
// Generate connection instance
MilvusClient client = new MilvusGrpcClient();
......@@ -79,8 +79,7 @@ public class MainClass {
.withIndexFileSize(index_file_size)
.withMetricType(metricTypes[i])
.build();
TableSchemaParam tableSchemaParam = new TableSchemaParam.Builder(tableSchema).build();
Response res = client.createTable(tableSchemaParam);
Response res = client.createTable(tableSchema);
if (!res.ok()) {
System.out.println(res.getMessage());
throw new SkipException("Table created failed");
......
......@@ -3,7 +3,6 @@ package com;
import io.milvus.client.InsertParam;
import io.milvus.client.InsertResponse;
import io.milvus.client.MilvusClient;
import io.milvus.client.TableParam;
import org.testng.Assert;
import org.testng.annotations.Test;
......@@ -55,19 +54,18 @@ public class TestAddVectors {
assert(res.getResponse().ok());
Thread.currentThread().sleep(1000);
// Assert table row count
TableParam tableParam = new TableParam.Builder(tableName).build();
Assert.assertEquals(client.getTableRowCount(tableParam).getTableRowCount(), nb);
Assert.assertEquals(client.getTableRowCount(tableName).getTableRowCount(), nb);
}
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_add_vectors_timeout(MilvusClient client, String tableName) throws InterruptedException {
int nb = 200000;
List<List<Float>> vectors = gen_vectors(nb);
System.out.println(new Date());
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).withTimeout(1).build();
InsertResponse res = client.insert(insertParam);
assert(!res.getResponse().ok());
}
// @Test(dataProvider = "Table", dataProviderClass = MainClass.class)
// public void test_add_vectors_timeout(MilvusClient client, String tableName) throws InterruptedException {
// int nb = 200000;
// List<List<Float>> vectors = gen_vectors(nb);
// System.out.println(new Date());
// InsertParam insertParam = new InsertParam.Builder(tableName, vectors).withTimeout(1).build();
// InsertResponse res = client.insert(insertParam);
// assert(!res.getResponse().ok());
// }
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_add_vectors_big_data(MilvusClient client, String tableName) throws InterruptedException {
......@@ -91,10 +89,9 @@ public class TestAddVectors {
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).withVectorIds(vectorIds).build();
InsertResponse res = client.insert(insertParam);
assert(res.getResponse().ok());
Thread.currentThread().sleep(1000);
Thread.currentThread().sleep(2000);
// Assert table row count
TableParam tableParam = new TableParam.Builder(tableName).build();
Assert.assertEquals(client.getTableRowCount(tableParam).getTableRowCount(), nb);
Assert.assertEquals(client.getTableRowCount(tableName).getTableRowCount(), nb);
}
// TODO: MS-628
......@@ -147,8 +144,7 @@ public class TestAddVectors {
}
Thread.currentThread().sleep(1000);
// Assert table row count
TableParam tableParam = new TableParam.Builder(tableName).build();
Assert.assertEquals(client.getTableRowCount(tableParam).getTableRowCount(), nb * loops);
Assert.assertEquals(client.getTableRowCount(tableName).getTableRowCount(), nb * loops);
}
}
package com;
import io.milvus.client.ConnectParam;
import io.milvus.client.MilvusClient;
import io.milvus.client.MilvusGrpcClient;
import io.milvus.client.Response;
import io.milvus.client.*;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class TestConnect {
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)
public void test_connect(String host, String port){
public void test_connect(String host, String port) throws ConnectFailedException {
System.out.println("Host: "+host+", Port: "+port);
MilvusClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder()
......@@ -18,31 +16,42 @@ public class TestConnect {
.build();
Response res = client.connect(connectParam);
assert(res.ok());
assert(client.connected());
assert(client.isConnected());
}
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)
public void test_connect_repeat(String host, String port){
public void test_connect_repeat(String host, String port) {
MilvusGrpcClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder()
.withHost(host)
.withPort(port)
.build();
client.connect(connectParam);
Response res = client.connect(connectParam);
assert(!res.ok());
assert(client.connected());
Response res = null;
try {
res = client.connect(connectParam);
res = client.connect(connectParam);
} catch (ConnectFailedException e) {
e.printStackTrace();
}
assert (res.ok());
assert(client.isConnected());
}
@Test(dataProvider="InvalidConnectArgs")
public void test_connect_invalid_connect_args(String ip, String port) throws InterruptedException {
public void test_connect_invalid_connect_args(String ip, String port) {
MilvusClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder()
.withHost(ip)
.withPort(port)
.build();
client.connect(connectParam);
assert(!client.connected());
Response res = null;
try {
res = client.connect(connectParam);
} catch (ConnectFailedException e) {
e.printStackTrace();
}
Assert.assertEquals(res, null);
assert(!client.isConnected());
}
// TODO: MS-615
......@@ -63,18 +72,18 @@ public class TestConnect {
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_disconnect(MilvusClient client, String tableName){
assert(!client.connected());
assert(!client.isConnected());
}
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_disconnect_repeatably(MilvusClient client, String tableNam){
public void test_disconnect_repeatably(MilvusClient client, String tableName){
Response res = null;
try {
res = client.disconnect();
} catch (InterruptedException e) {
e.printStackTrace();
}
assert(res.ok());
assert(!client.connected());
assert(!res.ok());
assert(!client.isConnected());
}
}
package com;
import io.milvus.client.*;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.*;
public class TestDeleteVectors {
......@@ -31,92 +27,90 @@ public class TestDeleteVectors {
return c.getTime();
}
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_delete_vectors(MilvusClient client, String tableName) throws InterruptedException {
int nb = 10000;
List<List<Float>> vectors = gen_vectors(nb);
// Add vectors
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
InsertResponse res = client.insert(insertParam);
assert(res.getResponse().ok());
Thread.sleep(1000);
DateRange dateRange = new DateRange(getDeltaDate(-1), getDeltaDate(1));
DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
Response res_delete = client.deleteByRange(param);
assert(res_delete.ok());
Thread.sleep(1000);
// Assert table row count
TableParam tableParam = new TableParam.Builder(tableName).build();
Assert.assertEquals(client.getTableRowCount(tableParam).getTableRowCount(), 0);
}
// @Test(dataProvider = "Table", dataProviderClass = MainClass.class)
// public void test_delete_vectors(MilvusClient client, String tableName) throws InterruptedException {
// int nb = 10000;
// List<List<Float>> vectors = gen_vectors(nb);
// // Add vectors
// InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
// InsertResponse res = client.insert(insertParam);
// assert(res.getResponse().ok());
// Thread.sleep(1000);
// DateRange dateRange = new DateRange(getDeltaDate(-1), getDeltaDate(1));
// DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
// Response res_delete = client.deleteByRange(param);
// assert(res_delete.ok());
// Thread.sleep(1000);
// // Assert table row count
// Assert.assertEquals(client.getTableRowCount(tableParam).getTableRowCount(), 0);
// }
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_delete_vectors_table_not_existed(MilvusClient client, String tableName) throws InterruptedException {
String tableNameNew = tableName + "_";
DateRange dateRange = new DateRange(getDeltaDate(-1), getDeltaDate(1));
DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableNameNew).build();
Response res_delete = client.deleteByRange(param);
assert(!res_delete.ok());
}
// @Test(dataProvider = "Table", dataProviderClass = MainClass.class)
// public void test_delete_vectors_table_not_existed(MilvusClient client, String tableName) throws InterruptedException {
// String tableNameNew = tableName + "_";
// DateRange dateRange = new DateRange(getDeltaDate(-1), getDeltaDate(1));
// DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableNameNew).build();
// Response res_delete = client.deleteByRange(param);
// assert(!res_delete.ok());
// }
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_delete_vectors_without_connect(MilvusClient client, String tableName) throws InterruptedException {
DateRange dateRange = new DateRange(getDeltaDate(-1), getDeltaDate(1));
DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
Response res_delete = client.deleteByRange(param);
assert(!res_delete.ok());
}
// @Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
// public void test_delete_vectors_without_connect(MilvusClient client, String tableName) throws InterruptedException {
// DateRange dateRange = new DateRange(getDeltaDate(-1), getDeltaDate(1));
// DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
// Response res_delete = client.deleteByRange(param);
// assert(!res_delete.ok());
// }
//
// @Test(dataProvider = "Table", dataProviderClass = MainClass.class)
// public void test_delete_vectors_table_empty(MilvusClient client, String tableName) throws InterruptedException {
// DateRange dateRange = new DateRange(getDeltaDate(-1), getDeltaDate(1));
// DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
// Response res_delete = client.deleteByRange(param);
// assert(res_delete.ok());
// }
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_delete_vectors_table_empty(MilvusClient client, String tableName) throws InterruptedException {
DateRange dateRange = new DateRange(getDeltaDate(-1), getDeltaDate(1));
DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
Response res_delete = client.deleteByRange(param);
assert(res_delete.ok());
}
// @Test(dataProvider = "Table", dataProviderClass = MainClass.class)
// public void test_delete_vectors_invalid_date_range(MilvusClient client, String tableName) throws InterruptedException {
// int nb = 100;
// List<List<Float>> vectors = gen_vectors(nb);
// // Add vectors
// InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
// InsertResponse res = client.insert(insertParam);
// assert(res.getResponse().ok());
// Thread.sleep(1000);
// DateRange dateRange = new DateRange(getDeltaDate(1), getDeltaDate(0));
// DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
// Response res_delete = client.deleteByRange(param);
// assert(!res_delete.ok());
// }
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_delete_vectors_invalid_date_range(MilvusClient client, String tableName) throws InterruptedException {
int nb = 100;
List<List<Float>> vectors = gen_vectors(nb);
// Add vectors
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
InsertResponse res = client.insert(insertParam);
assert(res.getResponse().ok());
Thread.sleep(1000);
DateRange dateRange = new DateRange(getDeltaDate(1), getDeltaDate(0));
DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
Response res_delete = client.deleteByRange(param);
assert(!res_delete.ok());
}
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_delete_vectors_invalid_date_range_1(MilvusClient client, String tableName) throws InterruptedException {
int nb = 100;
List<List<Float>> vectors = gen_vectors(nb);
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
InsertResponse res = client.insert(insertParam);
assert(res.getResponse().ok());
DateRange dateRange = new DateRange(getDeltaDate(2), getDeltaDate(-1));
DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
Response res_delete = client.deleteByRange(param);
assert(!res_delete.ok());
}
// @Test(dataProvider = "Table", dataProviderClass = MainClass.class)
// public void test_delete_vectors_invalid_date_range_1(MilvusClient client, String tableName) throws InterruptedException {
// int nb = 100;
// List<List<Float>> vectors = gen_vectors(nb);
// InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
// InsertResponse res = client.insert(insertParam);
// assert(res.getResponse().ok());
// DateRange dateRange = new DateRange(getDeltaDate(2), getDeltaDate(-1));
// DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
// Response res_delete = client.deleteByRange(param);
// assert(!res_delete.ok());
// }
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_delete_vectors_no_result(MilvusClient client, String tableName) throws InterruptedException {
int nb = 100;
List<List<Float>> vectors = gen_vectors(nb);
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
InsertResponse res = client.insert(insertParam);
assert(res.getResponse().ok());
Thread.sleep(1000);
DateRange dateRange = new DateRange(getDeltaDate(-3), getDeltaDate(-2));
DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
Response res_delete = client.deleteByRange(param);
assert(res_delete.ok());
TableParam tableParam = new TableParam.Builder(tableName).build();
Assert.assertEquals(client.getTableRowCount(tableParam).getTableRowCount(), nb);
}
// @Test(dataProvider = "Table", dataProviderClass = MainClass.class)
// public void test_delete_vectors_no_result(MilvusClient client, String tableName) throws InterruptedException {
// int nb = 100;
// List<List<Float>> vectors = gen_vectors(nb);
// InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
// InsertResponse res = client.insert(insertParam);
// assert(res.getResponse().ok());
// Thread.sleep(1000);
// DateRange dateRange = new DateRange(getDeltaDate(-3), getDeltaDate(-2));
// DeleteByRangeParam param = new DeleteByRangeParam.Builder(dateRange, tableName).build();
// Response res_delete = client.deleteByRange(param);
// assert(res_delete.ok());
// Assert.assertEquals(client.getTableRowCount(tableParam).getTableRowCount(), nb);
// }
}
......@@ -4,7 +4,6 @@ import io.milvus.client.*;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
......@@ -56,8 +55,7 @@ public class TestIndex {
Response res_create = client.createIndex(createIndexParam);
res_create = client.createIndex(createIndexParam);
assert(res_create.ok());
TableParam tableParam = new TableParam.Builder(tableName).build();
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getNList(), n_list);
......@@ -76,29 +74,27 @@ public class TestIndex {
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
Response res_create = client.createIndex(createIndexParam);
assert(res_create.ok());
TableParam tableParam = new TableParam.Builder(tableName).build();
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getIndexType(), indexType);
}
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_create_index_FLAT_timeout(MilvusClient client, String tableName) throws InterruptedException {
int nb = 500000;
IndexType indexType = IndexType.IVF_SQ8;
List<List<Float>> vectors = gen_vectors(nb);
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
client.insert(insertParam);
Index index = new Index.Builder().withIndexType(indexType)
.withNList(n_list)
.build();
System.out.println(new Date());
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).withTimeout(1).build();
Response res_create = client.createIndex(createIndexParam);
assert(!res_create.ok());
}
// @Test(dataProvider = "Table", dataProviderClass = MainClass.class)
// public void test_create_index_FLAT_timeout(MilvusClient client, String tableName) throws InterruptedException {
// int nb = 500000;
// IndexType indexType = IndexType.IVF_SQ8;
// List<List<Float>> vectors = gen_vectors(nb);
// InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
// client.insert(insertParam);
// Index index = new Index.Builder().withIndexType(indexType)
// .withNList(n_list)
// .build();
// System.out.println(new Date());
// CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).withTimeout(1).build();
// Response res_create = client.createIndex(createIndexParam);
// assert(!res_create.ok());
// }
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_create_index_IVFLAT(MilvusClient client, String tableName) throws InterruptedException {
......@@ -112,8 +108,7 @@ public class TestIndex {
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
Response res_create = client.createIndex(createIndexParam);
assert(res_create.ok());
TableParam tableParam = new TableParam.Builder(tableName).build();
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getIndexType(), indexType);
......@@ -131,8 +126,7 @@ public class TestIndex {
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
Response res_create = client.createIndex(createIndexParam);
assert(res_create.ok());
TableParam tableParam = new TableParam.Builder(tableName).build();
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getIndexType(), indexType);
......@@ -140,7 +134,7 @@ public class TestIndex {
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_create_index_IVFSQ8H(MilvusClient client, String tableName) throws InterruptedException {
IndexType indexType = IndexType.IVF_SQ8_H;
IndexType indexType = IndexType.IVF_SQ8H;
List<List<Float>> vectors = gen_vectors(nb);
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
client.insert(insertParam);
......@@ -150,8 +144,7 @@ public class TestIndex {
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
Response res_create = client.createIndex(createIndexParam);
assert(res_create.ok());
TableParam tableParam = new TableParam.Builder(tableName).build();
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getIndexType(), indexType);
......@@ -213,8 +206,7 @@ public class TestIndex {
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
Response res_create = client.createIndex(createIndexParam);
assert(res_create.ok());
TableParam tableParam = new TableParam.Builder(tableName).build();
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getNList(), n_list);
......@@ -232,7 +224,6 @@ public class TestIndex {
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
Response res_create = client.createIndex(createIndexParam);
assert(res_create.ok());
TableParam tableParam = new TableParam.Builder(tableName).build();
// Create another index
IndexType indexTypeNew = IndexType.IVFLAT;
int n_list_new = n_list + 1;
......@@ -242,7 +233,7 @@ public class TestIndex {
CreateIndexParam createIndexParamNew = new CreateIndexParam.Builder(tableName).withIndex(index_new).build();
Response res_create_new = client.createIndex(createIndexParamNew);
assert(res_create_new.ok());
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(res_create.ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getNList(), n_list_new);
......@@ -252,15 +243,13 @@ public class TestIndex {
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_describe_index_table_not_existed(MilvusClient client, String tableName) throws InterruptedException {
String tableNameNew = tableName + "_";
TableParam tableParam = new TableParam.Builder(tableNameNew).build();
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableNameNew);
assert(!res.getResponse().ok());
}
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_describe_index_without_connect(MilvusClient client, String tableName) throws InterruptedException {
TableParam tableParam = new TableParam.Builder(tableName).build();
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(!res.getResponse().ok());
}
......@@ -275,10 +264,9 @@ public class TestIndex {
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
Response res_create = client.createIndex(createIndexParam);
assert(res_create.ok());
TableParam tableParam = new TableParam.Builder(tableName).build();
Response res_drop = client.dropIndex(tableParam);
Response res_drop = client.dropIndex(tableName);
assert(res_drop.ok());
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getNList(), default_n_list);
......@@ -296,11 +284,10 @@ public class TestIndex {
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
Response res_create = client.createIndex(createIndexParam);
assert(res_create.ok());
TableParam tableParam = new TableParam.Builder(tableName).build();
Response res_drop = client.dropIndex(tableParam);
res_drop = client.dropIndex(tableParam);
Response res_drop = client.dropIndex(tableName);
res_drop = client.dropIndex(tableName);
assert(res_drop.ok());
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getNList(), default_n_list);
......@@ -310,15 +297,13 @@ public class TestIndex {
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_drop_index_table_not_existed(MilvusClient client, String tableName) throws InterruptedException {
String tableNameNew = tableName + "_";
TableParam tableParam = new TableParam.Builder(tableNameNew).build();
Response res_drop = client.dropIndex(tableParam);
Response res_drop = client.dropIndex(tableNameNew);
assert(!res_drop.ok());
}
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_drop_index_without_connect(MilvusClient client, String tableName) throws InterruptedException {
TableParam tableParam = new TableParam.Builder(tableName).build();
Response res_drop = client.dropIndex(tableParam);
Response res_drop = client.dropIndex(tableName);
assert(!res_drop.ok());
}
......@@ -327,10 +312,9 @@ public class TestIndex {
List<List<Float>> vectors = gen_vectors(nb);
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
client.insert(insertParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
Response res_drop = client.dropIndex(tableParam);
Response res_drop = client.dropIndex(tableName);
assert(res_drop.ok());
DescribeIndexResponse res = client.describeIndex(tableParam);
DescribeIndexResponse res = client.describeIndex(tableName);
assert(res.getResponse().ok());
Index index1 = res.getIndex().get();
Assert.assertEquals(index1.getNList(), default_n_list);
......
......@@ -71,7 +71,7 @@ public class TestMix {
}
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)
public void test_connect_threads(String host, String port) throws InterruptedException {
public void test_connect_threads(String host, String port) throws ConnectFailedException {
int thread_num = 100;
ForkJoinPool executor = new ForkJoinPool();
for (int i = 0; i < thread_num; i++) {
......@@ -82,8 +82,12 @@ public class TestMix {
.withHost(host)
.withPort(port)
.build();
client.connect(connectParam);
assert(client.connected());
try {
client.connect(connectParam);
} catch (ConnectFailedException e) {
e.printStackTrace();
}
assert(client.isConnected());
try {
client.disconnect();
} catch (InterruptedException e) {
......@@ -112,8 +116,7 @@ public class TestMix {
executor.shutdown();
Thread.sleep(2000);
TableParam tableParam = new TableParam.Builder(tableName).build();
GetTableRowCountResponse getTableRowCountResponse = client.getTableRowCount(tableParam);
GetTableRowCountResponse getTableRowCountResponse = client.getTableRowCount(tableName);
Assert.assertEquals(getTableRowCountResponse.getTableRowCount(), thread_num * nb);
}
......@@ -138,8 +141,7 @@ public class TestMix {
executor.awaitQuiescence(300, TimeUnit.SECONDS);
executor.shutdown();
Thread.sleep(2000);
TableParam tableParam = new TableParam.Builder(tableName).build();
GetTableRowCountResponse getTableRowCountResponse = client.getTableRowCount(tableParam);
GetTableRowCountResponse getTableRowCountResponse = client.getTableRowCount(tableName);
Assert.assertEquals(getTableRowCountResponse.getTableRowCount(), thread_num * nb);
}
......@@ -176,13 +178,12 @@ public class TestMix {
executor.awaitQuiescence(300, TimeUnit.SECONDS);
executor.shutdown();
Thread.sleep(2000);
TableParam tableParam = new TableParam.Builder(tableName).build();
GetTableRowCountResponse getTableRowCountResponse = client.getTableRowCount(tableParam);
GetTableRowCountResponse getTableRowCountResponse = client.getTableRowCount(tableName);
Assert.assertEquals(getTableRowCountResponse.getTableRowCount(), thread_num * nb);
}
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)
public void test_create_insert_delete_threads(String host, String port) throws InterruptedException {
public void test_create_insert_delete_threads(String host, String port) {
int thread_num = 100;
List<List<Float>> vectors = gen_vectors(nb,false);
ForkJoinPool executor = new ForkJoinPool();
......@@ -194,18 +195,21 @@ public class TestMix {
.withHost(host)
.withPort(port)
.build();
client.connect(connectParam);
try {
client.connect(connectParam);
} catch (ConnectFailedException e) {
e.printStackTrace();
}
assert(client.isConnected());
String tableName = RandomStringUtils.randomAlphabetic(10);
TableSchema tableSchema = new TableSchema.Builder(tableName, dimension)
.withIndexFileSize(index_file_size)
.withMetricType(MetricType.IP)
.build();
TableSchemaParam tableSchemaParam = new TableSchemaParam.Builder(tableSchema).build();
client.createTable(tableSchemaParam);
client.createTable(tableSchema);
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
client.insert(insertParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
Response response = client.dropTable(tableParam);
Response response = client.dropTable(tableName);
Assert.assertTrue(response.ok());
try {
client.disconnect();
......
package com;
import io.milvus.client.ConnectParam;
import io.milvus.client.MilvusClient;
import io.milvus.client.MilvusGrpcClient;
import io.milvus.client.Response;
import io.milvus.client.*;
import org.testng.annotations.Test;
public class TestPing {
@Test(dataProvider = "DefaultConnectArgs", dataProviderClass = MainClass.class)
public void test_server_status(String host, String port){
public void test_server_status(String host, String port) throws ConnectFailedException {
System.out.println("Host: "+host+", Port: "+port);
MilvusClient client = new MilvusGrpcClient();
ConnectParam connectParam = new ConnectParam.Builder()
......@@ -16,13 +13,13 @@ public class TestPing {
.withPort(port)
.build();
client.connect(connectParam);
Response res = client.serverStatus();
Response res = client.getServerStatus();
assert (res.ok());
}
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_server_status_without_connected(MilvusGrpcClient client, String tableName){
Response res = client.serverStatus();
Response res = client.getServerStatus();
assert (!res.ok());
}
}
\ No newline at end of file
......@@ -77,7 +77,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).build();
List<List<SearchResponse.QueryResult>> res_search = client.search(searchParam).getQueryResultsList();
Assert.assertEquals(res_search.size(), nq);
......@@ -101,7 +100,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).build();
List<List<SearchResponse.QueryResult>> res_search = client.search(searchParam).getQueryResultsList();
Assert.assertEquals(res_search.get(0).get(0).getVectorId(), 0L);
......@@ -115,7 +113,7 @@ public class TestSearchVectors {
List<List<Float>> queryVectors = vectors.subList(0,nq);
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
client.insert(insertParam);
Thread.sleep(1000);
Thread.sleep(2000);
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).build();
List<List<SearchResponse.QueryResult>> res_search = client.search(searchParam).getQueryResultsList();
Assert.assertEquals(res_search.size(), nq);
......@@ -135,7 +133,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).build();
List<List<SearchResponse.QueryResult>> res_search = client.search(searchParam).getQueryResultsList();
double distance = res_search.get(0).get(0).getDistance();
......@@ -159,7 +156,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).build();
List<List<SearchResponse.QueryResult>> res_search = client.search(searchParam).getQueryResultsList();
Assert.assertEquals(res_search.size(), nq);
......@@ -195,7 +191,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).build();
List<List<Double>> res_search = client.search(searchParam).getResultDistancesList();
for (int i = 0; i < nq; i++) {
......@@ -222,7 +217,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).build();
List<List<SearchResponse.QueryResult>> res_search = client.search(searchParam).getQueryResultsList();
Assert.assertEquals(res_search.size(), nq);
......@@ -244,22 +238,23 @@ public class TestSearchVectors {
Assert.assertEquals(res_search.get(0).size(), top_k);
}
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_search_FLAT_timeout(MilvusClient client, String tableName) throws InterruptedException {
IndexType indexType = IndexType.FLAT;
int nb = 100000;
int nq = 1000;
int top_k = 2048;
List<List<Float>> vectors = gen_vectors(nb, false);
List<List<Float>> queryVectors = vectors.subList(0,nq);
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
client.insert(insertParam);
Thread.sleep(1000);
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).withTimeout(1).build();
System.out.println(new Date());
SearchResponse res_search = client.search(searchParam);
assert (!res_search.getResponse().ok());
}
// @Test(dataProvider = "Table", dataProviderClass = MainClass.class)
// public void test_search_FLAT_timeout(MilvusClient client, String tableName) throws InterruptedException {
// IndexType indexType = IndexType.FLAT;
// int nb = 100000;
// int nq = 1000;
// int top_k = 2048;
// List<List<Float>> vectors = gen_vectors(nb, false);
// List<List<Float>> vectors = gen_vectors(nb, false);
// List<List<Float>> queryVectors = vectors.subList(0,nq);
// InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();
// client.insert(insertParam);
// Thread.sleep(1000);
// SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).withTimeout(1).build();
// System.out.println(new Date());
// SearchResponse res_search = client.search(searchParam);
// assert (!res_search.getResponse().ok());
// }
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_search_FLAT_big_data_size(MilvusClient client, String tableName) throws InterruptedException {
......@@ -315,7 +310,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe_new).withTopK(top_k).build();
SearchResponse res_search = client.search(searchParam);
assert (!res_search.getResponse().ok());
......@@ -335,7 +329,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k_new).build();
SearchResponse res_search = client.search(searchParam);
assert (!res_search.getResponse().ok());
......@@ -374,7 +367,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).withDateRanges(dateRange).build();
SearchResponse res_search = client.search(searchParam);
assert (res_search.getResponse().ok());
......@@ -416,7 +408,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).withDateRanges(dateRange).build();
SearchResponse res_search = client.search(searchParam);
assert (res_search.getResponse().ok());
......@@ -456,7 +447,6 @@ public class TestSearchVectors {
.build();
CreateIndexParam createIndexParam = new CreateIndexParam.Builder(tableName).withIndex(index).build();
client.createIndex(createIndexParam);
TableParam tableParam = new TableParam.Builder(tableName).build();
SearchParam searchParam = new SearchParam.Builder(tableName, queryVectors).withNProbe(n_probe).withTopK(top_k).withDateRanges(dateRange).build();
SearchResponse res_search = client.search(searchParam);
assert (!res_search.getResponse().ok());
......
......@@ -17,8 +17,7 @@ public class TestTable {
.withIndexFileSize(index_file_size)
.withMetricType(MetricType.L2)
.build();
TableSchemaParam tableSchemaParam = new TableSchemaParam.Builder(tableSchema).build();
Response res = client.createTable(tableSchemaParam);
Response res = client.createTable(tableSchema);
assert(res.ok());
Assert.assertEquals(res.ok(), true);
}
......@@ -29,8 +28,7 @@ public class TestTable {
.withIndexFileSize(index_file_size)
.withMetricType(MetricType.L2)
.build();
TableSchemaParam tableSchemaParam = new TableSchemaParam.Builder(tableSchema).build();
Response res = client.createTable(tableSchemaParam);
Response res = client.createTable(tableSchema);
assert(!res.ok());
}
......@@ -40,10 +38,9 @@ public class TestTable {
.withIndexFileSize(index_file_size)
.withMetricType(MetricType.L2)
.build();
TableSchemaParam tableSchemaParam = new TableSchemaParam.Builder(tableSchema).build();
Response res = client.createTable(tableSchemaParam);
Response res = client.createTable(tableSchema);
Assert.assertEquals(res.ok(), true);
Response res_new = client.createTable(tableSchemaParam);
Response res_new = client.createTable(tableSchema);
Assert.assertEquals(res_new.ok(), false);
}
......@@ -54,8 +51,7 @@ public class TestTable {
.withIndexFileSize(index_file_size)
.withMetricType(MetricType.L2)
.build();
TableSchemaParam tableSchemaParam = new TableSchemaParam.Builder(tableSchema).build();
Response res = client.createTable(tableSchemaParam);
Response res = client.createTable(tableSchema);
System.out.println(res.toString());
Assert.assertEquals(res.ok(), false);
}
......@@ -70,8 +66,7 @@ public class TestTable {
.withIndexFileSize(index_file_size)
.withMetricType(MetricType.L2)
.build();
TableSchemaParam tableSchemaParam = new TableSchemaParam.Builder(tableSchema).build();
client.createTable(tableSchemaParam);
client.createTable(tableSchema);
List<String> tableNames = client.showTables().getTableNames();
Assert.assertTrue(tableNames.contains(tableNameNew));
}
......@@ -85,8 +80,7 @@ public class TestTable {
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_drop_table(MilvusClient client, String tableName) throws InterruptedException {
TableParam tableParam = new TableParam.Builder(tableName).build();
Response res = client.dropTable(tableParam);
Response res = client.dropTable(tableName);
assert(res.ok());
Thread.currentThread().sleep(1000);
List<String> tableNames = client.showTables().getTableNames();
......@@ -95,8 +89,7 @@ public class TestTable {
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_drop_table_not_existed(MilvusClient client, String tableName) throws InterruptedException {
TableParam tableParam = new TableParam.Builder(tableName+"_").build();
Response res = client.dropTable(tableParam);
Response res = client.dropTable(tableName+"_");
assert(!res.ok());
List<String> tableNames = client.showTables().getTableNames();
Assert.assertTrue(tableNames.contains(tableName));
......@@ -104,15 +97,13 @@ public class TestTable {
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_drop_table_without_connect(MilvusClient client, String tableName) throws InterruptedException {
TableParam tableParam = new TableParam.Builder(tableName).build();
Response res = client.dropTable(tableParam);
Response res = client.dropTable(tableName);
assert(!res.ok());
}
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_describe_table(MilvusClient client, String tableName) throws InterruptedException {
TableParam tableParam = new TableParam.Builder(tableName).build();
DescribeTableResponse res = client.describeTable(tableParam);
DescribeTableResponse res = client.describeTable(tableName);
assert(res.getResponse().ok());
TableSchema tableSchema = res.getTableSchema().get();
Assert.assertEquals(tableSchema.getDimension(), dimension);
......@@ -123,30 +114,26 @@ public class TestTable {
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_describe_table_without_connect(MilvusClient client, String tableName) throws InterruptedException {
TableParam tableParam = new TableParam.Builder(tableName).build();
DescribeTableResponse res = client.describeTable(tableParam);
DescribeTableResponse res = client.describeTable(tableName);
assert(!res.getResponse().ok());
}
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_has_table_not_existed(MilvusClient client, String tableName) throws InterruptedException {
TableParam tableParam = new TableParam.Builder(tableName+"_").build();
HasTableResponse res = client.hasTable(tableParam);
HasTableResponse res = client.hasTable(tableName+"_");
assert(res.getResponse().ok());
Assert.assertFalse(res.hasTable());
}
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_has_table_without_connect(MilvusClient client, String tableName) throws InterruptedException {
TableParam tableParam = new TableParam.Builder(tableName).build();
HasTableResponse res = client.hasTable(tableParam);
HasTableResponse res = client.hasTable(tableName);
assert(!res.getResponse().ok());
}
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_has_table(MilvusClient client, String tableName) throws InterruptedException {
TableParam tableParam = new TableParam.Builder(tableName).build();
HasTableResponse res = client.hasTable(tableParam);
HasTableResponse res = client.hasTable(tableName);
assert(res.getResponse().ok());
Assert.assertTrue(res.hasTable());
}
......
......@@ -27,21 +27,18 @@ public class TestTableCount {
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_table_count_no_vectors(MilvusClient client, String tableName) {
TableParam tableParam = new TableParam.Builder(tableName).build();
Assert.assertEquals(client.getTableRowCount(tableParam).getTableRowCount(), 0);
Assert.assertEquals(client.getTableRowCount(tableName).getTableRowCount(), 0);
}
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
public void test_table_count_table_not_existed(MilvusClient client, String tableName) {
TableParam tableParam = new TableParam.Builder(tableName+"_").build();
GetTableRowCountResponse res = client.getTableRowCount(tableParam);
GetTableRowCountResponse res = client.getTableRowCount(tableName+"_");
assert(!res.getResponse().ok());
}
@Test(dataProvider = "DisConnectInstance", dataProviderClass = MainClass.class)
public void test_table_count_without_connect(MilvusClient client, String tableName) {
TableParam tableParam = new TableParam.Builder(tableName+"_").build();
GetTableRowCountResponse res = client.getTableRowCount(tableParam);
GetTableRowCountResponse res = client.getTableRowCount(tableName+"_");
assert(!res.getResponse().ok());
}
......@@ -52,9 +49,8 @@ public class TestTableCount {
// Add vectors
InsertParam insertParam = new InsertParam.Builder(tableName, vectors).build();;
client.insert(insertParam);
Thread.currentThread().sleep(1000);
TableParam tableParam = new TableParam.Builder(tableName).build();
Assert.assertEquals(client.getTableRowCount(tableParam).getTableRowCount(), nb);
Thread.currentThread().sleep(2000);
Assert.assertEquals(client.getTableRowCount(tableName).getTableRowCount(), nb);
}
@Test(dataProvider = "Table", dataProviderClass = MainClass.class)
......@@ -69,8 +65,7 @@ public class TestTableCount {
.withIndexFileSize(index_file_size)
.withMetricType(MetricType.L2)
.build();
TableSchemaParam tableSchemaParam = new TableSchemaParam.Builder(tableSchema).build();
client.createTable(tableSchemaParam);
client.createTable(tableSchema);
// Add vectors
InsertParam insertParam = new InsertParam.Builder(tableNameNew, vectors).build();
client.insert(insertParam);
......@@ -78,8 +73,7 @@ public class TestTableCount {
Thread.currentThread().sleep(1000);
for (int i = 0; i < tableNum; ++i) {
String tableNameNew = tableName + "_" + Integer.toString(i);
TableParam tableParam = new TableParam.Builder(tableNameNew).build();
res = client.getTableRowCount(tableParam);
res = client.getTableRowCount(tableNameNew);
Assert.assertEquals(res.getTableRowCount(), nb);
}
}
......
# Requirements
- python 3.6+
- pip install -r requirements.txt
# How to use this Test Project
This project is used to test search accuracy based on the given datasets (https://github.com/erikbern/ann-benchmarks#data-sets)
1. start your milvus server
2. update your test configuration in test.py
3. run command
```shell
python test.py
```
# Contribution getting started
- Follow PEP-8 for naming and black for formatting.
numpy==1.16.3
pymilvus>=0.2.0
scikit-learn==0.19.1
h5py==2.7.1
# Quick start
# Requirements
## 运行
- python 3.6+
- pip install -r requirements.txt
### 运行示例:
# How to use this Test Project
`python3 main.py --image=registry.zilliz.com/milvus/engine:branch-0.3.1-release --run-count=2 --run-type=performance`
This project is used to test performance / accuracy / stability of milvus server
### 运行参数:
1. update your test configuration in suites_*.yaml
2. run command
--image: 容器模式,传入镜像名称,如传入,则运行测试时,会先进行pull image,基于image生成milvus server容器
```shell
### docker mode:
python main.py --image=milvusdb/milvus:latest --run-count=2 --run-type=performance
--local: 与image参数互斥,本地模式,连接使用本地启动的milvus server进行测试
### local mode:
python main.py --local --run-count=2 --run-type=performance --ip=127.0.0.1 --port=19530
```
--run-count: 重复运行次数
# Contribution getting started
--suites: 测试集配置文件,默认使用suites.yaml
--run-type: 测试类型,包括性能--performance、准确性测试--accuracy以及稳定性--stability
### 测试集配置文件:
`operations:
insert:
​ [
​ {"table.index_type": "ivf_flat", "server.index_building_threshold": 300, "table.size": 2000000, "table.ni": 100000, "table.dim": 512},
​ ]
build: []
query:
​ [
​ {"dataset": "ip_ivfsq8_1000", "top_ks": [10], "nqs": [10, 100], "server.nprobe": 1, "server.use_blas_threshold": 800},
​ {"dataset": "ip_ivfsq8_1000", "top_ks": [10], "nqs": [10, 100], "server.nprobe": 10, "server.use_blas_threshold": 20},
​ ]`
## 测试结果:
性能:
`INFO:milvus_benchmark.runner:Start warm query, query params: top-k: 1, nq: 1
INFO:milvus_benchmark.client:query run in 19.19s
INFO:milvus_benchmark.runner:Start query, query params: top-k: 64, nq: 10, actually length of vectors: 10
INFO:milvus_benchmark.runner:Start run query, run 1 of 1
INFO:milvus_benchmark.client:query run in 0.2s
INFO:milvus_benchmark.runner:Avarage query time: 0.20
INFO:milvus_benchmark.runner:[[0.2]]`
**│ 10 │ 0.2 │**
准确率:
`INFO:milvus_benchmark.runner:Avarage accuracy: 1.0`
\ No newline at end of file
- Follow PEP-8 for naming and black for formatting.
\ No newline at end of file
# Requirements
* python 3.6.8
* python 3.6.8+
* pip install -r requirements.txt
# How to use this Test Project
```shell
pytest . -q -v
```
pytest . --level=1
```
or test connect function only
```shell
pytest test_connect.py --level=1
```
with allure test report
```shell
pytest --alluredir=test_out . -q -v
allure serve test_out
```
# Contribution getting started
* Follow PEP-8 for naming and black for formatting.
\ No newline at end of file
* Follow PEP-8 for naming and black for formatting.
* GLOBAL:
FORMAT = "%datetime | %level | %logger | %msg"
FILENAME = "/opt/milvus/logs/milvus-%datetime{%H:%m}-global.log"
ENABLED = true
TO_FILE = true
TO_STANDARD_OUTPUT = false
SUBSECOND_PRECISION = 3
PERFORMANCE_TRACKING = false
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 200MB
* DEBUG:
FILENAME = "/opt/milvus/logs/milvus-%datetime{%H:%m}-debug.log"
ENABLED = true
* WARNING:
FILENAME = "/opt/milvus/logs/milvus-%datetime{%H:%m}-warning.log"
* TRACE:
FILENAME = "/opt/milvus/logs/milvus-%datetime{%H:%m}-trace.log"
* VERBOSE:
FORMAT = "%datetime{%d/%M/%y} | %level-%vlevel | %msg"
TO_FILE = false
TO_STANDARD_OUTPUT = false
## Error logs
* ERROR:
ENABLED = true
FILENAME = "/opt/milvus/logs/milvus-%datetime{%H:%m}-error.log"
* FATAL:
ENABLED = true
FILENAME = "/opt/milvus/logs/milvus-%datetime{%H:%m}-fatal.log"
server_config:
address: 0.0.0.0
port: 19530
deploy_mode: single
time_zone: UTC+8
db_config:
primary_path: /opt/milvus
secondary_path:
backend_url: sqlite://:@:/
insert_buffer_size: 4
build_index_gpu: 0
preload_table:
metric_config:
enable_monitor: true
collector: prometheus
prometheus_config:
port: 8080
cache_config:
cpu_cache_capacity: 8
cpu_cache_threshold: 0.85
cache_insert_data: false
engine_config:
use_blas_threshold: 20
resource_config:
resource_pool:
- cpu
- gpu0
......@@ -12,6 +12,7 @@ index_file_size = 10
def pytest_addoption(parser):
parser.addoption("--ip", action="store", default="localhost")
parser.addoption("--port", action="store", default=19530)
parser.addoption("--internal", action="store", default=False)
def check_server_connection(request):
......@@ -76,7 +77,10 @@ def dis_connect(request):
def args(request):
ip = request.config.getoption("--ip")
port = request.config.getoption("--port")
internal = request.config.getoption("--internal")
args = {"ip": ip, "port": port}
if internal:
args = {"ip": ip, "port": port, "internal": internal}
return args
......
......@@ -108,8 +108,11 @@ class TestDeleteVectorsBase:
scope="function",
params=gen_index_params()
)
def get_index_params(self, request):
yield request.param
def get_index_params(self, request, args):
if "internal" not in args:
if request.param["index_type"] == IndexType.IVF_SQ8H:
pytest.skip("sq8h not support in open source")
return request.param
@pytest.mark.timeout(DELETE_TIMEOUT)
def test_delete_vectors_valid_range_index_created(self, connect, table, get_index_params):
......@@ -291,8 +294,11 @@ class TestDeleteVectorsIP:
scope="function",
params=gen_index_params()
)
def get_index_params(self, request):
yield request.param
def get_index_params(self, request, args):
if "internal" not in args:
if request.param["index_type"] == IndexType.IVF_SQ8H:
pytest.skip("sq8h not support in open source")
return request.param
@pytest.mark.timeout(DELETE_TIMEOUT)
def test_delete_vectors_valid_range_index_created(self, connect, ip_table, get_index_params):
......
......@@ -26,8 +26,11 @@ class TestIndexBase:
scope="function",
params=gen_index_params()
)
def get_index_params(self, request):
yield request.param
def get_index_params(self, request, args):
if "internal" not in args:
if request.param["index_type"] == IndexType.IVF_SQ8H:
pytest.skip("sq8h not support in open source")
return request.param
@pytest.fixture(
scope="function",
......@@ -501,8 +504,11 @@ class TestIndexIP:
scope="function",
params=gen_index_params()
)
def get_index_params(self, request):
yield request.param
def get_index_params(self, request, args):
if "internal" not in args:
if request.param["index_type"] == IndexType.IVF_SQ8H:
pytest.skip("sq8h not support in open source")
return request.param
@pytest.fixture(
scope="function",
......
......@@ -43,8 +43,11 @@ class TestSearchBase:
scope="function",
params=gen_index_params()
)
def get_index_params(self, request):
yield request.param
def get_index_params(self, request, args):
if "internal" not in args:
if request.param["index_type"] == IndexType.IVF_SQ8H:
pytest.skip("sq8h not support in open source")
return request.param
"""
generate top-k params
......
......@@ -590,8 +590,11 @@ class TestTable:
scope="function",
params=gen_index_params()
)
def get_index_params(self, request):
yield request.param
def get_index_params(self, request, args):
if "internal" not in args:
if request.param["index_type"] == IndexType.IVF_SQ8H:
pytest.skip("sq8h not support in open source")
return request.param
@pytest.mark.level(1)
def test_preload_table(self, connect, table, get_index_params):
......
......@@ -38,8 +38,11 @@ class TestTableCount:
scope="function",
params=gen_index_params()
)
def get_index_params(self, request):
yield request.param
def get_index_params(self, request, args):
if "internal" not in args:
if request.param["index_type"] == IndexType.IVF_SQ8H:
pytest.skip("sq8h not support in open source")
return request.param
def test_table_rows_count(self, connect, table, add_vectors_nb):
'''
......@@ -179,8 +182,11 @@ class TestTableCountIP:
scope="function",
params=gen_index_params()
)
def get_index_params(self, request):
yield request.param
def get_index_params(self, request, args):
if "internal" not in args:
if request.param["index_type"] == IndexType.IVF_SQ8H:
pytest.skip("sq8h not support in open source")
return request.param
def test_table_rows_count(self, connect, ip_table, add_vectors_nb):
'''
......
......@@ -461,6 +461,7 @@ def gen_simple_index_params():
return gen_params(index_types, nlists)
if __name__ == "__main__":
import numpy
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册