Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-39198

External Workspace Manager doesn't work properly with parallel test execution

XMLWordPrintable

      The external workspace manager plugin doesn't work very well when using parallel test execution. The main problem is that it creates different workspaces for each test that is executed in parallel.

      Here's a basic example:

      Upstream code:

      node('master') {
          def extWorkspace = exwsAllocate 'dp1'
          exws(extWorkspace) {
              stage "Checkout ${GIT_BRANCH}"
              git ...
      
      
              stage 'Test execution'
              def TEST_CONFIG = "production"
              def tests = ['test_1',
                           'test_2',
      
              ]
              try {
                  def branches = [:]
                  for (int i = 0; i < tests.size(); i++) {
      
                      def s = tests.get(i)
                      def stepName = "running ${s}"
      
                      branches[stepName] = runTestSuite(s, TEST_CONFIG)
                  }
      
                  parallel branches
              } catch (all) {
      
              } finally {
                  stage 'Test results parsing'
                  step([$class: 'JUnitResultArchiver', testResults: 'junit/*.xml'])
              }
          }
      }
      
      def runTestSuite(test_suite, config) {
          return {
              node('master') {
                  build job: 'Run test suite',
                          parameters: [[$class: 'StringParameterValue', name: 'test', value: test_suite],
                                       [$class: 'StringParameterValue', name: 'TEST_CONFIG', value: config],
                                       [$class: 'StringParameterValue', name: 'UPSTREAM_BUILD_NUMBER', value: currentBuild.number.toString()],
                          ]
              }
          }
      }
      

      Downstream code is:

      node('master') {
          def customPath = "tmp/TEST2/${UPSTREAM_BUILD_NUMBER}"
          def extWorkspace = exwsAllocate diskPoolId: 'dp1', path: customPath
      
      
          exws(extWorkspace) {
      
              currentBuild.displayName = "branch: ${GIT_BRANCH}, config: prod, test: ${test}"
      
              stage 'Test execution'
              sh "py.test ... ${test}"
      
          }
      }
      

      Due to parallel execution of downstream job, builds start it in different workspaces, for example:
      /tmp/TEST2/63@2
      /tmp/TEST2/63@3

            alexsomai Alexandru Somai
            alexsomai Alexandru Somai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: