diff --git a/pipelines/build/common/openjdk_build_pipeline.groovy b/pipelines/build/common/openjdk_build_pipeline.groovy index ab94150b9..222156001 100644 --- a/pipelines/build/common/openjdk_build_pipeline.groovy +++ b/pipelines/build/common/openjdk_build_pipeline.groovy @@ -132,11 +132,36 @@ class Build { The test jobs all follow the same name naming pattern that is defined in the openjdk-tests repository. E.g. Test_openjdk11_hs_sanity.system_ppc64_aix */ - def getTestJobParams(testType) { - def jobParams = [:] + def getSmokeTestJobParams() { + def jobParams = getCommonTestJobParams() + jobParams.put('LEVELS', "extend") + jobParams.put('GROUPS', "functional") + jobParams.put('TEST_JOB_NAME', "${env.JOB_NAME}_SmokeTests") + jobParams.put("VENDOR_TEST_REPOS", ((String)ADOPT_DEFAULTS_JSON['repository']['build_url']).minus(".git")) + jobParams.put("VENDOR_TEST_BRANCHES","${ADOPT_DEFAULTS_JSON['repository']['build_branch']}")) + jobParams.put("VENDOR_TEST_DIRS", "${ADOPT_DEFAULTS_JSON['repository']['test_dirs']}") + return jobParams + } + + def getAQATestJobParams(testType) { + def jobParams = getCommonTestJobParams() def (level, group) = testType.tokenize('.') jobParams.put('LEVELS', level) jobParams.put('GROUPS', group) + def jobName = "Test_openjdk${jobParams['JDK_VERSIONS']}_${jobParams['JDK_IMPL']}_${testType}_${jobParams['ARCH_OS_LIST']}" + if (buildConfig.ADDITIONAL_FILE_NAME_TAG) { + switch (buildConfig.ADDITIONAL_FILE_NAME_TAG) { + case ~/.*XL.*/: + jobName += "_xl"; + break + } + } + jobParams.put('TEST_JOB_NAME', jobName) + return jobParams + } + + def getCommonTestJobParams() { + def commonJobParams = [:] def number = getJavaVersionNumber() jobParams.put('JDK_VERSIONS', number) def variant @@ -152,22 +177,18 @@ class Build { if (arch == "x64") { arch = "x86-64" } - def arch_os = "${arch}_${buildConfig.TARGET_OS}" - def jobName = "Test_openjdk${number}_${variant}_${testType}_${arch_os}" + def arch_os = "${arch}_${buildConfig.TARGET_OS}" if (buildConfig.ADDITIONAL_FILE_NAME_TAG) { switch (buildConfig.ADDITIONAL_FILE_NAME_TAG) { case ~/.*XL.*/: - jobName += "_xl"; arch_os += "_xl"; break } } - jobParams.put('TEST_JOB_NAME', jobName) jobParams.put('ARCH_OS_LIST', arch_os) jobParams.put('LIGHT_WEIGHT_CHECKOUT', true) return jobParams } - /* Retrieve the corresponding OpenJDK source code repository branch. This is used the downstream tests to determine what source code branch the tests should run against. */ @@ -236,13 +257,51 @@ class Build { return jdkRepo } + /* + Run smoke tests, which should block the running downstream test jobs should there are failures. + If we try to call a test job that doesn't exist, the pipeline will not fail but it will print out a warning. + If you need more test jobs added, please request so in #testing on Slack. + */ + def runSmokeTests() { + def additionalTestLabel = buildConfig.ADDITIONAL_TEST_LABEL + try { + context.println "Running smoke test" + context.stage("smoke test") { + def jobParams = getSmokeTestJobParams() + def jobName = jobParams.TEST_JOB_NAME + def JobHelper = context.library(identifier: 'openjdk-jenkins-helper@master').JobHelper + if (!JobHelper.jobIsRunnable(jobName as String)) { + context.sh('curl -Os https://raw.githubusercontent.com/AdoptOpenJDK/openjdk-tests/master/buildenv/jenkins/testJobTemplate') + def templatePath = 'testJobTemplate' + context.println "Smoke test job doesn't exist, create test job: ${jobName}" + jobDsl targets: templatePath, ignoreExisting: false, additionalParameters: jobParams + } + + context.catchError { + context.build job: jobName, + propagate: false, + parameters: [ + context.string(name: 'UPSTREAM_JOB_NUMBER', value: "${env.BUILD_NUMBER}"), + context.string(name: 'UPSTREAM_JOB_NAME', value: "${env.JOB_NAME}"), + context.string(name: 'RELEASE_TAG', value: "${buildConfig.SCM_REF}"), + context.string(name: 'LABEL_ADDITION', value: additionalTestLabel), + context.string(name: 'KEEP_REPORTDIR', value: "${keep_test_reportdir}"), + context.string(name: 'ACTIVE_NODE_TIMEOUT', value: "${buildConfig.ACTIVE_NODE_TIMEOUT}")] + } + } + } catch (Exception e) { + context.println "Failed to execute test: ${e.getLocalizedMessage()}" + throw new Exception("[ERROR] Smoke Tests failed. Tests Stop. ") + } + } /* Run the downstream test jobs based off the configuration passed down from the top level pipeline jobs. If we try to call a test job that doesn't exist, the pipeline will not fail but it will print out a warning. If you need more test jobs added, please request so in #testing on Slack. */ - def runTests() { + // def runDownStreamTests() + def runAQATests() { def testStages = [:] List testList = [] def jdkBranch = getJDKBranch() @@ -264,7 +323,7 @@ class Build { keep_test_reportdir = "true" } - def jobParams = getTestJobParams(testType) + def jobParams = getAQATestJobParams(testType) def jobName = jobParams.TEST_JOB_NAME def JobHelper = context.library(identifier: 'openjdk-jenkins-helper@master').JobHelper @@ -1322,14 +1381,21 @@ class Build { throw new Exception("[ERROR] Sign job timeout (${buildTimeouts.SIGN_JOB_TIMEOUT} HOURS) has been reached OR the downstream sign job failed. Exiting...") } } - - if (enableTests && buildConfig.TEST_LIST.size() > 0) { - try { - // Run tests if we have a test list, don't use timeouts as the jobs have their own - def testStages = runTests() - context.parallel testStages + + runTests() { + try { + runSmokeTests() + if (enableTests && buildConfig.TEST_LIST.size() > 0) { + try { + // Run tests if we have a test list, don't use timeouts as the jobs have their own + def testStages = runAQATests() + context.parallel testStages + } catch (Exception e) { + context.println "Failed test: ${e}" + } + } } catch (Exception e) { - context.println "Failed test: ${e}" + context.println(e.message) } } diff --git a/pipelines/defaults.json b/pipelines/defaults.json index ca5bf24f7..5085c534b 100644 --- a/pipelines/defaults.json +++ b/pipelines/defaults.json @@ -2,6 +2,7 @@ "repository" : { "build_url" : "https://github.com/AdoptOpenJDK/openjdk-build.git", "build_branch" : "master", + "test_dirs" : "/test/functional", "pipeline_url" : "https://github.com/AdoptOpenJDK/ci-jenkins-pipelines.git", "pipeline_branch" : "master" },