Skip to content

Commit 2aa11eb

Browse files
committed
jenkinsci/jenkins-test-harness#583 makes PreserveStashesJobPropertyLoadTest much more precise
1 parent 0996af3 commit 2aa11eb

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/properties/PreserveStashesJobPropertyLoadTest.java

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,18 @@ public void evaluate() throws Throwable {
6767
public void evaluate() throws Throwable {
6868
WorkflowJob p = (WorkflowJob)story.j.jenkins.getItem("stashWithLoadCount");
6969
assertNotNull(p);
70-
RunLoadCounter.prepare(p);
7170

72-
// PreserveStashesJobProperty.StashClearingListener and .SaveStashes shouldn't trigger a full load.
73-
assertEquals(0, RunLoadCounter.countLoads(p, new Runnable() {
74-
@Override
75-
public void run() {
76-
try {
77-
story.j.buildAndAssertSuccess(p);
78-
} catch (Exception e) {
79-
// This will never happen.
80-
assert false;
81-
}
82-
}
83-
}));
71+
RunLoadCounter.assertMaxLoads(p, /* TODO 2.407+ should be just 1 */4, () -> {
72+
// The last build will get loaded via Queue.maintain as shown in https://github.com/jenkinsci/jenkins/pull/7998 anyway:
73+
assertEquals(10, p.getLastBuild().getNumber());
74+
// (until 2.407+, so will #7, #8, and #9, for a total of 4 loaded builds)
75+
// PreserveStashesJobProperty.StashClearingListener and .SaveStashes shouldn't trigger a full load.
76+
return story.j.buildAndAssertSuccess(p);
77+
});
8478

85-
// This is here largely to demonstrate that we do still do loads. We're using countLoads so as not to
86-
// blow up later when we check stashes.
87-
assertEquals(1, RunLoadCounter.countLoads(p, new Runnable() {
88-
@Override
89-
public void run() {
90-
p.getLastFailedBuild().getNumber();
91-
}
79+
// This is here largely to demonstrate that we do still do loads.
80+
assertEquals(1, RunLoadCounter.countLoads(p, () -> {
81+
assertEquals(7, p.getLastFailedBuild().getNumber());
9282
}));
9383

9484
// The first nine builds shouldn't have stashes any more.

0 commit comments

Comments
 (0)