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

Add test for Sorter strategy #439

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

Conversation

yashpal2104
Copy link
Contributor

Testing done

  • Add test for SorterStrategy class
  • Refactor the onCanceledItem method to invoke item.isCancelled for test

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did

@github-actions github-actions bot added the tests Automated test addition or improvement label Jan 11, 2025
Refactored the onCanceledItem method to invoke item.isCancelled for test
@yashpal2104
Copy link
Contributor Author

yashpal2104 commented Jan 11, 2025

@MarkEWaite do let me know about the changes I made. Are they viable or not

@MarkEWaite MarkEWaite changed the title Add test for Sorter strategy test Add test for Sorter strategy Jan 11, 2025
@MarkEWaite
Copy link
Contributor

As a general pattern, most Jenkins plugin maintainers don't review draft pull requests. A pull request is usually marked as draft by the submitter because they are not ready for review.

Since you asked for my feedback, I checked the CI job. There is a spotbugs warning. You need to fix the spotbus warning before I'll spend time reviewing the pull request in any other way.

@yashpal2104 yashpal2104 marked this pull request as ready for review January 11, 2025 13:55
@yashpal2104 yashpal2104 requested a review from a team as a code owner January 11, 2025 13:55
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.

Needs fixes as noted in the comments. Needs more review after those fixes are applied.

@@ -23,7 +23,10 @@
*/
package jenkins.advancedqueue.sorter;

import static org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.LOGGER;
Copy link
Contributor

Choose a reason for hiding this comment

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

Using the logger from a class that is outside this plugin is not the way to add logging to a class. Refer to src/main/java/jenkins/advancedqueue/PriorityConfiguration.java for the technique that is used to add a logger to a class.

Suggested change
import static org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.LOGGER;

@@ -66,7 +69,12 @@ public void onStartedItem(@NonNull LeftItem item, float weight) {}
/**
* Called when a {@link hudson.model.Item} leaves the queue and it is canceled.
*/
public void onCanceledItem(@NonNull LeftItem item) {}
@CheckReturnValue
Copy link
Contributor

Choose a reason for hiding this comment

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

The CheckReturnValue javadoc says:

This annotation is used to denote a method whose return value should always be checked when invoking the method.

Since the method is void, it has no return value. That seems like the wrong annotation for the method

-Corrected the annotation method for void method and deleted @checkfornull
-Imported Logger from the same plugin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Automated test addition or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants