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.

(cherry picked from commit 61cf2df)
  • Loading branch information
kohsuke authored and olivergondza committed Dec 8, 2013
1 parent 774c54a commit 8c8102e
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;

/**
* @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()
}
}

0 comments on commit 8c8102e

Please sign in to comment.