Skip to content

Commit

Permalink
[JENKINS-22395] correcting the control test
Browse files Browse the repository at this point in the history
As I step-executed the code, I discovered b2.getPreviousBuild() was getting invoked
between BRHF.drop(b1) and b2.dropLinks() call, in PeepholePermalink.RunListenerImpl.onDeleted()
because Run.delete() calls RunListener.fireDeleted(this).

Thus in effect the sequence of the call order was as follows:

        assertEquals(1, BRHF.drop(b1));
        b2.getPreviousBuild(); // happens indirectly in PeepholePermalink
        b2.delete();
        FreeStyleBuild b1a = b2.getPreviousBuild();

This defeats the purpose of the fix, because in this call sequence, by b2.dropLinks()
as implemented before f1430a2 will correctly fix up b1a.nextBuildR to b3.

For the test to work as intended, it is important that b2.previousBuildR.get()==null
during dropLinks(). That is what causes b2.getPreviousBuild() in the next line to go
load b1a, and sets up b1a.nextBuildR to b2, and trigger the assertion error.

Added a code to remove all RunListeners. With this change, the test now fails without
the fix in f1430a2.

(cherry picked from commit 7b1b50c)
  • Loading branch information
kohsuke authored and olivergondza committed Aug 1, 2014
1 parent 2baa7ca commit 3f03883
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/src/test/java/jenkins/model/lazy/LazyBuildMixInTest.java
Expand Up @@ -30,6 +30,8 @@
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.*;

import hudson.model.listeners.RunListener;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
Expand All @@ -44,6 +46,8 @@ public class LazyBuildMixInTest {

@Bug(22395)
@Test public void dropLinksAfterGC() throws Exception {
RunListener.all().clear(); // see commit message for the discussion

FreeStyleProject p = r.createFreeStyleProject();
FreeStyleBuild b1 = r.buildAndAssertSuccess(p);
FreeStyleBuild b2 = r.buildAndAssertSuccess(p);
Expand All @@ -64,6 +68,8 @@ public class LazyBuildMixInTest {

@Issue("JENKINS-22395")
@Test public void dropLinksAfterGC2() throws Exception {
RunListener.all().clear(); // see commit message for the discussion

FreeStyleProject p = r.createFreeStyleProject();
FreeStyleBuild b1 = r.buildAndAssertSuccess(p);
FreeStyleBuild b2 = r.buildAndAssertSuccess(p);
Expand Down

0 comments on commit 3f03883

Please sign in to comment.