Skip to content

Commit

Permalink
Update logic for Parallel option with num_machines=1
Browse files Browse the repository at this point in the history
resolve: #4093
Signed-off-by: Lan Xia <Lan_Xia@ca.ibm.com>
  • Loading branch information
llxia committed Nov 1, 2022
1 parent 487c0ee commit fd5d68f
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions buildenv/jenkins/JenkinsfileBase
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def setupEnv() {
env.DOCKER_REGISTRY_DIR = params.DOCKER_REGISTRY_DIR ? params.DOCKER_REGISTRY_DIR : ""
env.DOCKER_REGISTRY_URL_CREDENTIAL_ID = params.DOCKER_REGISTRY_URL_CREDENTIAL_ID ? params.DOCKER_REGISTRY_URL_CREDENTIAL_ID : ""
ITERATIONS = params.ITERATIONS ? "${params.ITERATIONS}".toInteger() : 1
NUM_MACHINES = params.NUM_MACHINES ? params.NUM_MACHINES.toInteger() : 1

if (JOB_NAME.contains("Grinder")) {
def currentDate = new Date()
Expand Down Expand Up @@ -152,7 +153,7 @@ def setupParallelEnv() {
def UPSTREAM_TEST_JOB_NUMBER = ""

if (params.PARALLEL == "NodesByIterations") {
childJobNum = params.NUM_MACHINES ? params.NUM_MACHINES.toInteger() : 1
childJobNum = NUM_MACHINES
// limit childJobNum
if (childJobNum > 20) {
echo "Due to the limited machines, NUM_MACHINES can only be set up to 20. Current NUM_MACHINES is ${NUM_MACHINES}."
Expand Down Expand Up @@ -826,23 +827,13 @@ def testBuild() {
addGrinderLink()
// prepare environment and compile test projects
if( params.PARALLEL && params.PARALLEL != "None" ) {
setupParallelEnv()
} else {
try {
//ToDo: temporary workaround for jck test parallel runs
// until build.xml is added into each subfolder
if( env.BUILD_LIST.startsWith('jck/')) {
def temp = env.BUILD_LIST
env.BUILD_LIST = "jck"
buildTest()
env.BUILD_LIST = temp
} else {
buildTest()
}
runTest()
} finally {
post("${env.BUILD_LIST}")
if ((params.PARALLEL == "NodesByIterations" || params.PARALLEL == "Dynamic") && NUM_MACHINES == 1) {
testExecution()
} else {
setupParallelEnv()
}
} else {
testExecution()
}
} finally {
// Terminate any left over java processes
Expand All @@ -864,6 +855,24 @@ def testBuild() {
}
}

def testExecution() {
try {
//ToDo: temporary workaround for jck test parallel runs
// until build.xml is added into each subfolder
if( env.BUILD_LIST.startsWith('jck/')) {
def temp = env.BUILD_LIST
env.BUILD_LIST = "jck"
buildTest()
env.BUILD_LIST = temp
} else {
buildTest()
}
runTest()
} finally {
post("${env.BUILD_LIST}")
}
}

def terminateJavaProcesses() {
// Attempt up to 30 times or until no more Java processes spawn...
for(int i=0; i<30; i++) {
Expand Down Expand Up @@ -1100,7 +1109,7 @@ def addFailedTestsGrinderLink(paths=""){
}

def run_parallel_tests() {
if (params.PARALLEL && params.PARALLEL != "None") {
if (params.PARALLEL && params.PARALLEL != "None" && NUM_MACHINES > 1) {
stage ("Parallel Tests") {
def childJobs = parallel parallel_tests
node {
Expand Down

0 comments on commit fd5d68f

Please sign in to comment.