Skip to content

Commit

Permalink
Update logic for Parallel option with num_machines=1 (#4102)
Browse files Browse the repository at this point in the history
When running tests with Parallel option and num_machines=1, run tests serially.
Don't do parallel as it will create unnecessary overhead

resolve: #4093
Signed-off-by: Lan Xia <Lan_Xia@ca.ibm.com>

Signed-off-by: Lan Xia <Lan_Xia@ca.ibm.com>
  • Loading branch information
llxia authored Nov 2, 2022
1 parent 1367231 commit d35e9d1
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 @@ -810,23 +811,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 @@ -848,6 +839,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 @@ -1152,7 +1161,7 @@ def triggerRerunJob (failedTests) {
}

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 d35e9d1

Please sign in to comment.