NightlyCI.groovy 8.4 KB
Newer Older
1 2
#!/usr/bin/env groovy

3 4
// When scheduling a job that gets automatically triggered by changes,
// you need to include a [cronjob] tag within the commit message.
5
String cron_timezone = "TZ=Asia/Shanghai"
6
String cron_string = BRANCH_NAME == "master" ? "50 22 * * * " : ""
7

8 9
int total_timeout_minutes = 240
int e2e_timeout_seconds = 3 * 60 * 60
10

11 12 13
pipeline {
    agent none
    triggers {
14
        cron """${cron_timezone}
15 16 17 18
            ${cron_string}"""
    }
    options {
        timestamps()
19
        timeout(time: total_timeout_minutes, unit: 'MINUTES')
20 21 22 23 24 25 26 27 28 29 30
        buildDiscarder logRotator(artifactDaysToKeepStr: '30')
        // parallelsAlwaysFailFast()
    }
    stages {
        stage ('E2E Test') {
            matrix {
                axes {
                    axis {
                        name 'MILVUS_SERVER_TYPE'
                        values 'standalone', 'distributed'
                    }
31 32
                    axis {
                        name 'MILVUS_CLIENT'
33 34
                        values 'pymilvus'
//                         'pymilvus-orm'
35
                    }
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
                }
                agent {
                    kubernetes {
                        label "milvus-e2e-test-kind-nightly"
                        inheritFrom 'default'
                        defaultContainer 'main'
                        yamlFile "build/ci/jenkins/pod/krte.yaml"
                        customWorkspace '/home/jenkins/agent/workspace'
                    }
                }
                environment {
                    PROJECT_NAME = "milvus"
                    SEMVER = "${BRANCH_NAME.contains('/') ? BRANCH_NAME.substring(BRANCH_NAME.lastIndexOf('/') + 1) : BRANCH_NAME}"
                    IMAGE_REPO = "dockerhub-mirror-sh.zilliz.cc/milvusdb"
                    DOCKER_BUILDKIT = 1
51
                    ARTIFACTS = "${env.WORKSPACE}/_artifacts"
52 53
                    DOCKER_CREDENTIALS_ID = "f0aacc8e-33f2-458a-ba9e-2c44f431b4d2"
                    TARGET_REPO = "milvusdb"
54 55 56 57
                }
                stages {
                    stage('Test') {
                        steps {
58 59 60 61 62
                            container('etcd') {
                                script {
                                    sh 'ETCDCTL_API=3 etcdctl del "" --from-key=true'
                                }
                            }
63 64 65
                            container('main') {
                                dir ('tests/scripts') {
                                    script {
66
                                        sh 'printenv'
67
                                        def clusterEnabled = "false"
68
                                        if ("${MILVUS_SERVER_TYPE}" == "distributed") {
69
                                            clusterEnabled = "true"
70 71
                                        }

72 73 74 75 76
                                        if ("${MILVUS_CLIENT}" == "pymilvus") {
                                            sh """
                                            MILVUS_CLUSTER_ENABLED=${clusterEnabled} \
                                            ./e2e-k8s.sh \
                                            --kind-config "${env.WORKSPACE}/build/config/topology/trustworthy-jwt-ci.yaml" \
77
                                            --node-image registry.zilliz.com/kindest/node:v1.20.2 \
78
                                            --install-extra-arg "--set etcd.enabled=false --set externalEtcd.enabled=true --set externalEtcd.endpoints={\$KRTE_POD_IP:2379}" \
79 80
                                            --skip-export-logs \
                                            --skip-cleanup \
81
                                            --test-extra-arg "--tags smoke L0 L1 L2" \
82
                                            --test-timeout ${e2e_timeout_seconds}
83
                                            """
84 85 86 87 88 89 90 91 92 93 94 95
//                                         } else if ("${MILVUS_CLIENT}" == "pymilvus-orm") {
//                                             sh """
//                                             MILVUS_CLUSTER_ENABLED=${clusterEnabled} \
//                                             ./e2e-k8s.sh \
//                                             --kind-config "${env.WORKSPACE}/build/config/topology/trustworthy-jwt-ci.yaml" \
//                                             --node-image registry.zilliz.com/kindest/node:v1.20.2 \
//                                             --install-extra-arg "--set etcd.enabled=false --set externalEtcd.enabled=true --set externalEtcd.endpoints={\$KRTE_POD_IP:2379}" \
//                                             --skip-export-logs \
//                                             --skip-cleanup \
//                                             --test-extra-arg "--tags L0 L1 L2" \
//                                             --test-timeout ${e2e_timeout_seconds}
//                                             """
96 97 98
                                        } else {
                                            error "Error: Unsupported Milvus client: ${MILVUS_CLIENT}"
                                        }
99 100 101 102 103 104 105 106 107 108 109 110
                                    }
                                }
                            }
                        }
                    }
                }
                post {
                    unsuccessful {
                        container('jnlp') {
                            script {
                                emailext subject: '$DEFAULT_SUBJECT',
                                body: '$DEFAULT_CONTENT',
111
                                recipientProviders: [requestor()],
112 113 114 115 116
                                replyTo: '$DEFAULT_REPLYTO',
                                to: 'qa@zilliz.com'
                            }
                        }
                    }
117
                    success {
118 119
                        container('main') {
                            script {
120 121
                                def date = sh(returnStdout: true, script: 'date +%Y%m%d').trim()
                                def gitShortCommit = sh(returnStdout: true, script: 'git rev-parse --short HEAD').trim()
122

123
                                withCredentials([usernamePassword(credentialsId: "${env.DOCKER_CREDENTIALS_ID}", usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
124
                                    sh 'docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}'
125
                                    sh """
126 127 128 129
                                        docker tag localhost:5000/milvus:latest ${TARGET_REPO}/milvus-nightly:${env.BRANCH_NAME}-${date}-${gitShortCommit}
                                        docker tag localhost:5000/milvus:latest ${TARGET_REPO}/milvus-nightly:${env.BRANCH_NAME}-latest
                                        docker push ${TARGET_REPO}/milvus-nightly:${env.BRANCH_NAME}-${date}-${gitShortCommit}
                                        docker push ${TARGET_REPO}/milvus-nightly:${env.BRANCH_NAME}-latest
130
                                    """
131
                                    sh 'docker logout'
132
                                }
133 134 135
                            }
                        }
                    }
136
                    always {
137 138
                        container('main') {
                            script {
139 140 141 142 143 144 145 146
                                sh "./tests/scripts/export_logs.sh"
                                dir("${env.ARTIFACTS}") {
                                    sh "find ./kind -path '*/history/*' -type f | xargs tar -zcvf artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${SEMVER}-${env.BUILD_NUMBER}-e2e-nightly-logs.tar.gz --transform='s:^[^/]*/[^/]*/[^/]*/[^/]*/::g' || true"
                                    if ("${MILVUS_CLIENT}" == "pymilvus-orm") {
                                        sh "tar -zcvf artifacts-${PROJECT_NAME}-${MILVUS_SERVER_TYPE}-${MILVUS_CLIENT}-pytest-logs.tar.gz ./tests/pytest_logs --remove-files || true"
                                    }
                                    archiveArtifacts artifacts: "**.tar.gz", allowEmptyArchive: true
                                }
147 148 149 150 151 152
                            }
                        }
                    }
                    cleanup {
                        container('main') {
                            script {
153
                                sh "kind delete cluster --name kind -v9 || true"
154
                                sh 'find . -name . -o -prune -exec rm -rf -- {} +' /* clean up our workspace */
155 156 157 158 159 160 161 162
                            }
                        }
                    }
                }
            }
        }
    }
}