Skip to content

Commit

Permalink
Make functional test stage run parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
Carthanial committed Jan 10, 2022
1 parent 65e6d3b commit 7ee407a
Showing 1 changed file with 37 additions and 23 deletions.
60 changes: 37 additions & 23 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -97,39 +97,53 @@ node('test') {

}
}
}
stage('Functional Test') {
functionalDynamicParallelSteps(testImage);

stage("Run Functional Test") {
sh "sleep 120"
sh "curl localhost:9200"
sh "curl localhost:5601"
echo "Start Functional Tests"

junit 'target/junit/ci*/*.xml'
}
} catch (e) {
echo 'This will run only if failed'
currentBuild.result = 'FAILURE'
throw e
}
}

def functionalDynamicParallelSteps(image){
ciGroupsMap = [:]
for (int i = 1; i <= 12; i++) {
def currentCiGroup = "ciGroup${i}";
def currentStep = i;
ciGroupsMap["${currentCiGroup}"] = {
sh "rm -rf ${env.WORKSPACE}/data/${currentCiGroup}"
sh "mkdir -p ${env.WORKSPACE}/data/${currentCiGroup}"
stage("${currentCiGroup}") {
withEnv([
"TEST_BROWSER_HEADLESS=1",
"CI=1",
"GCS_UPLOAD_PREFIX=fake",
"TEST_ES_PORT=9200",
"TEST_KIBANA_PORT=5601",
"TEST_KIBANA_PROTOCOL=http",
"TEST_ES_PROTOCOL=http",
"TEST_KIBANA_HOSTNAME=localhost",
"TEST_ES_HOSTNAME=localhost"
"TEST_ES_HOSTNAME=localhost",
"CACHE_DIR=${currentCiGroup}"
]) {

def utResult = sh returnStatus: true, script: 'CI=1 GCS_UPLOAD_PREFIX=fake node scripts/functional_test_runner'

if (utResult != 0) {
currentBuild.result = 'FAILURE'
image.inside("-v \'${env.WORKSPACE}/data/${currentCiGroup}:${env.WORKSPACE}/elasticsearch-6.7.2/data\'"){
sh './elasticsearch-6.7.2/bin/elasticsearch & '

echo "Starting Kibana..."
sh "./bin/kibana --no-base-path &"

sh "sleep 180"
sh "curl localhost:9200"
sh "curl localhost:5601"
echo "Start Functional Tests"
sh "node scripts/functional_test_runner --config test/functional/config.js --include-tag ${currentCiGroup}"
}

junit 'target/junit/TEST-UI Functional Tests.xml'
}
}

}
} catch (e) {
echo 'This will run only if failed'
junit 'target/junit/TEST-UI Functional Tests.xml'
currentBuild.result = 'FAILURE'
throw e
}
}
parallel ciGroupsMap
}

0 comments on commit 7ee407a

Please sign in to comment.