Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-53172] Make sure the reference build is not running #37

Merged
merged 2 commits into from Aug 30, 2018

Conversation

raul-arabaolaza
Copy link
Contributor

JENKINS-53172

The code to choose a previous run as reference is as follows:

private static TestResult findPreviousTestResult(Run<?, ?> b, TaskListener listener) {
        for (int i = 0; i < NUMBER_OF_BUILDS_TO_SEARCH; i++) {// limit the search to a small number to avoid loading too much
            b = b.getPreviousBuild();
            if (b == null) break;
            if(!RESULTS_OF_BUILDS_TO_CONSIDER.contains(b.getResult())) continue;

            AbstractTestResultAction tra = b.getAction(AbstractTestResultAction.class);
            if (tra == null) continue;

            Object o = tra.getResult();
            if (o instanceof TestResult) {
                listener.getLogger().printf("Using build #%d as reference%n", b.getNumber());
                return (TestResult) o;
            }
        }
        return null;    // couldn't find it
    }

Which AFAIUI does not perform any check about the running status of the potential reference run

As per javadoc #getResult alone is not enough guarantee that the run is finished as it can return a value even if the job has not yet finished. And I have found situations where a previous, still running run, is used as the reference. With the consequence of improper parallelization because not all tests have finished (only some of the branches).

This PR updates the aforementioned code to add a check for discarding running jobs as reference, created with the intention of get some feedback as I am still running tests on my instance.

As per javadoc #getResult alone is not enough guarantee
@raul-arabaolaza
Copy link
Contributor Author

All my tests indicate that the problem is not happening again.

@raul-arabaolaza
Copy link
Contributor Author

Pinging @abayer and @jglick as you are the last commiters I can see in the repo

Copy link
Member

@abayer abayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you could add a test too? Thanks!

@raul-arabaolaza
Copy link
Contributor Author

@abayer New test for you to review :)

Copy link
Member

@abayer abayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@abayer abayer merged commit d6b35d1 into jenkinsci:master Aug 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants