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
[FIXED JENKINS-34722] Performance improvement to not load all jobs #100
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,9 @@ | |
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.jvnet.hudson.test.HudsonTestCase; | ||
import org.jvnet.hudson.test.RunLoadCounter; | ||
|
||
import java.util.concurrent.Callable; | ||
|
||
public class BuildUtilTest extends HudsonTestCase { | ||
|
||
|
@@ -47,6 +50,40 @@ public void setUp() throws Exception { | |
super.setUp(); | ||
} | ||
|
||
@Test | ||
public void testGetDownstreamBuildWithLimit() throws Exception { | ||
int max_upstream_depth = 3; | ||
int total_proj2_builds = 5; | ||
System.setProperty(BuildUtil.class.getCanonicalName() + ".MAX_DOWNSTREAM_DEPTH", String.valueOf(max_upstream_depth)); | ||
|
||
final FreeStyleProject proj1 = createFreeStyleProject(); | ||
final FreeStyleProject proj2 = createFreeStyleProject(); | ||
|
||
|
||
final FreeStyleBuild freeStyleBuild = proj1.scheduleBuild2(0).get(); | ||
assertBuildStatusSuccess(freeStyleBuild); | ||
|
||
proj1.getPublishersList().add(new BuildTrigger(proj2.getName(), true)); | ||
|
||
jenkins.rebuildDependencyGraph(); | ||
|
||
// Schedule a build 10 times | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🐜 this comment is incorrect. It is 5, not 10. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
for (int i = 0; i < total_proj2_builds; i++) { | ||
assertBuildStatusSuccess(proj1.scheduleBuild2(0)); | ||
waitUntilNoActivity(); | ||
} | ||
assertEquals("Proj2 does not have the correct number of builds.", total_proj2_builds + 1, proj2.getNextBuildNumber()); | ||
RunLoadCounter.prepare(proj2); | ||
|
||
assertFalse(RunLoadCounter.assertMaxLoads(proj2, max_upstream_depth - 1, new Callable<Boolean>() { | ||
@Override | ||
public Boolean call() throws Exception { | ||
return BuildUtil.getDownstreamBuild(proj2, freeStyleBuild) != null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Easier to understand assertNull(RunLoadCounter.assertMaxLoads(proj2, max_upstream_depth - 1, new Callable<AbstractBuild<?,?>>() {
@Override
public AbstractBuild<?,?> call() throws Exception {
return BuildUtil.getDownstreamBuild(proj2, freeStyleBuild);
}
})); |
||
} | ||
})); | ||
} | ||
|
||
|
||
@Test | ||
public void testGetDownstreamBuild() throws Exception { | ||
final String proj1 = "Proj1"; | ||
|
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.
BTW we typically discourage star imports.
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.
In fact Checkstyle is failing the build in this case.