-
Notifications
You must be signed in to change notification settings - Fork 129
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
Provide JenkinsRule.restart()
implementation
#716
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 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
strangelookingnerd
force-pushed
the
feature/provide_restart_for_jenkins_rule
branch
from
January 17, 2024 17:20
3b50059
to
3488f8d
Compare
strangelookingnerd
force-pushed
the
feature/provide_restart_for_jenkins_rule
branch
from
April 11, 2024 13:19
3488f8d
to
ba496ee
Compare
strangelookingnerd
force-pushed
the
feature/provide_restart_for_jenkins_rule
branch
from
April 17, 2024 16:36
ba496ee
to
a53638d
Compare
timja
reviewed
Jan 8, 2025
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
strangelookingnerd
force-pushed
the
feature/provide_restart_for_jenkins_rule
branch
from
January 8, 2025 15:53
60664c5
to
1b207e2
Compare
timja
approved these changes
Jan 8, 2025
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
strangelookingnerd
deleted the
feature/provide_restart_for_jenkins_rule
branch
January 9, 2025 10:03
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
RestartableJenkinsRule
orJenkinsSessionRule
for 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
RestartableJenkinsRule
orJenkinsSessionRule
I opted for an extension toJenkinsRule
by 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_HOME
and 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
RestartableJenkinsRule
orJenkinsSessionRule
in 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.JUnit5JenkinsRule
because I found them useful to have.Submitter checklist