Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Reproduced the problem. Workspace is getting released prematurely, before publishers run. This has all sorts of serious problems.
  • Loading branch information
kohsuke committed Nov 8, 2013
1 parent 7648a95 commit 61cf2df
Showing 1 changed file with 51 additions and 4 deletions.
55 changes: 51 additions & 4 deletions test/src/test/groovy/hudson/model/AbstractProjectTest.groovy
Expand Up @@ -28,8 +28,11 @@ import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.WebRequestSettings
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import hudson.security.*;
import hudson.tasks.BuildTrigger;
import hudson.security.*
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.BuildTrigger
import hudson.tasks.Publisher
import hudson.tasks.Recorder;
import hudson.tasks.Shell;
import hudson.scm.NullSCM;
import hudson.Launcher;
Expand All @@ -47,13 +50,16 @@ import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;
import org.jvnet.hudson.test.HudsonTestCase
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.MemoryAssert;
import org.jvnet.hudson.test.MemoryAssert
import org.jvnet.hudson.test.SequenceLock;
import org.jvnet.hudson.test.recipes.PresetData;
import org.jvnet.hudson.test.recipes.PresetData.DataSet
import org.apache.commons.io.FileUtils;
import java.lang.ref.WeakReference

import org.jvnet.hudson.test.MockFolder;
import org.jvnet.hudson.test.MockFolder

import java.util.concurrent.Phaser;

This comment has been minimized.

Copy link
@mrebasti

mrebasti Nov 11, 2013

Contributor

@kohsuke java.util.concurrent.Phaser was added in JDK 1.7, I think the builds are failing for that. As far I can see, this class isn't being used, and we can delete the import to solve the problem.

This comment has been minimized.

Copy link
@olivergondza

olivergondza Nov 11, 2013

Member

Just hit this one. Narrowed in ebeda2a.

This comment has been minimized.

Copy link
@jglick

jglick Nov 11, 2013

Member

@kohsuke please use the validated merge repo to avoid that kind of build breakage.

This comment has been minimized.

Copy link
@kohsuke

kohsuke Nov 11, 2013

Author Member

Oops


/**
* @author Kohsuke Kawaguchi
Expand Down Expand Up @@ -483,4 +489,45 @@ public class AbstractProjectTest extends HudsonTestCase {
def t = j.triggers()[1]
assert t == newTrigger
}

@Bug(10615)
public void testWorkspaceLock() {
def p = createFreeStyleProject()
p.concurrentBuild = true;
def e1 = new OneShotEvent(), e2=new OneShotEvent()
def done = new OneShotEvent()

p.publishersList.add(new Recorder() {
BuildStepMonitor getRequiredMonitorService() {
return BuildStepMonitor.NONE;
}

@Override
boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
if (build.number==1) {
e1.signal(); // signal that build #1 is in publisher
} else {
assert build.number==2;
e2.signal()
}

done.block()

return true;
}
private Object writeReplace() { return new Object(); }
})

def b1 = p.scheduleBuild2(0)
e1.block()

def b2 = p.scheduleBuild2(0)
e2.block()

// at this point both builds are in the publisher, so we verify that
// the workspace are differently allocated
assert b1.startCondition.get().workspace!=b2.startCondition.get().workspace

done.signal()
}
}

1 comment on commit 61cf2df

@jglick
Copy link
Member

@jglick jglick commented on 61cf2df Dec 11, 2013

Choose a reason for hiding this comment

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

This test fails often.

Please sign in to comment.