Several xUnit runs within same pipeline interfer with each other

36 views
Skip to first unread message

ST

unread,
Jun 10, 2018, 4:32:02 PM6/10/18
to Jenkins Users
I have a pipeline where at some point two parallel branches are run, both of them collecting their test result with xUnit. One branch (say branch A) has unstableThreshold=5 whereas the other branch (say branch B) has unstableThreshold=0. Branch A has usually 2-3 tests failing for various reasons. Ascii visualization:

                      |-- (branch A: build & xUnit) --|
(main build) --|                                               | ---- (build cleanup)
                      |-- (branch B: build & xUnit) --|

Now the strange behaviour I'm seeing:
If branch A takes longer than branch B, everything works as expected when 2 tests in branch A fail: the build gets set to SUCCESS.

However if branch A runs faster than branch B, then the build will get set to UNSTABLE during xUnit step in branch B, since xUnit step in branch B somehow picks up the test failures from branch A and then sets the build to UNSTABLE based on its configuration for branch B (unstableThreshold=0).

I've verified that the test output XML files are *not* interfering in between branches. So I'm suspecting some pipeline build global state that xUnit keeps in either a shared object instance or some file?

Here is how that part of our pipeline looks like:
-----
def integrationTestsStage(selectedAgent) {
    def pipelineRunBranches = [:]

    pipelineRunBranches['itests-withEmptyDatabase'] = {
        node(selectedAgent) {
            deleteDir()
            unstash '<stashed-src-code-label>'
            boolean hasException = true
            try {
                sh "maven-build-command"
                hasException = false

            } finally {
                step([$class        : 'XUnitPublisher',
                                                      testTimeMargin: '3000',
                                                      thresholdMode : 1,
                                                      thresholds    : [[$class              : 'FailedThreshold',
                                                                        failureNewThreshold : '0',
                                                                        failureThreshold    : '0',
                                                                        unstableNewThreshold: '0',
                                                                        unstableThreshold   : '0'],
                                                                       [$class              : 'SkippedThreshold',
                                                                        failureNewThreshold : '',
                                                                        failureThreshold    : '',
                                                                        unstableNewThreshold: '',
                                                                        unstableThreshold   : '']],
                                                      tools         : [[$class               : 'JUnitType',
                                                                        deleteOutputFiles    : true,
                                                                        failIfNotNew         : true,
                                                                        pattern              : '<maven-module>/target/failsafe-reports/TEST-*.xml',
                                                                        skipNoTestFiles      : hasException,
                                                                        stopProcessingIfError: true]]
                                                ])

            }
        }
    }

    pipelineRunBranches['itests-withPopulatedDatabase'] = {
        node(selectedAgent) {
            deleteDir()
            unstash '<stashed-src-code-label>'

            try {
                hasException = true
                sh "<maven-build-command>"
                hasException = false

            } finally {
                step([$class        : 'XUnitPublisher',
                      testTimeMargin: '3000',
                      thresholdMode : 1,
                      thresholds    : [[$class              : 'FailedThreshold',
                                        failureNewThreshold : '20',
                                        failureThreshold    : '20',
                                        unstableNewThreshold: '5',
                                        unstableThreshold   : '5'],
                                       [$class              : 'SkippedThreshold',
                                        failureNewThreshold : '',
                                        failureThreshold    : '',
                                        unstableNewThreshold: '',
                                        unstableThreshold   : '']],
                      tools         : [[$class               : 'JUnitType',
                                        deleteOutputFiles    : true,
                                        failIfNotNew         : true,
                                        pattern              : '<maven-module>/target/failsafe-reports/TEST-*.xml',
                                        skipNoTestFiles      : hasException,
                                        stopProcessingIfError: true]]
                ])

            }

        }
    }

    parallel pipelineRunBranches
}


ST

unread,
Jun 10, 2018, 4:40:44 PM6/10/18
to Jenkins Users
Probably same issue as described here: https://issues.jenkins-ci.org/browse/JENKINS-47194 (although we are running xUnit 2.0.0 and still seeing this problem).
Reply all
Reply to author
Forward
0 new messages