Advertisement
jimklimov

Parallel tests over parallel node labels

Nov 21st, 2016
1,310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 5.76 KB | None | 0 0
  1. #!groovy
  2.  
  3. /* Sample structure for parallelized steps over parallelized nodes in a DDSL pipeline (not 100% pure DDSL though)
  4.  * Use-case : build and test of a PR to a FOSS project across a farm of different target OSes.
  5.  * Note that practically there may be even more layers of loops (e.g. different compilers, bitnesses, autotools vs cmake, etc.)
  6.  * Problem: BlueOcean has problem rendering this. 1.0.0-b12 shows nothing, and 1.0.0-b13 shows a single tall stack
  7.  *          of green/red balls, often overlapped by largish step-tag texts (so the ball can not be clicked to get logs).
  8.  * Copyright (C) 2016 by Jim Klimov on the terms of MIT license
  9.  */
  10.  
  11. pipeline {
  12.     agent label:""
  13.     environment {
  14.         PATH="/usr/lib/ccache:\$PATH"
  15.         CC="/usr/lib/ccache/gcc"
  16.         CXX="/usr/lib/ccache/g++"
  17.         CCACHE_DIR="/home/jim/.ccache"
  18.     }
  19.     stages {
  20.         stage ("SELECT-BUILDER") {
  21.             steps {
  22.                 script {
  23.                     def subbuilds = [:]
  24.                     for (var_buildnode in ["hipster", "debian8"] ) {
  25.                         def buildnode = "${var_buildnode}"
  26.                         subbuilds["${buildnode}"] = {
  27.                             node("${buildnode}") {
  28.                                 stage ("PREP-SCM@${buildnode}") {
  29.                                         echo "Checkout to ${env.NODE_NAME} : ${env.WORKSPACE}"
  30.                                         checkout scm
  31.                                 }
  32.  
  33.                                 stage ("PREP-CLEAN@${buildnode}") {
  34.                                         sh 'if [ -s Makefile ] ; then make -k clean || true; make -k distclean || true; fi; true'
  35.                                         sh 'rm -f config.cache config.log config.status || true'
  36.                                         sh 'git checkout -- scripts/DMF/dmfnutscan/*.dmf scripts/DMF/dmfsnmp/*.dmf || true'
  37.                                 }
  38.  
  39.                                 stage ("PREP-AUTOGEN@${buildnode}") {
  40.                                         echo 'Autogen'
  41.                                         sh './autogen.sh'
  42.                                 }
  43.  
  44.                                 stage ("Configure-DMF-quick@${buildnode}") {
  45.                                         sh 'CCACHE_BASEDIR="`pwd`" ./configure --with-snmp --with-neon --with-dev --with-doc=skip --with-snmp_dmf=yes --with-dmfnutscan-regenerate=no --with-dmfsnmp-regenerate=no'
  46.                                 }
  47.  
  48.                                 stage ("Build@${buildnode}") {
  49.                                         sh 'CCACHE_BASEDIR="`pwd`" gmake -j 4 -k all || { echo ""; echo "================"; echo "=== REMAKE"; gmake -j1 all; }'
  50.                                 }
  51.  
  52.                                 stage ("FanoutTests@${buildnode}") {
  53.                                         script {
  54.                                             def tag_stashed = "${env.BUILD_TAG}-${env.GIT_COMMIT}-${env.NODE_LABELS}".replace(' ','_').replace('%','_')
  55.                                             stash("${tag_stashed}")
  56.                                             deleteDir()
  57.                                             def subtests = [:]
  58.                                             for (makerecipe in [
  59.  "distcheck-light"
  60. ,"distcheck-light-man"
  61. ,"distcheck-dmf-all-yes"
  62. ,"distcheck-dmf-no"
  63. ,"distcheck-dmf-warnings"
  64. ,"distcheck-dmf-features-REGEN_NO"
  65. ,"distcheck-dmf-features-LTDL_YES"
  66. ,"distcheck-dmf-features-LTDL_NO"
  67. ,"distcheck-dmf-features-LUA_YES"
  68. ,"distcheck-dmf-features-LUA_YESNO"
  69. ,"distcheck-dmf-features-LUA_NO"
  70. ,"distcheck-dmf-features-REGEN_YES"
  71.                                             ] ) {
  72.                                                 def tag_recipe = "${makerecipe}"
  73.                                                 def tag_labels = "${env.NODE_LABELS}".replace(' ','_').replace('%','_')
  74.                                                 def node_labels = "${env.NODE_LABELS}".replace(' ',' && ')
  75.                                                 subtests["TEST-${tag_recipe}@${tag_labels}"] = {
  76.                                                     node("${node_labels}") {
  77.                                                         stage ("TEST@${buildnode}: ${tag_recipe}") {
  78.                                                             echo "WIPE before UNSTASH for DISTCHECK"
  79.                                                             deleteDir()
  80.                                                             echo "UNSTASH for DISTCHECK"
  81.                                                             unstash("${tag_stashed}")
  82.                                                             echo "Reconfigure (fix up srcdir)"
  83.                                                             sh 'CCACHE_BASEDIR="`pwd`" ./configure -C --with-snmp --with-neon --with-dev --with-doc=skip --with-snmp_dmf=yes --with-dmfnutscan-regenerate=no --with-dmfsnmp-regenerate=no'
  84.                                                             echo "MAKE DISTCHECK : ${tag_recipe}"
  85.                                                             sh "CCACHE_BASEDIR=\"`pwd`\" gmake ${tag_recipe}"
  86.                                                             echo "WIPE after UNSTASH for DISTCHECK"
  87.                                                             deleteDir()
  88.                                                         }
  89.                                                     }
  90.                                                 }
  91.                                             }
  92.                                             parallel subtests
  93.                                         }
  94.                                 }
  95.                             }
  96.                         }
  97.                     }
  98.                     parallel subbuilds
  99.                 }
  100.             }
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement