Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into builder_suspend
Browse files Browse the repository at this point in the history
  • Loading branch information
shengjun.li committed May 11, 2020
2 parents 6826f1f + 0ee3c63 commit b6d2227
Show file tree
Hide file tree
Showing 97 changed files with 2,600 additions and 3,799 deletions.
18 changes: 18 additions & 0 deletions tests/milvus-java-test/src/main/java/com/TestSearchByIds.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class TestSearchByIds {
int n_list = 1024;
int default_n_list = 16384;
int nb = 10000;
int small_nb = 10;
int n_probe = 20;
int top_k = 10;
int nq = 5;
Expand All @@ -22,6 +23,7 @@ public class TestSearchByIds {
IndexType defaultIndexType = IndexType.FLAT;
List<Long> default_ids = Utils.toListIds(1111);
List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
List<List<Float>> small_vectors = Utils.genVectors(small_nb, dimension, true);
List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
String indexParam = Utils.setIndexParam(n_list);
public String searchParamStr = Utils.setSearchParam(n_probe);
Expand Down Expand Up @@ -62,6 +64,22 @@ public void test_search_no_result(MilvusClient client, String collectionName) {
List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
assert (client.searchByIds(searchParam).getResponse().ok());
Assert.assertEquals(res_search.get(0).size(), 0);
}

@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_count_lt_top_k(MilvusClient client, String collectionName) {
int top_k = 100;
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(small_vectors).build();
InsertResponse res_insert = client.insert(insertParam);
client.flush(collectionName);
SearchByIdsParam searchParam = new SearchByIdsParam.Builder(collectionName)
.withParamsInJson(searchParamStr)
.withTopK(top_k)
.withIDs(Utils.toListIds(res_insert.getVectorIds().get(0)))
.build();
List<List<SearchResponse.QueryResult>> res_search = client.searchByIds(searchParam).getQueryResultsList();
// reason: "Failed to query by id in collection L2_FmVKbqSZaN, result doesn\'t match id count"
assert (!client.searchByIds(searchParam).getResponse().ok());
// Assert.assertEquals(res_search.size(), default_ids.size());
// Assert.assertEquals(res_search.get(0).get(0).getVectorId(), -1);
}
Expand Down
17 changes: 17 additions & 0 deletions tests/milvus-java-test/src/main/java/com/TestSearchVectors.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ public class TestSearchVectors {
int n_list = 1024;
int default_n_list = 16384;
int nb = 10000;
int small_nb = 10;
int n_probe = 20;
int top_k = 10;
int nq = 5;
double epsilon = 0.001;
IndexType indexType = IndexType.IVF_SQ8;
IndexType defaultIndexType = IndexType.FLAT;
List<List<Float>> vectors = Utils.genVectors(nb, dimension, true);
List<List<Float>> small_vectors = Utils.genVectors(small_nb, dimension, true);
List<ByteBuffer> vectorsBinary = Utils.genBinaryVectors(nb, dimension);
List<List<Float>> queryVectors = vectors.subList(0, nq);
List<ByteBuffer> queryVectorsBinary = vectorsBinary.subList(0, nq);
Expand Down Expand Up @@ -190,6 +192,21 @@ public void test_search_invalid_n_probe(MilvusClient client, String collectionNa
assert (!res_search.getResponse().ok());
}

@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_count_lt_top_k(MilvusClient client, String collectionName) {
int top_k_new = 100;
InsertParam insertParam = new InsertParam.Builder(collectionName).withFloatVectors(small_vectors).build();
client.insert(insertParam);
client.flush(collectionName);
SearchParam searchParam = new SearchParam.Builder(collectionName)
.withFloatVectors(queryVectors)
.withParamsInJson(searchParamStr)
.withTopK(top_k_new).build();
List<List<SearchResponse.QueryResult>> res_search = client.search(searchParam).getQueryResultsList();
Assert.assertEquals(res_search.size(), nq);
Assert.assertEquals(res_search.get(0).size(), small_vectors.size());
}

@Test(dataProvider = "Collection", dataProviderClass = MainClass.class)
public void test_search_invalid_top_k(MilvusClient client, String collectionName) {
int top_k_new = 0;
Expand Down
4 changes: 3 additions & 1 deletion tests/milvus_benchmark/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ logs/
*idmap*.txt
__pycache__/
venv
.idea
.idea

suites/
11 changes: 6 additions & 5 deletions tests/milvus_benchmark/ci/jenkinsfile/deploy_test.groovy
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
timeout(time: 1440, unit: 'MINUTES') {
timeout(time: 4000, unit: 'MINUTES') {
try {
dir ("milvus-helm") {
sh 'helm init --client-only --skip-refresh --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts'
sh 'helm repo update'
// sh 'helm init --client-only --skip-refresh --stable-repo-url https://kubernetes.oss-cn-hangzhou.aliyuncs.com/charts'
// sh 'helm repo update'
checkout([$class: 'GitSCM', branches: [[name: "${HELM_BRANCH}"]], userRemoteConfigs: [[url: "${HELM_URL}", name: 'origin', refspec: "+refs/heads/${HELM_BRANCH}:refs/remotes/origin/${HELM_BRANCH}"]]])
}
dir ("milvus_benchmark") {
print "Git clone url: ${TEST_URL}:${TEST_BRANCH}"
checkout([$class: 'GitSCM', branches: [[name: "${TEST_BRANCH}"]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_USER}", url: "${TEST_URL}", name: 'origin', refspec: "+refs/heads/${TEST_BRANCH}:refs/remotes/origin/${TEST_BRANCH}"]]])
print "Install requirements"
sh "python3 -m pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com"
// sh "python3 -m pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com"
sh "python3 -m pip install -r requirements.txt"
sh "python3 -m pip install git+${TEST_LIB_URL}"
sh "python3 main.py --hostname=${params.SERVER_HOST} --image-tag=${IMAGE_TAG} --image-type=${params.IMAGE_TYPE} --suite=suites/${params.SUITE}"
sh "python3 main.py --image-version=${params.IMAGE_VERSION} --schedule-conf=scheduler/${params.CONFIG_FILE}"
}
} catch (exc) {
echo 'Deploy Test Failed !'
Expand Down
46 changes: 46 additions & 0 deletions tests/milvus_benchmark/ci/jenkinsfile/publishDailyImages.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
timeout(time: 15, unit: 'MINUTES') {
def imageName = "milvus/engine:${DOCKER_VERSION}"
def remoteImageName = "milvusdb/daily-build:${REMOTE_DOCKER_VERSION}"
def localDockerRegistryImage = "${params.LOCAL_DOKCER_REGISTRY_URL}/${imageName}"
def remoteDockerRegistryImage = "${params.REMOTE_DOKCER_REGISTRY_URL}/${remoteImageName}"
try {
deleteImages("${localDockerRegistryImage}", true)

def pullSourceImageStatus = sh(returnStatus: true, script: "docker pull ${localDockerRegistryImage}")

if (pullSourceImageStatus == 0) {
def renameImageStatus = sh(returnStatus: true, script: "docker tag ${localDockerRegistryImage} ${remoteImageName} && docker rmi ${localDockerRegistryImage}")
def sourceImage = docker.image("${remoteImageName}")
docker.withRegistry("https://${params.REMOTE_DOKCER_REGISTRY_URL}", "${params.REMOTE_DOCKER_CREDENTIALS_ID}") {
sourceImage.push()
sourceImage.push("${REMOTE_DOCKER_LATEST_VERSION}")
}
} else {
echo "\"${localDockerRegistryImage}\" image does not exist !"
}
} catch (exc) {
throw exc
} finally {
deleteImages("${localDockerRegistryImage}", true)
deleteImages("${remoteDockerRegistryImage}", true)
}
}

boolean deleteImages(String imageName, boolean force) {
def imageNameStr = imageName.trim()
def isExistImage = sh(returnStatus: true, script: "docker inspect --type=image ${imageNameStr} 2>&1 > /dev/null")
if (isExistImage == 0) {
def deleteImageStatus = 0
if (force) {
def imageID = sh(returnStdout: true, script: "docker inspect --type=image --format \"{{.ID}}\" ${imageNameStr}")
deleteImageStatus = sh(returnStatus: true, script: "docker rmi -f ${imageID}")
} else {
deleteImageStatus = sh(returnStatus: true, script: "docker rmi ${imageNameStr}")
}

if (deleteImageStatus != 0) {
return false
}
}
return true
}
39 changes: 29 additions & 10 deletions tests/milvus_benchmark/ci/main_jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ pipeline {
}

parameters{
choice choices: ['gpu', 'cpu'], description: 'cpu or gpu version', name: 'IMAGE_TYPE'
string defaultValue: 'master', description: 'server image version', name: 'IMAGE_VERSION', trim: true
choice choices: ['poseidon', 'eros', 'apollo', 'athena'], description: 'server host', name: 'SERVER_HOST'
string defaultValue: 'gpu_search_performance_sift1m.yaml', description: 'test suite config yaml', name: 'SUITE', trim: true
string defaultValue: '080_data.json', description: 'test suite config yaml', name: 'CONFIG_FILE', trim: true
string defaultValue: '09509e53-9125-4f5d-9ce8-42855987ad67', description: 'git credentials', name: 'GIT_USER', trim: true
}

environment {
IMAGE_TAG = "${params.IMAGE_VERSION}-${params.IMAGE_TYPE}-ubuntu18.04-release"
HELM_URL = "https://github.com/milvus-io/milvus-helm.git"
HELM_BRANCH = "0.6.0"
HELM_BRANCH = "master"
TEST_URL = "git@192.168.1.105:Test/milvus_benchmark.git"
TEST_BRANCH = "master"
TEST_LIB_URL = "http://192.168.1.105:6060/Test/milvus_metrics.git"
Expand All @@ -37,8 +34,8 @@ pipeline {
componet: test
spec:
containers:
- name: milvus-testframework
image: registry.zilliz.com/milvus/milvus-test:v0.2
- name: milvus-test-env
image: registry.zilliz.com/milvus/milvus-test-env:v0.2
command:
- cat
tty: true
Expand Down Expand Up @@ -79,10 +76,25 @@ pipeline {
}

stages {
stage("Publish Daily Docker images") {
steps {
container('milvus-test-env') {
script {
boolean isNightlyTest = isTimeTriggeredBuild()
if (isNightlyTest) {
build job: 'milvus-publish-daily-docker', wait: false
} else {
echo "Skip publish daily docker images ..."
}
}
}
}
}

stage("Deploy Test") {
steps {
gitlabCommitStatus(name: 'Deploy Test') {
container('milvus-testframework') {
container('milvus-test-env') {
script {
print "In Deploy Test Stage"
load "${env.WORKSPACE}/ci/jenkinsfile/deploy_test.groovy"
Expand All @@ -95,7 +107,7 @@ pipeline {
stage ("Cleanup Env") {
steps {
gitlabCommitStatus(name: 'Cleanup Env') {
container('milvus-testframework') {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkinsfile/cleanup.groovy"
}
Expand All @@ -106,7 +118,7 @@ pipeline {
}
post {
always {
container('milvus-testframework') {
container('milvus-test-env') {
script {
load "${env.WORKSPACE}/ci/jenkinsfile/cleanup.groovy"
}
Expand All @@ -131,3 +143,10 @@ pipeline {
}
}
}

boolean isTimeTriggeredBuild() {
if (currentBuild.getBuildCauses('hudson.triggers.TimerTrigger$TimerTriggerCause').size() != 0) {
return true
}
return false
}
103 changes: 103 additions & 0 deletions tests/milvus_benchmark/ci/publish_jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
pipeline {
agent none

options {
timestamps()
}

parameters{
string defaultValue: 'registry.zilliz.com', description: 'Local Docker registry URL', name: 'LOCAL_DOKCER_REGISTRY_URL', trim: true
string defaultValue: 'registry-1.docker.io', description: 'Remote Docker registry URL', name: 'REMOTE_DOKCER_REGISTRY_URL', trim: true
string defaultValue: 'milvus-docker-access-token', description: 'Remote Docker credentials id', name: 'REMOTE_DOCKER_CREDENTIALS_ID', trim: true
}

environment {
DAILY_BUILD_VERSION = VersionNumber([
versionNumberString : '${BUILD_DATE_FORMATTED, "yyyyMMdd"}'
]);
}

stages {
stage('Push Daily Docker Images') {
matrix {
agent none
axes {
axis {
name 'OS_NAME'
values 'ubuntu18.04', 'centos7'
}

axis {
name 'CPU_ARCH'
values 'amd64'
}

axis {
name 'BINARY_VERSION'
values 'gpu', 'cpu'
}
}

stages {
stage("Publish Docker Images") {
environment {
DOCKER_VERSION = "master-${BINARY_VERSION}-${OS_NAME}-release"
REMOTE_DOCKER_VERSION = "${OS_NAME}-${BINARY_VERSION}-${DAILY_BUILD_VERSION}"
REMOTE_DOCKER_LATEST_VERSION = "${OS_NAME}-${BINARY_VERSION}-latest"
}

agent {
kubernetes {
label "${OS_NAME}-${BINARY_VERSION}-publish-${env.BUILD_NUMBER}"
defaultContainer 'jnlp'
yaml """
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
resources:
limits:
memory: "4Gi"
cpu: "1.0"
requests:
memory: "2Gi"
cpu: "0.5"
volumeMounts:
- name: docker-sock
mountPath: /var/run/docker.sock
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
"""
}
}

stages {
stage('Publish') {
steps {
container('publish-images') {
script {
load "${env.WORKSPACE}/ci/jenkinsfile/publishDailyImages.groovy"
}
}
}
}
}
}
}
}
}
}
}
Loading

0 comments on commit b6d2227

Please sign in to comment.