Skip to content

Commit

Permalink
[Stable8.2] fix unit test on new jenkins setup and adjust Jenkinsfile (
Browse files Browse the repository at this point in the history
…#25772) (#25775) (#25783)

* Next step jenkinsfile (#25622)

* Adding timestamper and evaluation of test results even in case of failure

* Adding build timeout

* use fixed value 120 minutes as timeout for each test executing for now

* Terminate the build as soon as test execution fails

* Adjust external testing as well

* Finalize use of executeAndReport

* Array sort order is of no relevance
  • Loading branch information
DeepDiver1975 committed Aug 14, 2016
1 parent 312590e commit e13c3a7
Showing 1 changed file with 74 additions and 30 deletions.
104 changes: 74 additions & 30 deletions Jenkinsfile
@@ -1,43 +1,87 @@
#!groovy
/*
* This Jenkinsfile is intended to run on https://ci.owncloud.org and may fail anywhere else.
* It makes assumptions about plugins being installed, labels mapping to nodes that can build what is needed, etc.
*/

node('SLAVE') {
timestampedNode('SLAVE') {
stage 'Checkout'
checkout scm
sh '''git submodule update --init'''

stage 'JavaScript Testing'
sh '''./autotest-js.sh'''
step([$class: 'JUnitResultArchiver', testResults: 'tests/autotest-results-js.xml'])
executeAndReport('tests/autotest-results-js.xml') {
sh '''./autotest-js.sh'''
}

stage 'PHPUnit'
sh '''
export NOCOVERAGE=1
unset USEDOCKER
phpenv local 5.6
./autotest.sh sqlite
phpenv local 5.4
./autotest.sh mysql
phpenv local 5.6
./autotest.sh pgsql
phpenv local 5.5
./autotest.sh oci
'''
step([$class: 'JUnitResultArchiver', testResults: 'tests/autotest-results-sqlite.xml'])
step([$class: 'JUnitResultArchiver', testResults: 'tests/autotest-results-mysql.xml'])
step([$class: 'JUnitResultArchiver', testResults: 'tests/autotest-results-oci.xml'])
step([$class: 'JUnitResultArchiver', testResults: 'tests/autotest-results-pgsql.xml'])
executeAndReport('tests/autotest-results-sqlite.xml') {
sh '''
export NOCOVERAGE=1
unset USEDOCKER
phpenv local 5.6
./autotest.sh sqlite
'''
}
executeAndReport('tests/autotest-results-mysql.xml') {
sh '''
export NOCOVERAGE=1
unset USEDOCKER
phpenv local 5.4
./autotest.sh mysql
'''
}
executeAndReport('tests/autotest-results-pgsql.xml') {
sh '''
export NOCOVERAGE=1
unset USEDOCKER
phpenv local 5.6
./autotest.sh pgsql
'''
}
executeAndReport('tests/autotest-results-oci.xml') {
sh '''
export NOCOVERAGE=1
unset USEDOCKER
phpenv local 5.5
./autotest.sh oci
'''
}

stage 'Files External Testing'
sh '''phpenv local 5.6
export NOCOVERAGE=1
unset USEDOCKER
./autotest-external.sh sqlite webdav-ownCloud
./autotest-external.sh sqlite smb-silvershell
./autotest-external.sh sqlite swift-ceph
'''
step([$class: 'JUnitResultArchiver', testResults: 'tests/autotest-external-results-sqlite.xml'])
step([$class: 'JUnitResultArchiver', testResults: 'tests/autotest-external-results-sqlite-webdav-ownCloud.xml'])
step([$class: 'JUnitResultArchiver', testResults: 'tests/autotest-external-results-sqlite-smb-silvershell.xml'])
step([$class: 'JUnitResultArchiver', testResults: 'tests/autotest-external-results-sqlite-swift-ceph.xml'])
executeAndReport('tests/autotest-external-results-sqlite-webdav-ownCloud.xml') {
sh '''phpenv local 5.6
export NOCOVERAGE=1
unset USEDOCKER
./autotest-external.sh sqlite webdav-ownCloud
'''
}
}

void executeAndReport(String testResultLocation, def body) {
def failed = false
// We're wrapping this in a timeout - if it takes longer, kill it.
try {
timeout(time: 120, unit: 'MINUTES') {
body.call()
}
} catch (Exception e) {
failed = true
echo "Test execution failed: ${e}"
} finally {
step([$class: 'JUnitResultArchiver', testResults: testResultLocation])
}

if (failed) {
error "Test execution failed. Terminating the build"
}
}

// Runs the given body within a Timestamper wrapper on the given label.
def timestampedNode(String label, Closure body) {
node(label) {
wrap([$class: 'TimestamperBuildWrapper']) {
body.call()
}
}
}

0 comments on commit e13c3a7

Please sign in to comment.