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-2 part of JENKINS-29649 + Fixed JENKINS-37623, JENKINS-38149 #14

Merged
merged 8 commits into from
Nov 29, 2016

Conversation

anenviousguest
Copy link

@anenviousguest anenviousguest commented Aug 23, 2016

Hi @kinow

Thanks for merging #13. Turns out there was missing part there, namely the fix for Jenkins 2 workflow jobs. Would appreciate if you could review it.

Also i put in here the fix for JENKINS-37623 , as the it and the change above modify same file.

TL;DR

For Jenkins 2 workflow jobs, it might happen that JUnit and TAP publishers wrongly use TAP-only (or JUnit-only) results to draw their graphs. Added test case to detect that.

Also, when build history contained runs which failed before any TAP results were published, NullPointerException was occurring during the tooltip generation. The graph was still rendered, but the image map was missing.

Why it happens (JENKINS-29649 part)

In JUnit's code inside TestResultProjectAction, they try to fetch last test result action of specific type before drawing a plot:

As one may see here: https://github.com/jenkinsci/junit-plugin/blob/master/src/main/java/hudson/tasks/test/TestResultProjectAction.java#L93 - the action they search for is supposed to be inherited from AbstractTestResultAction.

And because TapTestResultAction is also derived from AbstractTestResultAction, it may (depending on the action order) be unexpectedly used to plot JUnit graphs, too. Vice versa might also be the case.

This PR's content

  1. The fix for Jenkins-2 part of JENKINS-29649 + test case which is red when fix is not applied. I basically decoupled TapTestResultAction from JUnit and migrated it and its surroundings to use generic Run instead of AbstractProject.
  2. The fix for JENKINS-37623 + test case which is red when fix is not applied.
  3. Because of the test cases above, I had to add test dependency and increase the minimum Jenkins version plugin is built against (still Jenkins 1.xxx though).
  4. The new Jenkins parent seem to bring in InjectedTest which performs basic lint checks on *.jelly files. Had to add Jelly escaping directive to make this test happy.
  5. Few IDE warnings fixed.

@kinow
Copy link
Member

kinow commented Aug 23, 2016

👍 thanks @anenviousguest will need a few days, as I'm going through a few other plug-ins and pull requests to cut more releases. Feel free to update the pull request in the meantime.

@anenviousguest anenviousguest changed the title Jenkins-2 part of JENKINS-29649. JUnit and TAP publishers were impacting each other on Jenkins 2 workflow job page Jenkins-2 part of JENKINS-29649 + Fixed JENKINS-37623 Aug 23, 2016
@anenviousguest
Copy link
Author

hi @kinow
Have you by any chance had a time to look at this PR? Would very much appreciate if you could give your feedback or merge it.
Thanks!

@anenviousguest
Copy link
Author

hi Bruno @kinow
Let me kindly bump the thread here. Would that be reasonable to assume that you would have time to review this in a foreseeable future?
Thanks!

@kinow
Copy link
Member

kinow commented Sep 7, 2016

Hi @anenviousguest

Ack :-) Promise that as soon as I'm done with https://github.com/jenkinsci/tap-plugin/tree/performance-fix for the performance issues.

Normally I make little progress, and proceed with other issues. But this time I really want to fix these performance issues. Once it's done, will continue merging the other PR's and working on issues. Yours will be the first PR that I will look into, and with RERO motto in mind, we might have it released shortly after the PR has been merged.

Sorry for the delay

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Generally the code should address the issue. There are several improvement areas, minor fixes are required.

I would also recommend to bump major version of the plugin since there are incompatible changes.

CC @olofk, whose issue will be likely solved by this pull request

@@ -20,7 +20,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.580.3</version><!-- which version of Jenkins is this plugin
<version>1.637</version><!-- which version of Jenkins is this plugin
Copy link
Member

Choose a reason for hiding this comment

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

🐜 for selecting non-LTS version.
What was the reason for it?

Copy link
Author

Choose a reason for hiding this comment

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

addressed.

@@ -47,26 +50,31 @@
* @since 0.1
*/
public class TapTestResultAction
extends AbstractTestResultAction<AbstractTestResultAction<?>>
implements StaplerProxy, SimpleBuildStep.LastBuildAction {
implements StaplerProxy, SimpleBuildStep.LastBuildAction, HealthReportingAction, RunAction2 {
Copy link
Member

Choose a reason for hiding this comment

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

Removal of AbstractTestResultAction inheritance smells like a compatibility issue, but seems it's reasonable in this case

Copy link
Author

@anenviousguest anenviousguest Sep 20, 2016

Choose a reason for hiding this comment

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

was exactly causing the issue, please see "Why it happens (JENKINS-29649 part)" in the description above.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I understand why this change is required. The problem is that...

  • The class cannot be longer casted to AbstractTestResultAction
  • Usage of non-implemented methods from AbstractTestResultAction will cause LinkageError. E.g. findPreviousCorresponding()

So I would vouch for keeping AbstractTestResultAction inheritance. If you update JUnit plugin dependency to the latest version (1.18), you may see it's interfaces have been adapted to make this class compatible with Pipeline Plugin

Copy link
Author

Choose a reason for hiding this comment

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

hi @oleg-nenashev ,
I've just tested, and upgrading to junit-plugin 1.18 doesn't fix JENKINS-29649 in this plugin.

Everything described in the "why it happens..." at the very beginning of this PR is still relevant to version 1.18.

That is, when a build contains multiple test result actions derived from AbstractTestResultAction, the return value of TestResultProjectAction.getLastTestResultAction, as seen here may depend on the order in which actions were saved, because it searches for actions of a base class.

Consequently, here and here wrong action might be used to draw the graph.


public transient Run<?,?> run;
@Deprecated
public transient AbstractBuild<?,?> owner;
Copy link
Member

Choose a reason for hiding this comment

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

Well, the binary compatibility is broken in any case

Copy link
Author

@anenviousguest anenviousguest Sep 20, 2016

Choose a reason for hiding this comment

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

why? these have already been there, just inherited from AbstractTestResultAction. Now that it was removed from inheritance hierarchy, i placed these fields right here.

Copy link
Member

Choose a reason for hiding this comment

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

see above

/**
* @param owner
* @param r
Copy link
Member

Choose a reason for hiding this comment

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

🐛 It changes param name to the invalid one.
Having of param declarations without description is also a bad practice. Javadoc linter in Java8 will grumble about that.

Copy link
Author

Choose a reason for hiding this comment

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

addressed

@Override
@Exported(visibility = 2)
public int getTotalCount() {
Copy link
Member

Choose a reason for hiding this comment

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

Binary compat as well

Copy link
Author

@anenviousguest anenviousguest Sep 20, 2016

Choose a reason for hiding this comment

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

i guess it's a diff display issue. The lines highlighted were in the unused descendant class.
getTotalCount is still there in TapTestResultAction

*
* @return associated TAP test result action object
*/
private TapTestResultAction getTestResultActionDiverged() {
Copy link
Member

Choose a reason for hiding this comment

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

Good practice: CheckForNull annotation

Copy link
Author

Choose a reason for hiding this comment

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

addressed

@oleg-nenashev
Copy link
Member

The PR also addresses JENKINS-38149

@oleg-nenashev oleg-nenashev changed the title Jenkins-2 part of JENKINS-29649 + Fixed JENKINS-37623 Jenkins-2 part of JENKINS-29649 + Fixed JENKINS-37623, JENKINS-38149 Sep 19, 2016
@anenviousguest
Copy link
Author

@oleg-nenashev thanks for reviewing this. I'll try to accomodate changes where it deems reasonable.

* Addressing wrong parameter name in Javadoc.
* @checkfornull usage.
* Depending on LTS parent version in pom.xml
Copy link
Author

@anenviousguest anenviousguest left a comment

Choose a reason for hiding this comment

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

@oleg-nenashev Thanks for review.

I guess i've addressed all the points, please see comments.

In particular, i think binary compatibility is preserved.

@Override
@Exported(visibility = 2)
public int getTotalCount() {
Copy link
Author

@anenviousguest anenviousguest Sep 20, 2016

Choose a reason for hiding this comment

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

i guess it's a diff display issue. The lines highlighted were in the unused descendant class.
getTotalCount is still there in TapTestResultAction

*
* @return associated TAP test result action object
*/
private TapTestResultAction getTestResultActionDiverged() {
Copy link
Author

Choose a reason for hiding this comment

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

addressed

@@ -47,26 +50,31 @@
* @since 0.1
*/
public class TapTestResultAction
extends AbstractTestResultAction<AbstractTestResultAction<?>>
implements StaplerProxy, SimpleBuildStep.LastBuildAction {
implements StaplerProxy, SimpleBuildStep.LastBuildAction, HealthReportingAction, RunAction2 {
Copy link
Author

@anenviousguest anenviousguest Sep 20, 2016

Choose a reason for hiding this comment

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

was exactly causing the issue, please see "Why it happens (JENKINS-29649 part)" in the description above.


public transient Run<?,?> run;
@Deprecated
public transient AbstractBuild<?,?> owner;
Copy link
Author

@anenviousguest anenviousguest Sep 20, 2016

Choose a reason for hiding this comment

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

why? these have already been there, just inherited from AbstractTestResultAction. Now that it was removed from inheritance hierarchy, i placed these fields right here.

/**
* @param owner
* @param r
Copy link
Author

Choose a reason for hiding this comment

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

addressed

@@ -20,7 +20,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.580.3</version><!-- which version of Jenkins is this plugin
<version>1.637</version><!-- which version of Jenkins is this plugin
Copy link
Author

Choose a reason for hiding this comment

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

addressed.

@anenviousguest
Copy link
Author

@kinow @oleg-nenashev does that look better now? Thanks.

@oleg-nenashev
Copy link
Member

@anenviousguest Provided feedback. I think that the inheritance from AbstractTestResultAction should be retained. Upgrade to one of the latest JUnit plugin versions should help with it

@anenviousguest
Copy link
Author

@oleg-nenashev thanks! See my reply in the above thread.

@oleg-nenashev
Copy link
Member

Well, we need to think about potential solutions. Now particular Jenkins features may stop working for TAP Plugin (e.g. aggregation of downstream test results in Freestyle jobs).

P.S: We've tested the change on a Pipeline-only instance, and the plugin is working as we need with this patch.

@kinow
Copy link
Member

kinow commented Sep 23, 2016

Will try to catch up with the review/comments this weekend :)

@anenviousguest
Copy link
Author

Hi @oleg-nenashev

I'm struggling to find any immediate elegant solution to work around this check in junit-plugin.

I have no idea if JUnit plugin was meant to provide a base API for test-alike plugins, but if it was, it's probably better to think of fixing the check on its side, in a long term.

@oleg-nenashev
Copy link
Member

Yes, I should have read the text carefully from the beginning.

The JUnit Issue

I have no idea if JUnit plugin was meant to provide a base API for test-alike plugins, but if it was, it's probably better to think of fixing the check on its side, in a long term.

JUnit plugin has been decoupled from the Jenkins core at some point. So yes, it's actually a kind of API plugin for all test results then just a JUnit plugin.

And because TapTestResultAction is also derived from AbstractTestResultAction, it may (depending on the action order) be unexpectedly used to plot JUnit graphs, too. Vice versa might also be the case.

It is a case.

How to solve it?

Well, it should be solved on the JUnit plugin level. Just because of that: https://github.com/search?q=org%3Ajenkinsci+%22extends+AbstractTestResultAction%22&type=Code

I would just ignore this issue by now. I'll see if I can fix it on the JUnit plugin side by merging results in the plot (or by filtering them)

@anenviousguest
Copy link
Author

hi @oleg-nenashev

I guess i know what type of fix it might be on junit-plugin side. Should I just submit a PR there and if it's merged, revise this one?

Thanks.

@oleg-nenashev
Copy link
Member

@anenviousguest Up to you. I think we can go forward with this PR even without waiting for JUnit stuff to be integrated and released

@alappe
Copy link

alappe commented Oct 31, 2016

Any news here? A fix would be deeply appreciated…

@kinow
Copy link
Member

kinow commented Oct 31, 2016

@alappe lurking in the discussion between @oleg-nenashev and @anenviousguest :-) happy to review/merge whenever they confirm it's ready

@oleg-nenashev
Copy link
Member

I think it's ready. The fix is required on the JUnit plugin. Merge of this PR does not increase the technical debt

@kinow
Copy link
Member

kinow commented Oct 31, 2016

Can we release after merging it @oleg-nenashev ? Or would it be necessary to wait for a merge and release in JUnit plugin first?

@oleg-nenashev
Copy link
Member

no need in waiting for JUnit plugin IMHO. Just 🚢 🇮🇹 :)

@mkhan446
Copy link

Any updates on this pull request? I'm encountering JENKINS-38149 and would love to have it resolved... :)

@kinow
Copy link
Member

kinow commented Nov 28, 2016

Sorry @mkhan446 got a bit busy with active-choices-plugin, had to digress for a while, but also want to get this merged and released soon. Just give me a few more days and I will sort out and prepare a release to the experimental update center, so others can test it.

@anenviousguest
Copy link
Author

@oleg-nenashev : thanks!
@kinow : i would very much appreciate if you could merge this, indeed :-) I've been running this fix over the past few months, and it seems to be working, just like @oleg-nenashev mentioned above, too.
Thanks guys for your cooperation!

@kinow
Copy link
Member

kinow commented Nov 29, 2016

Merged. Merge conflicts fixed manually, and all tests passed after that as well. Re-read the issue history, and the only concern is regarding previous behavior that may change after this change. Will push to experimental update center in a few minutes for now, and will play with the new plug-in before cutting a release, likely by the mid or end of December. Any feedback from the version in the experimental update center will definitely help! Thanks @anenviousguest and @oleg-nenashev !

@jglick
Copy link
Member

jglick commented Dec 5, 2016

@kinow please also amend jenkinsci/pipeline-plugin#403 to indicate the status of the release (fix version).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants