From c90eb8c80507f6d5c9fc9c577a4a5aed75c619af Mon Sep 17 00:00:00 2001 From: Waldemar Zurowski Date: Fri, 18 Sep 2020 08:46:08 +0200 Subject: [PATCH] Switching linear regression build on two agents --- .ci/dev/regression/Jenkinsfile | 310 +++++++++++++++++++-------------- 1 file changed, 181 insertions(+), 129 deletions(-) diff --git a/.ci/dev/regression/Jenkinsfile b/.ci/dev/regression/Jenkinsfile index c971361c5c..f773438b4b 100644 --- a/.ci/dev/regression/Jenkinsfile +++ b/.ci/dev/regression/Jenkinsfile @@ -1,29 +1,21 @@ #!groovy /** - * Jenkins pipeline to build Corda OS release branches and tags + * Jenkins pipeline to build Corda OS release branches and tags. + * PLEASE NOTE: we DO want to run a build for each commit!!! */ -/** - * Kill already started job. - * Assume new commit takes precendence and results from previous - * unfinished builds are not required. - * This feature doesn't play well with disableConcurrentBuilds() option - */ -@Library('corda-shared-build-pipeline-steps') -import static com.r3.build.BuildControl.killAllExistingBuildsForJob - -killAllExistingBuildsForJob(env.JOB_NAME, env.BUILD_NUMBER.toInteger()) - /** * Sense environment */ boolean isReleaseTag = (env.TAG_NAME =~ /^release-.*(?version-properties" /* every build related to Corda X.Y (GA, RC, HC, patch or snapshot) uses the same NexusIQ application */ @@ -98,82 +114,130 @@ pipeline { } } - stage('Deploy Nodes') { - steps { - sh "./gradlew --no-daemon jar deployNodes" - } - } - - stage('Generate Build Image') { - steps { - withCredentials([string(credentialsId: 'container_reg_passwd', variable: 'DOCKER_PUSH_PWD')]) { - sh "./gradlew " + - "-Dkubenetize=true " + - "-Ddocker.push.password=\"\${DOCKER_PUSH_PWD}\" " + - "-Ddocker.work.dir=\"/tmp/\${EXECUTOR_NUMBER}\" " + - "-Ddocker.container.env.parameter.CORDA_ARTIFACTORY_USERNAME=\"\${ARTIFACTORY_CREDENTIALS_USR}\" " + - "-Ddocker.container.env.parameter.CORDA_ARTIFACTORY_PASSWORD=\"\${ARTIFACTORY_CREDENTIALS_PSW}\" " + - "-Ddocker.build.tag=\"\${DOCKER_TAG_TO_USE}\"" + - " clean preAllocateForAllParallelUnitTest preAllocateForAllParallelIntegrationTest " + - " preAllocateForAllParallelSlowIntegrationTest preAllocateForAllParallelSmokeTest " + - " pushBuildImage --stacktrace" - } - sh "kubectl auth can-i get pods" - } - } - - stage('Testing phase') { + stage('All Tests') { parallel { - stage('Unit Test') { - steps { - sh "./gradlew " + - "-DbuildId=\"\${BUILD_ID}\" " + - "-Dkubenetize=true " + - "-Ddocker.run.tag=\"\${DOCKER_TAG_TO_USE}\" " + - "-Dartifactory.username=\"\${ARTIFACTORY_CREDENTIALS_USR}\" " + - "-Dartifactory.password=\"\${ARTIFACTORY_CREDENTIALS_PSW}\" " + - "-Dgit.branch=\"\${GIT_BRANCH}\" " + - "-Dgit.target.branch=\"\${GIT_BRANCH}\" " + - " allParallelUnitTest --stacktrace" + stage('Another agent') { + agent { + label 'standard' + } + options { + skipDefaultCheckout true + } + post { + always { + archiveArtifacts artifacts: '**/*.log', fingerprint: false + junit testResults: '**/build/test-results/**/*.xml', keepLongStdio: true + /* + * Copy all JUnit results files into a single top level directory. + * This is necessary to stop the allure plugin from hitting out + * of memory errors due to being passed many directories with + * long paths. + * + * File names are pre-pended with a prefix when + * copied to avoid collisions between files where the same test + * classes have run on multiple agents. + */ + fileOperations([fileCopyOperation( + includes: '**/build/test-results/**/*.xml', + targetLocation: 'allure-input', + flattenFiles: true, + renameFiles: true, + sourceCaptureExpression: '.*/([^/]+)$', + targetNameExpression: 'other-agent-$1')]) + stash name: 'allure-input', includes: 'allure-input/**', useDefaultExcludes: false + } + cleanup { + deleteDir() /* clean up our workspace */ + } + } + stages { + stage('Unstash') { + steps { + unstash 'compiled' + } + } + stage('Recompile') { + steps { + sh script: [ + './gradlew', + COMMON_GRADLE_PARAMS, + 'jar' + ].join(' ') + } + } + stage('Unit Test') { + steps { + sh script: [ + './gradlew', + COMMON_GRADLE_PARAMS, + 'test' + ].join(' ') + } + } + stage('Smoke Test') { + steps { + sh script: [ + './gradlew', + COMMON_GRADLE_PARAMS, + 'smokeTest' + ].join(' ') + } + } + stage('Slow Integration Test') { + steps { + sh script: [ + './gradlew', + COMMON_GRADLE_PARAMS, + 'slowIntegrationTest' + ].join(' ') + } + } } } - stage('Integration Test') { - steps { - sh "./gradlew " + - "-DbuildId=\"\${BUILD_ID}\" " + - "-Dkubenetize=true " + - "-Ddocker.run.tag=\"\${DOCKER_TAG_TO_USE}\" " + - "-Dartifactory.username=\"\${ARTIFACTORY_CREDENTIALS_USR}\" " + - "-Dartifactory.password=\"\${ARTIFACTORY_CREDENTIALS_PSW}\" " + - "-Dgit.branch=\"\${GIT_BRANCH}\" " + - "-Dgit.target.branch=\"\${GIT_BRANCH}\" " + - " allParallelIntegrationTest --stacktrace" + stage('Same agent') { + post { + always { + archiveArtifacts artifacts: '**/*.log', fingerprint: false + junit testResults: '**/build/test-results/**/*.xml', keepLongStdio: true + /* + * Copy all JUnit results files into a single top level directory. + * This is necessary to stop the allure plugin from hitting out + * of memory errors due to being passed many directories with + * long paths. + * + * File names are pre-pended with a prefix when + * copied to avoid collisions between files where the same test + * classes have run on multiple agents. + */ + fileOperations([fileCopyOperation( + includes: '**/build/test-results/**/*.xml', + targetLocation: 'allure-input', + flattenFiles: true, + renameFiles: true, + sourceCaptureExpression: '.*/([^/]+)$', + targetNameExpression: 'same-agent-$1')]) + } } - } - stage('Smoke Test') { - steps { - sh "./gradlew " + - "-DbuildId=\"\${BUILD_ID}\" " + - "-Dkubenetize=true " + - "-Ddocker.run.tag=\"\${DOCKER_TAG_TO_USE}\" " + - "-Dartifactory.username=\"\${ARTIFACTORY_CREDENTIALS_USR}\" " + - "-Dartifactory.password=\"\${ARTIFACTORY_CREDENTIALS_PSW}\" " + - "-Dgit.branch=\"\${GIT_BRANCH}\" " + - "-Dgit.target.branch=\"\${GIT_BRANCH}\" " + - " allParallelSmokeTest --stacktrace" - } - } - stage('Slow Integration Test') { - steps { - sh "./gradlew " + - "-DbuildId=\"\${BUILD_ID}\" " + - "-Dkubenetize=true " + - "-Ddocker.run.tag=\"\${DOCKER_TAG_TO_USE}\" " + - "-Dartifactory.username=\"\${ARTIFACTORY_CREDENTIALS_USR}\" " + - "-Dartifactory.password=\"\${ARTIFACTORY_CREDENTIALS_PSW}\" " + - "-Dgit.branch=\"\${GIT_BRANCH}\" " + - "-Dgit.target.branch=\"\${GIT_BRANCH}\" " + - " allParallelSlowIntegrationTest --stacktrace" + stages { + stage('Integration Test') { + steps { + sh script: [ + './gradlew', + COMMON_GRADLE_PARAMS, + 'integrationTest' + ].join(' ') + } + } + + stage('Deploy Node') { + steps { + sh script: [ + './gradlew', + COMMON_GRADLE_PARAMS, + 'deployNode' + ].join(' ') + } + } } } } @@ -211,14 +275,19 @@ pipeline { stage('Publish Release to Docker Hub') { when { - expression { !isInternalRelease && isReleaseTag } + expression { isReleaseTag && !isInternalRelease && !isReleaseCandidate} } steps { withCredentials([ usernamePassword(credentialsId: 'corda-publisher-docker-hub-credentials', usernameVariable: 'DOCKER_USERNAME', - passwordVariable: 'DOCKER_PASSWORD')]) { - sh "./gradlew pushOfficialImages" + passwordVariable: 'DOCKER_PASSWORD') + ]) { + sh script: [ + './gradlew', + COMMON_GRADLE_PARAMS, + 'pushOfficialImages' + ].join(' ') } } } @@ -226,31 +295,12 @@ pipeline { post { always { - archiveArtifacts artifacts: '**/pod-logs/**/*.log', fingerprint: false - junit testResults: '**/build/test-results-xml/**/*.xml', keepLongStdio: true - script { try { - /* - * Copy all JUnit results files into a single top level directory. - * This is necessary to stop the allure plugin from hitting out - * of memory errors due to being passed many directories with - * long paths. - * - * File names are pre-pended with the pod number when - * copied to avoid collisions between files where the same test - * classes have run on multiple pods. - */ - fileOperations([fileCopyOperation( - includes: '**/test-results-xml/**/test-runs/test-reports/**', - targetLocation: 'allure-input', - flattenFiles: true, - renameFiles: true, - sourceCaptureExpression: '.*test-results-xml/.*-([\\d]+)/.*/([^/]+)$', - targetNameExpression: '$1-$2')]) + unstash 'allure-input' allure includeProperties: false, - jdk: '', - results: [[path: '**/allure-input']] + jdk: '', + results: [[path: '**/allure-input']] } catch (err) { echo("Allure report generation failed: $err") @@ -267,7 +317,7 @@ pipeline { // Comparing the dates of the previous and current builds achieves this, // i.e. we will only send an email for the first build on a given day. def prevBuildDate = new Date( - currentBuild?.previousBuild.timeInMillis ?: 0).clearTime() + currentBuild.previousBuild?.timeInMillis ?: 0).clearTime() def currentBuildDate = new Date( currentBuild.timeInMillis).clearTime() @@ -278,6 +328,8 @@ pipeline { statusSymbol = '\u2705' break; case 'UNSTABLE': + statusSymbol = '\u26A0' + break; case 'FAILURE': statusSymbol = '\u274c' break;