diff --git a/buildenv/jenkins/JenkinsfileBase b/buildenv/jenkins/JenkinsfileBase index bea07d28a8..62abbbd213 100644 --- a/buildenv/jenkins/JenkinsfileBase +++ b/buildenv/jenkins/JenkinsfileBase @@ -66,6 +66,7 @@ def setupEnv() { SSH_AGENT_CREDENTIAL = params.SSH_AGENT_CREDENTIAL ? params.SSH_AGENT_CREDENTIAL : "" KEEP_WORKSPACE = params.KEEP_WORKSPACE ? params.KEEP_WORKSPACE : false OPENJ9_SHA = params.OPENJ9_SHA ? params.OPENJ9_SHA : "" + CLOUD_PROVIDER = params.CLOUD_PROVIDER ? params.CLOUD_PROVIDER : "" env.JDK_BRANCH = params.JDK_BRANCH ? params.JDK_BRANCH : "" env.USER_CREDENTIALS_ID = params.USER_CREDENTIALS_ID ? params.USER_CREDENTIALS_ID : "" env.TEST_JDK_HOME = "$WORKSPACE/openjdkbinary/j2sdk-image" @@ -575,7 +576,7 @@ def runTest( ) { echo "env.DISPLAY is ${env.DISPLAY}" makeTest("${RUNTEST_CMD}") } - else if (env.SPEC.startsWith('linux')) { + else if (env.SPEC.startsWith('linux') && !LABEL.contains('ci.agent.dynamic')) { // Add an additional 10 second timeout due to issue: https://github.com/AdoptOpenJDK/openjdk-build/issues/2368#issuecomment-756683888 wrap([$class: 'Xvfb', autoDisplayName: true, timeout:10]) { def DISPLAY = sh ( @@ -875,7 +876,6 @@ def run_parallel_tests() { if (params.PARALLEL && params.PARALLEL != "None") { stage ("Parallel Tests") { def childJobs = parallel parallel_tests - node { def buildResult = "" childJobs.each { diff --git a/buildenv/jenkins/openjdk_tests b/buildenv/jenkins/openjdk_tests index 4d3d65d6d2..5e22732dd7 100644 --- a/buildenv/jenkins/openjdk_tests +++ b/buildenv/jenkins/openjdk_tests @@ -68,18 +68,22 @@ def PLATFORM_MAP = [ 's390_linux' : [ 'SPEC' : 'linux_390', 'LABEL' : 'ci.role.test&&hw.arch.s390x&&sw.os.linux&&hw.bits.32', + 'DynamicAgents' : ['fyre'] ], 's390x_linux' : [ 'SPEC' : 'linux_390-64_cmprssptrs', 'LABEL' : 'ci.role.test&&hw.arch.s390x&&sw.os.linux', + 'DynamicAgents' : ['fyre'] ], 's390x_linux_mixed' : [ 'SPEC' : 'linux_390-64_mxdptrs', 'LABEL' : 'ci.role.test&&hw.arch.s390x&&sw.os.linux', + 'DynamicAgents' : ['fyre'] ], 's390x_linux_xl' : [ 'SPEC' : 'linux_390-64', 'LABEL' : 'ci.role.test&&hw.arch.s390x&&sw.os.linux', + 'DynamicAgents' : ['fyre'] ], 's390x_zos' : [ 'SPEC' : 'zos_390-64_cmprssptrs', @@ -116,14 +120,17 @@ def PLATFORM_MAP = [ 'x86-64_linux' : [ 'SPEC' : 'linux_x86-64_cmprssptrs', 'LABEL' : 'ci.role.test&&hw.arch.x86&&sw.os.linux', + 'DynamicAgents' : ['azure', 'fyre'] ], 'x86-64_linux_mixed' : [ 'SPEC' : 'linux_x86-64_mxdptrs', 'LABEL' : 'ci.role.test&&hw.arch.x86&&sw.os.linux', + 'DynamicAgents' : ['azure', 'fyre'] ], 'x86-64_linux_xl' : [ 'SPEC' : 'linux_x86-64', 'LABEL' : 'ci.role.test&&hw.arch.x86&&sw.os.linux', + 'DynamicAgents' : ['azure', 'fyre'] ], 'x86-64_mac' : [ 'SPEC' : 'osx_x86-64_cmprssptrs', @@ -154,7 +161,6 @@ def PLATFORM_MAP = [ if ( !params.TARGET ) { assert false : "Please provide TARGET value" } - def PLATFORMS = params.PLATFORM.trim().split("\\s*,\\s*"); def JDK_VERSIONS = params.JDK_VERSION.trim().split("\\s*,\\s*"); def JDK_IMPLS = params.JDK_IMPL.trim().split("\\s*,\\s*"); @@ -210,6 +216,10 @@ if (JDK_VERSIONS.size() > 1 || JDK_IMPLS.size() > 1 || PLATFORMS.size() >1 || PL if (PLATFORM_MAP.containsKey(params.PLATFORM)) { SPEC = PLATFORM_MAP[params.PLATFORM]["SPEC"] LABEL = params.LABEL ? params.LABEL : PLATFORM_MAP[params.PLATFORM]["LABEL"] + dynamicAgents = [] + if (PLATFORM_MAP[params.PLATFORM].containsKey('DynamicAgents')) { + dynamicAgents = PLATFORM_MAP[params.PLATFORM]["DynamicAgents"] + } if (params.DOCKER_REQUIRED) { LABEL += "&&sw.tool.docker" @@ -223,51 +233,81 @@ if (JDK_VERSIONS.size() > 1 || JDK_IMPLS.size() > 1 || PLATFORMS.size() >1 || PL println "LABEL: ${LABEL}" stage('Queue') { - if (nodesByLabel(LABEL).size() < 1) { + String[] onlineNodes = nodesByLabel(LABEL) + if (onlineNodes.size() < 1) { int ACTIVE_NODE_TIMEOUT = params.ACTIVE_NODE_TIMEOUT ? params.ACTIVE_NODE_TIMEOUT : 0 - timeout(ACTIVE_NODE_TIMEOUT) { - // node(LABEL) has to be used for spinning up a dynamic vm agent + // If there is available node before timeout node(LABEL) { - echo "find the node ${env.NODE_NAME}" + echo "find the node with label as ${env.NODE_NAME}" + } + } + } else { + boolean isNodeIdle = false + node('master') { + for (String onlineNode : onlineNodes) { + def nodeStatus = sh(script: "curl ${env.JENKINS_URL}computer/${onlineNode}/api/xml?xpath=/*/idle", + returnStdout: true, + returnStatus: false + ).trim() + if (nodeStatus.contains("true")) { + isNodeIdle = true + break + } + } + } + // IF no nodes are idle we will check if there is supported virtual agent + // When Parallel the race condition could happen. Say the number of multiply jobs is larger than the available nodes the query's result may be delayed and wrong + // In this case jobs will be fooled to fall back to wait local busy nodes. + if (!isNodeIdle && (CLOUD_PROVIDER.length()) != 0) { + if (CLOUD_PROVIDER in dynamicAgents) { + LABEL += '&&ci.agent.dynamic' } } - } - node(LABEL) { - if (params.PLATFORM.contains('zos')) { - /* Ensure correct CC env */ - env._CC_CCMODE = '1' - env._CXX_CCMODE = '1' - env._C89_CCMODE = '1' + node(LABEL) { + if (params.PLATFORM.contains('zos')) { + /* Ensure correct CC env */ + env._CC_CCMODE = '1' + env._CXX_CCMODE = '1' + env._C89_CCMODE = '1' - def gitConfig = scm.getUserRemoteConfigs()[0] - def SCM_GIT_REPO = gitConfig.getUrl() - def SCM_GIT_BRANCH = scm.branches[0].name - cleanWs() + def gitConfig = scm.getUserRemoteConfigs()[0] + def SCM_GIT_REPO = gitConfig.getUrl() + def SCM_GIT_BRANCH = scm.branches[0].name + cleanWs() - // SCM_GIT_REPO value only gets expanded in sh - def SCM_GIT_REPO_VAL = sh(script: "echo ${SCM_GIT_REPO}", returnStdout: true).trim() - SCM_GIT_REPO_VAL = SCM_GIT_REPO_VAL.replace("https://github.com/","git@github.com:") + // SCM_GIT_REPO value only gets expanded in sh + def SCM_GIT_REPO_VAL = sh(script: "echo ${SCM_GIT_REPO}", returnStdout: true).trim() + SCM_GIT_REPO_VAL = SCM_GIT_REPO_VAL.replace("https://github.com/","git@github.com:") - sh "git clone -b ${SCM_GIT_BRANCH} ${SCM_GIT_REPO_VAL} openjdk-tests" - } else { - def gitConfig = scm.getUserRemoteConfigs().get(0) + sh "git clone -b ${SCM_GIT_BRANCH} ${SCM_GIT_REPO_VAL} openjdk-tests" + } else { + def gitConfig = scm.getUserRemoteConfigs().get(0) - // Adopt windows machines require env here https://github.com/AdoptOpenJDK/openjdk-tests/issues/1803 - ref_cache = "${env.HOME}/openjdk_cache" + // Adopt windows machines require env here https://github.com/AdoptOpenJDK/openjdk-tests/issues/1803 + ref_cache = "${env.HOME}/openjdk_cache" - checkout scm: [$class: 'GitSCM', - branches: [[name: "${scm.branches[0].name}"]], - extensions: [ - [$class: 'CleanBeforeCheckout'], - [$class: 'CloneOption', reference: ref_cache], - [$class: 'RelativeTargetDirectory', relativeTargetDir: 'openjdk-tests']], - userRemoteConfigs: [[url: "${gitConfig.getUrl()}"]] - ] + checkout scm: [$class: 'GitSCM', + branches: [[name: "${scm.branches[0].name}"]], + extensions: [ + [$class: 'CleanBeforeCheckout'], + [$class: 'CloneOption', reference: ref_cache], + [$class: 'RelativeTargetDirectory', relativeTargetDir: 'openjdk-tests']], + userRemoteConfigs: [[url: "${gitConfig.getUrl()}"]] + ] + } + jenkinsfile = load "${WORKSPACE}/openjdk-tests/buildenv/jenkins/JenkinsfileBase" + if (LABEL.contains('ci.agent.dynamic') && CLOUD_PROVIDER == 'azure') { + //Set dockerimage for azure agent. Fyre has stencil to setup the right environment + docker.image('adoptopenjdk/centos6_build_image').pull() + docker.image('adoptopenjdk/centos6_build_image').inside { + jenkinsfile.testBuild() + } + } else { + jenkinsfile.testBuild() + } } - jenkinsfile = load "${WORKSPACE}/openjdk-tests/buildenv/jenkins/JenkinsfileBase" - jenkinsfile.testBuild() } } jenkinsfile.run_parallel_tests() diff --git a/buildenv/jenkins/testJobTemplate b/buildenv/jenkins/testJobTemplate index 9d917bf2bb..80d329de31 100644 --- a/buildenv/jenkins/testJobTemplate +++ b/buildenv/jenkins/testJobTemplate @@ -49,8 +49,7 @@ if (!binding.hasVariable('VENDOR_TEST_REPOS')) VENDOR_TEST_REPOS = "" if (!binding.hasVariable('VENDOR_TEST_BRANCHES')) VENDOR_TEST_BRANCHES = "" if (!binding.hasVariable('VENDOR_TEST_DIRS')) VENDOR_TEST_DIRS = "" if (!binding.hasVariable('USER_CREDENTIALS_ID')) USER_CREDENTIALS_ID = "" - - +if (!binding.hasVariable('CLOUD_PROVIDER')) CLOUD_PROVIDER = "" if (!binding.hasVariable('BUILDS_TO_KEEP')) { BUILDS_TO_KEEP = 10 @@ -246,6 +245,7 @@ ARCH_OS_LIST.each { ARCH_OS -> stringParam('UPSTREAM_TEST_JOB_NAME', "", "Auto-populated. Upstream test job name. It will be used together with PARALLEL=Dynamic") stringParam('UPSTREAM_TEST_JOB_NUMBER', "", "Auto-populated. Upstream test job number. It will be used together with PARALLEL=Dynamic") booleanParam('LIGHT_WEIGHT_CHECKOUT', LIGHT_WEIGHT_CHECKOUT.toBoolean(), "Optional. Default is false for Grinders") + stringParam('CLOUD_PROVIDER', CLOUD_PROVIDER, "Available cloud provider, e.g. azure, fyre") } cpsScm { scm {