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

Documented the RestartableJenkinsRule #7754

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

StefanSpieker
Copy link
Contributor

Documented the RestartableJenkinsRule also created a very small example to showcase how it can be used.

@StefanSpieker StefanSpieker requested a review from a team as a code owner December 15, 2024 10:25
@probot-autolabeler probot-autolabeler bot added the documentation Jenkins documentation, including user and developer docs, solution pages, etc. label Dec 15, 2024
Copy link
Member

@krisstern krisstern left a comment

Choose a reason for hiding this comment

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

Thanks @StefanSpieker for the PR! I have made some minor edit suggestions.

content/doc/developer/testing/index.adoc Outdated Show resolved Hide resolved
content/doc/developer/testing/index.adoc Outdated Show resolved Hide resolved
content/doc/developer/testing/index.adoc Outdated Show resolved Hide resolved
content/doc/developer/testing/index.adoc Outdated Show resolved Hide resolved
content/doc/developer/testing/index.adoc Outdated Show resolved Hide resolved
@StefanSpieker
Copy link
Contributor Author

Thanks for the suggestions, @krisstern !

Copy link
Member

@krisstern krisstern left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@MarkEWaite MarkEWaite left a comment

Choose a reason for hiding this comment

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

Thanks! I like the documentation, but think that the heading should be changed from "Testing Durable Pipeline Steps" to "Testing Jenkins Restart", since the example is showing a test with a FreeStyleProject rather than a Pipeline step.

I don't think we should use RestartableJenkinsRule to test Pipeline steps because the workflow-durable-task-step plugin is no longer using RestartableJenkinsRule. It migrated from RestartableJenkinsRule to JenkinsSessionRule in this pull request:

It added RealJenkinsRule based tests in these pull requests:

I think that documenting RestartableJenkinsRule is great. Thanks for doing it!

If you want to ensure that your plugin behaves correctly after a restart, there are methods to help you.
`RestartableJenkinsRule` is part of the Jenkins testing framework and provides an easy way to simulate restarting Jenkins in your tests without actually having to restart the Jenkins instance.
You can use the `then()` method to run one Jenkins session and then shut down.
The following example shows how it can be used with a `FreeStyleJob` run which is verified after a Jenkins restart:
Copy link
Contributor

Choose a reason for hiding this comment

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

I lack fundamental skills in the use of RestartableJenkinsRule, so I'm not a great reviewer of this pull request. My apologies in advance for mistakes that I may make in the review process.

Since the example uses a FreeStyleProject, I think that the section heading should be changed from "Testing Durable Pipeline Steps" to "Testing Jenkins Restart". The example looks reasonable to me as a way to show that a FreeStyleProject build status persisted across a restart.

I think the job type used in the test should be referenced using the phrase "Freestyle job", the phrase "Freestyle project", or the Java class name "FreeStyleProject". The first two forms are used elsewhere in the www.jenkins.io documentation and the third is used in the example source code.

Suggested change
The following example shows how it can be used with a `FreeStyleJob` run which is verified after a Jenkins restart:
The following example shows how it can be used with a `FreeStyleProject` build which is verified after a Jenkins restart:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Jenkins documentation, including user and developer docs, solution pages, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants