NightlyCI.groovy 8.5 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
int total_timeout_minutes = 360
9
int e2e_timeout_seconds = 4 * 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
                                            e2e_timeout_seconds = 5 * 60 * 60
71 72
                                        }

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

124
                                withCredentials([usernamePassword(credentialsId: "${env.DOCKER_CREDENTIALS_ID}", usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
125
                                    sh 'docker login -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}'
126
                                    sh """
127 128 129 130
                                        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
131
                                    """
132
                                    sh 'docker logout'
133
                                }
134 135 136
                            }
                        }
                    }
137
                    always {
138 139
                        container('main') {
                            script {
140 141 142
                                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"
143
                                    if ("${MILVUS_CLIENT}" == "pymilvus") {
144 145 146 147
                                        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
                                }
148 149 150 151 152 153
                            }
                        }
                    }
                    cleanup {
                        container('main') {
                            script {
154
                                sh "kind delete cluster --name kind -v9 || true"
155
                                sh 'find . -name . -o -prune -exec rm -rf -- {} +' /* clean up our workspace */
156 157 158 159 160 161 162 163
                            }
                        }
                    }
                }
            }
        }
    }
}