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

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

      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

          [JENKINS-39198] External Workspace Manager doesn't work properly with parallel test execution

          Alexandru Somai created issue -
          Alexandru Somai made changes -
          Epic Link New: JENKINS-37543 [ 173654 ]
          Alexandru Somai made changes -
          Rank New: Ranked higher
          Alexandru Somai made changes -
          Description New: 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:
          {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()],
                              ]
                  }
              }
          }
          {code}
          Downstream code is:
          {code}
          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}"

              }
          }
          {code}

          Due to parallel execution of downstream job, builds start it in different workspaces, for example:
          {{/tmp/TEST2/63@2}}
          {{/tmp/TEST2/63@3}}
          Alexandru Somai made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Alexandru Somai made changes -
          Remote Link New: This issue links to "PR #48 (Web Link)" [ 14976 ]
          Alexandru Somai made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Progress [ 3 ] New: Resolved [ 5 ]

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

              Created:
              Updated:
              Resolved: