Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #33 from jenkinsci/JENKINS-26137-no-pickle-factories
Make a test involving Jenkins restart pass
  • Loading branch information
jglick committed Jan 14, 2015
2 parents dd5eaf7 + ddeceed commit 9186a51
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Expand Up @@ -28,7 +28,6 @@
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.Rule;
import org.junit.runners.model.Statement;
Expand All @@ -48,7 +47,6 @@ public class PushdStepTest {
});
}

@Ignore("TODO as per JENKINS-26149 PushdStep.Execution.step might need to be optional=true, but cannot get this test to pass because of JENKINS-26137")
@Test public void restarting() {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
Expand All @@ -62,6 +60,9 @@ public class PushdStepTest {
@Override public void evaluate() throws Throwable {
SemaphoreStep.success("restarting/1", null);
WorkflowRun b = story.j.jenkins.getItemByFullName("p", WorkflowJob.class).getLastBuild();
while (b.isBuilding()) { // TODO JENKINS-26399
Thread.sleep(100);
}
story.j.assertLogContains("/subdir", story.j.assertBuildStatusSuccess(b));
}
});
Expand Down
Expand Up @@ -79,7 +79,7 @@ public Set<Class<?>> getProvidedContext() {

public static class Execution extends AbstractStepExecutionImpl {

@Inject private transient PushdStep step;
@Inject private transient PushdStep step; // TODO should this be marked optional=true?
@StepContextParameter private transient TaskListener listener;
@StepContextParameter private transient FilePath cwd;
private BodyExecution body;
Expand Down
Expand Up @@ -28,6 +28,7 @@
import org.jenkinsci.plugins.workflow.pickles.Pickle;
import org.jenkinsci.plugins.workflow.pickles.PickleFactory;
import com.trilead.ssh2.util.IOUtils;
import hudson.ExtensionList;
import org.jboss.marshalling.Marshaller;
import org.jboss.marshalling.Marshalling;
import org.jboss.marshalling.MarshallingConfiguration;
Expand Down Expand Up @@ -87,6 +88,10 @@ public class RiverWriter implements Closeable {

// TODO: rename to HibernatingObjectOutputStream?
public RiverWriter(File f, FlowExecutionOwner _owner) throws IOException {
final ExtensionList<PickleFactory> pickleFactories = PickleFactory.all();
if (pickleFactories.isEmpty()) {
throw new IllegalStateException("JENKINS-26137: Jenkins is shutting down");
}
file = f;
owner = _owner;
dout = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
Expand All @@ -107,7 +112,7 @@ public Object writeReplace(Object o) {
return new DryOwner();

if (pickling) {
for (PickleFactory f : PickleFactory.all()) {
for (PickleFactory f : pickleFactories) {
Pickle v = f.writeReplace(o);
if (v != null) {
pickles.add(v);
Expand Down

0 comments on commit 9186a51

Please sign in to comment.