|
| 1 | +#!/usr/bin/env groovy |
| 2 | + |
| 3 | +int total_timeout_minutes = 60 * 5 |
| 4 | +int e2e_timeout_seconds = 120 * 60 |
| 5 | +def imageTag = '123' |
| 6 | +int case_timeout_seconds = 20 * 60 |
| 7 | +def chart_version = '4.1.8' |
| 8 | +def release_name = '' |
| 9 | +pipeline { |
| 10 | + options { |
| 11 | + timestamps() |
| 12 | + timeout(time: total_timeout_minutes, unit: 'MINUTES') |
| 13 | + buildDiscarder logRotator(artifactDaysToKeepStr: '30') |
| 14 | + parallelsAlwaysFailFast() |
| 15 | + preserveStashes(buildCount: 5) |
| 16 | + disableConcurrentBuilds(abortPrevious: true) |
| 17 | + } |
| 18 | + agent { |
| 19 | + kubernetes { |
| 20 | + cloud '4am' |
| 21 | + inheritFrom 'milvus-e2e-4am' |
| 22 | + defaultContainer 'main' |
| 23 | + yamlFile 'ci/jenkins/pod/rte-build.yaml' |
| 24 | + customWorkspace '/home/jenkins/agent/milvus' |
| 25 | + } |
| 26 | + } |
| 27 | + environment { |
| 28 | + PROJECT_NAME = 'milvus' |
| 29 | + SEMVER = "${BRANCH_NAME.contains('/') ? BRANCH_NAME.substring(BRANCH_NAME.lastIndexOf('/') + 1) : BRANCH_NAME}" |
| 30 | + DOCKER_BUILDKIT = 1 |
| 31 | + ARTIFACTS = "${env.WORKSPACE}/_artifacts" |
| 32 | + CI_DOCKER_CREDENTIAL_ID = 'harbor-milvus-io-registry' |
| 33 | + MILVUS_HELM_NAMESPACE = 'milvus-ci' |
| 34 | + DISABLE_KIND = true |
| 35 | + HUB = 'harbor.milvus.io/milvus' |
| 36 | + JENKINS_BUILD_ID = "${env.BUILD_ID}" |
| 37 | + CI_MODE = 'pr' |
| 38 | + SHOW_MILVUS_CONFIGMAP = true |
| 39 | + } |
| 40 | + |
| 41 | + stages { |
| 42 | + stage('Build') { |
| 43 | + steps { |
| 44 | + container('main') { |
| 45 | + dir('build') { |
| 46 | + sh ''' |
| 47 | + MIRROR_URL="https://docker-nexus-ci.zilliz.cc" ./set_docker_mirror.sh |
| 48 | + ''' |
| 49 | + } |
| 50 | + dir('tests/scripts') { |
| 51 | + script { |
| 52 | + sh 'printenv' |
| 53 | + def date = sh(returnStdout: true, script: 'date +%Y%m%d').trim() |
| 54 | + sh 'git config --global --add safe.directory /home/jenkins/agent/workspace' |
| 55 | + def gitShortCommit = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim() |
| 56 | + imageTag = "${env.BRANCH_NAME}-${date}-${gitShortCommit}" |
| 57 | + withCredentials([usernamePassword(credentialsId: "${env.CI_DOCKER_CREDENTIAL_ID}", usernameVariable: 'CI_REGISTRY_USERNAME', passwordVariable: 'CI_REGISTRY_PASSWORD')]) { |
| 58 | + sh """ |
| 59 | + TAG="${imageTag}" \ |
| 60 | + ./e2e-k8s.sh \ |
| 61 | + --skip-export-logs \ |
| 62 | + --skip-install \ |
| 63 | + --skip-cleanup \ |
| 64 | + --skip-setup \ |
| 65 | + --skip-test |
| 66 | + """ |
| 67 | + |
| 68 | + // stash imageTag info for rebuild install & E2E Test only |
| 69 | + sh "echo ${imageTag} > imageTag.txt" |
| 70 | + stash includes: 'imageTag.txt', name: 'imageTag' |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + } |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + stage('Install & E2E Test') { |
| 79 | + matrix { |
| 80 | + axes { |
| 81 | + axis { |
| 82 | + name 'MILVUS_SERVER_TYPE' |
| 83 | + values 'standalone', 'distributed' |
| 84 | + } |
| 85 | + axis { |
| 86 | + name 'MILVUS_CLIENT' |
| 87 | + values 'milvus-sdk-go' |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + stages { |
| 92 | + stage('Install') { |
| 93 | + steps { |
| 94 | + container('main') { |
| 95 | + stash includes: 'tests/**', name: 'testCode', useDefaultExcludes: false |
| 96 | + stash includes: 'client/**', name: 'clientCode', useDefaultExcludes: false |
| 97 | + dir('tests/scripts') { |
| 98 | + script { |
| 99 | + sh 'printenv' |
| 100 | + def clusterEnabled = 'false' |
| 101 | + def valuesFile = 'pr-4am.yaml' |
| 102 | + if ("${MILVUS_SERVER_TYPE}".contains('distributed')) { |
| 103 | + clusterEnabled = 'true' |
| 104 | + } |
| 105 | + if ("${imageTag}" == '') { |
| 106 | + dir('imageTag') { |
| 107 | + try { |
| 108 | + unstash 'imageTag' |
| 109 | + imageTag = sh(returnStdout: true, script: 'cat imageTag.txt | tr -d \'\n\r\'') |
| 110 | + }catch (e) { |
| 111 | + print 'No Image Tag info remained ,please rerun build to build new image.' |
| 112 | + exit 1 |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | + // modify values file to enable kafka |
| 117 | + if ("${MILVUS_SERVER_TYPE}".contains('kafka')) { |
| 118 | + sh ''' |
| 119 | + apt-get update |
| 120 | + apt-get install wget -y |
| 121 | + wget https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64 -O /usr/bin/yq |
| 122 | + chmod +x /usr/bin/yq |
| 123 | + ''' |
| 124 | + sh """ |
| 125 | + cp values/ci/pr-4am.yaml values/ci/pr_kafka.yaml |
| 126 | + yq -i '.pulsar.enabled=false' values/ci/pr_kafka.yaml |
| 127 | + yq -i '.kafka.enabled=true' values/ci/pr_kafka.yaml |
| 128 | + yq -i '.kafka.metrics.kafka.enabled=true' values/ci/pr_kafka.yaml |
| 129 | + yq -i '.kafka.metrics.jmx.enabled=true' values/ci/pr_kafka.yaml |
| 130 | + yq -i '.kafka.metrics.serviceMonitor.enabled=true' values/ci/pr_kafka.yaml |
| 131 | + """ |
| 132 | + } |
| 133 | + withCredentials([usernamePassword(credentialsId: "${env.CI_DOCKER_CREDENTIAL_ID}", usernameVariable: 'CI_REGISTRY_USERNAME', passwordVariable: 'CI_REGISTRY_PASSWORD')]) { |
| 134 | + sh """ |
| 135 | + MILVUS_CLUSTER_ENABLED=${clusterEnabled} \ |
| 136 | + MILVUS_HELM_REPO="https://nexus-ci.zilliz.cc/repository/milvus-proxy" \ |
| 137 | + TAG=${imageTag}\ |
| 138 | + ./e2e-k8s.sh \ |
| 139 | + --skip-export-logs \ |
| 140 | + --skip-cleanup \ |
| 141 | + --skip-setup \ |
| 142 | + --skip-test \ |
| 143 | + --skip-build \ |
| 144 | + --skip-build-image \ |
| 145 | + --install-extra-arg " |
| 146 | + --set etcd.metrics.enabled=true \ |
| 147 | + --set etcd.metrics.podMonitor.enabled=true \ |
| 148 | + --set indexCoordinator.gc.interval=1 \ |
| 149 | + --set indexNode.disk.enabled=true \ |
| 150 | + --set queryNode.disk.enabled=true \ |
| 151 | + --set standalone.disk.enabled=true \ |
| 152 | + --version ${chart_version} \ |
| 153 | + -f values/ci/${valuesFile}" |
| 154 | + """ |
| 155 | + } |
| 156 | + |
| 157 | + release_name = sh(returnStdout: true, script: './get_release_name.sh').trim() |
| 158 | + } |
| 159 | + } |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | + stage('E2E Test') { |
| 164 | + options { |
| 165 | + skipDefaultCheckout() |
| 166 | + } |
| 167 | + agent { |
| 168 | + kubernetes { |
| 169 | + cloud '4am' |
| 170 | + inheritFrom 'default' |
| 171 | + defaultContainer 'main' |
| 172 | + yamlFile 'ci/jenkins/pod/e2e-go-sdk.yaml' |
| 173 | + customWorkspace '/home/jenkins/agent/milvus' |
| 174 | + } |
| 175 | + } |
| 176 | + steps { |
| 177 | + container('gotestsum') { |
| 178 | + unstash('testCode') |
| 179 | + unstash('clientCode') |
| 180 | + dir('tests/scripts') { |
| 181 | + script { |
| 182 | + def clusterEnabled = 'false' |
| 183 | + if ("${MILVUS_SERVER_TYPE}".contains('distributed')) { |
| 184 | + clusterEnabled = 'true' |
| 185 | + } |
| 186 | + } |
| 187 | + } |
| 188 | + |
| 189 | + dir('tests/go_client') { |
| 190 | + |
| 191 | + script { |
| 192 | + sh """ |
| 193 | + gotestsum --format testname --hide-summary=output ./testcases/... --tags L0 --addr=${release_name}-milvus.milvus-ci:19530 -timeout=60m |
| 194 | + """ |
| 195 | + |
| 196 | + } |
| 197 | + |
| 198 | + } |
| 199 | + } |
| 200 | + } |
| 201 | + } |
| 202 | + } |
| 203 | + post { |
| 204 | + always { |
| 205 | + container('main') { |
| 206 | + dir('tests/scripts') { |
| 207 | + script { |
| 208 | + sh "kubectl get pods -n ${MILVUS_HELM_NAMESPACE} | grep ${release_name} " |
| 209 | + sh "./uninstall_milvus.sh --release-name ${release_name}" |
| 210 | + sh "./ci_logs.sh --log-dir /ci-logs --artifacts-name ${env.ARTIFACTS}/artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${SEMVER}-${env.BUILD_NUMBER}-${MILVUS_CLIENT}-e2e-logs \ |
| 211 | + --release-name ${release_name}" |
| 212 | + dir("${env.ARTIFACTS}") { |
| 213 | + archiveArtifacts artifacts: "artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${SEMVER}-${env.BUILD_NUMBER}-${MILVUS_CLIENT}-e2e-logs.tar.gz", allowEmptyArchive: true |
| 214 | + } |
| 215 | + } |
| 216 | + } |
| 217 | + } |
| 218 | + } |
| 219 | + } |
| 220 | + } |
| 221 | + } |
| 222 | + } |
| 223 | + post { |
| 224 | + unsuccessful { |
| 225 | + container('jnlp') { |
| 226 | + dir('tests/scripts') { |
| 227 | + script { |
| 228 | + def authorEmail = sh(returnStdout: true, script: './get_author_email.sh ') |
| 229 | + emailext subject: '$DEFAULT_SUBJECT', |
| 230 | + body: '$DEFAULT_CONTENT', |
| 231 | + recipientProviders: [developers(), culprits()], |
| 232 | + replyTo: '$DEFAULT_REPLYTO', |
| 233 | + to: "${authorEmail},[email protected]" |
| 234 | + } |
| 235 | + } |
| 236 | + } |
| 237 | + } |
| 238 | + } |
| 239 | +} |
0 commit comments