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

Fix opt-in for Maven Failsafe plugin #462

Merged
merged 1 commit into from
Feb 24, 2023
Merged

Fix opt-in for Maven Failsafe plugin #462

merged 1 commit into from
Feb 24, 2023

Conversation

basil
Copy link
Member

@basil basil commented Feb 16, 2023

Fixes #461. PluginWithFailsafeIntegrationTestsHook was meant to be a way for plugins to opt-in to having their Maven Failsafe plugin tests executed, but the class is not marked as abstract. Since

executes all non-abstract hooks, PluginWithFailsafeIntegrationTestsHook gets executed unconditionally, resulting in workarounds like https://github.com/jenkinsci/bom/blob/c72362731c98313189c04025c3b7bc181da4c121/pct.sh#L22-L25. This PR solves the problem by marking PluginWithFailsafeIntegrationTestsHook as abstract, which allows the abovementioned workaround to be removed. That, in turn, exposed the fact that Dr Ullrich Hafner's plugins run their tests using a combination of Surefire and Failsafe, so to ensure the status quo is preserved I added a new hook to explicitly opt in to Failsafe for those plugins. And with that, jenkinsci/bom#1764 now passes.

@basil basil added the bug label Feb 16, 2023
basil added a commit to basil/bom that referenced this pull request Feb 16, 2023
basil added a commit to basil/bom that referenced this pull request Feb 16, 2023
@basil basil requested a review from jtnord February 16, 2023 22:46
@basil basil marked this pull request as ready for review February 16, 2023 22:46
@basil basil requested a review from a team as a code owner February 16, 2023 22:46
Copy link
Member

@jtnord jtnord left a comment

Choose a reason for hiding this comment

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

OK as is - comments for consideration

* Custom execution hook for plugins whose parent is {@code org.jvnet.hudson.plugins:analysis-pom}.
* These plugins use Maven Failsafe Plugin in their test suites.
*/
public class AnalysisPomExecutionHook extends PluginWithFailsafeIntegrationTestsHook {
Copy link
Member

@jtnord jtnord Feb 17, 2023

Choose a reason for hiding this comment

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

CloudBees' has no internal users of PluginWithFailsafeIntegrationTestsHook (nee PluginWithFailsafeIntegrationTestsHook)

And as implemented PluginWithFailsafeIntegrationTestsHook is incorrect as to be generic it should be executing pre-integration-test then integration-test and finally post-integration-test.

the analysis-pom's configuration of failsafe does not follow this generic nature as it is not spinning anything up.

Perhaps it is worth just removing PluginWithFailsafeIntegrationTestsHook and then inlining getGoals here in a way that is specific to Ulli's usage.

Suggested change
public class AnalysisPomExecutionHook extends PluginWithFailsafeIntegrationTestsHook {
public class AnalysisPomExecutionHook extends PluginWithIntegrationTestsHook {

return "io.jenkins.plugins".equals(data.groupId)
&& ARTIFACT_IDS.contains(data.artifactId)
&& "hpi".equals(data.getPackaging());
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
}
}
@Override
public Collection<String> getGoals() {
return List.of("failsafe:integration-test");
}

@basil
Copy link
Member Author

basil commented Feb 24, 2023

I am here to make it better, not to make it perfect. I am not going to do what was suggested.

@basil basil merged commit 2f6e034 into master Feb 24, 2023
@basil basil deleted the failsafe branch February 24, 2023 18:15
basil added a commit to basil/bom that referenced this pull request Feb 27, 2023
timja pushed a commit to jenkinsci/bom that referenced this pull request Feb 27, 2023
lemeurherve pushed a commit to lemeurherve/bom that referenced this pull request Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opt-in for Maven Failsafe plugin is broken
3 participants