-
-
Notifications
You must be signed in to change notification settings - Fork 134
Provide JenkinsRule.restart() implementation
#716
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
Merged
timja
merged 8 commits into
jenkinsci:master
from
strangelookingnerd:feature/provide_restart_for_jenkins_rule
Jan 8, 2025
Merged
Provide JenkinsRule.restart() implementation
#716
timja
merged 8 commits into
jenkinsci:master
from
strangelookingnerd:feature/provide_restart_for_jenkins_rule
Jan 8, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timja
reviewed
Jan 8, 2025
Member
timja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, a few questions
src/test/java/org/jvnet/hudson/test/junit/jupiter/JenkinsRuleClassResolverTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/jvnet/hudson/test/junit/jupiter/JenkinsRuleResolverTest.java
Outdated
Show resolved
Hide resolved
timja
approved these changes
Jan 8, 2025
Member
timja
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
6 tasks
6 tasks
6 tasks
6 tasks
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Thanks to #438 there is now support for JUnit5. However there are still some open points or missing features from JUnit4 evolving around
JenkinsRule.Problem
While trying to upgrade the plugin archetypes to use JUnit5 (jenkinsci/archetypes#691) I encountered one of these open points: Right now there is no implementation that resembles
RestartableJenkinsRuleorJenkinsSessionRulefor JUnit5.After giving it a try myself to get such an implementation going I quickly found that it will likely require a huge portion of refactoring and changing behavior of
JenkinsRule/JUnit5JenkinsRule.Even though I do think that at some point one might need to bite the bullet and fully re-write most of the implementation for JUnit5 and dropping support for JUnit4 - this is not my decision to make and more importantly I would not want to jump onto that unless that decision is made beforehand 😄
Solution
Anyways, since I still wanted to find some equivalent for
RestartableJenkinsRuleorJenkinsSessionRuleI opted for an extension toJenkinsRuleby providingJenkinsRule.restart(). This method basically does the same as the JUnit4 rules but is agnostic to the JUnit version being used.Summed up shorty it creates a backup of the
JENKINS_HOMEand restarts the underlying Jenkins instance by runningJenkinsRule.after()andJenkinsRule.before()with the backup as home. The port remains unchanged.From what I can tell this method could be used in favor of
RestartableJenkinsRuleorJenkinsSessionRulein most of the existing test cases:This would allow these projects to migrate to JUnit5 eventually without any downside and would open up the way to deprecate / discontinue the usage of JUnit4 in
jenkinsci.@basil: FYI
Testing done
JenkinsRule.restart()works for JUnit4 as well as JUnit5.JUnit5JenkinsRulebecause I found them useful to have.