Skip to content

Commit

Permalink
Add extra options for Jenkins to improve test reliability. (#48)
Browse files Browse the repository at this point in the history
* Add extra options for Jenkins to improve test reliability.

* Add a timeout on testing steps.

* Reduce the number of workers.

* Bump the timeout a bit

* Revert crawler agent
  • Loading branch information
sammacbeth authored Nov 17, 2022
1 parent 86f8a0d commit a396e5c
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
def runPlaywrightTests(resultDir) {
sh 'mkdir -p ./test-results'
sh """
PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --project webkit --project iphoneSE --reporter=junit || true
"""
junit 'results.xml'
sh """
mkdir -p ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
mkdir -p ./test-results
mv ./test-results/ ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
"""
def runPlaywrightTests(resultDir, browser, grep) {
try {
timeout(20) {
sh 'mkdir -p ./test-results'
sh """
PLAYWRIGHT_JUNIT_OUTPUT_NAME=results.xml npx playwright test --project $browser --reporter=junit --workers 10 --grep "$grep"|| true
"""
}
} finally {
junit 'results.xml'
sh """
mkdir -p ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
mkdir -p ./test-results
mv ./test-results/ ${resultDir}/results/${BRANCH_NAME}/${BUILD_NUMBER}/$REGION/
"""
}
}

def withEnvFile(envfile, Closure cb) {
Expand All @@ -19,9 +24,11 @@ def withEnvFile(envfile, Closure cb) {
}

pipeline {
agent { label 'crawler-autoconsent' }
agent { label 'autoconsent-crawler' }
parameters {
string(name: 'TEST_RESULT_ROOT', defaultValue: '/mnt/efs/users/smacbeth/autoconsent/ci', description: 'Where test results and configuration are stored')
choice(name: 'BROWSER', choices: ['webkit', 'iphoneSE', 'chrome', 'firefox'], description: 'Browser')
string(name: 'GREP', defaultValue: '', description: 'filter for tests matching a specific string')
}
environment {
NODENV_VERSION = "14.15.4"
Expand All @@ -41,37 +48,40 @@ pipeline {
npm ci
npx playwright install webkit
'''
script {
currentBuild.description = "${params.BROWSER} - ${params.GREP}"
}
}
}

stage('Test: DE') {
steps {
withEnvFile("${params.TEST_RESULT_ROOT}/de.env") {
runPlaywrightTests(params.TEST_RESULT_ROOT)
runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP)
}
}
}

stage('Test: US') {
steps {
withEnvFile("${params.TEST_RESULT_ROOT}/us.env") {
runPlaywrightTests(params.TEST_RESULT_ROOT)
runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP)
}
}
}

stage('Test: GB') {
steps {
withEnvFile("${params.TEST_RESULT_ROOT}/gb.env") {
runPlaywrightTests(params.TEST_RESULT_ROOT)
runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP)
}
}
}

stage('Test: FR') {
steps {
withEnvFile("${params.TEST_RESULT_ROOT}/fr.env") {
runPlaywrightTests(params.TEST_RESULT_ROOT)
runPlaywrightTests(params.TEST_RESULT_ROOT, params.BROWSER, params.GREP)
}
}
}
Expand Down

0 comments on commit a396e5c

Please sign in to comment.