-
Notifications
You must be signed in to change notification settings - Fork 75
Revert fixes related to JENKINS-67351 and JENKINS-67164 #198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a384598
Revert "[JENKINS-67351] Avoid deadlock when resuming Pipelines in som…
dwnusbaum ca655cf
Revert "[JENKINS-40161] Handle exceptions from `StepExecution.onResum…
dwnusbaum fd1ae7f
Revert "[JENKINS-67164] Call StepExecution.onResume directly from Wor…
dwnusbaum 3ce403f
Preserve FlowExecutionList.isResumption for binary compatibility
dwnusbaum fa07adf
Preserve minor changes that removed Guice and JSR-305 annotations
dwnusbaum d923637
Preserve explanatory comment and minor change to log message
dwnusbaum 92aa05c
Preserve NonNull annotations
dwnusbaum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,44 +24,24 @@ | |
|
||
package org.jenkinsci.plugins.workflow.flow; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.hasItem; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import hudson.AbortException; | ||
import hudson.model.ParametersAction; | ||
import hudson.model.ParametersDefinitionProperty; | ||
import hudson.model.Result; | ||
import hudson.model.StringParameterDefinition; | ||
import hudson.model.StringParameterValue; | ||
import hudson.model.TaskListener; | ||
import hudson.model.queue.QueueTaskFuture; | ||
import java.io.Serializable; | ||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.util.Collections; | ||
import java.util.Set; | ||
import java.util.function.Supplier; | ||
import java.util.logging.Level; | ||
import org.hamcrest.Matcher; | ||
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowJob; | ||
import org.jenkinsci.plugins.workflow.job.WorkflowRun; | ||
import org.jenkinsci.plugins.workflow.steps.Step; | ||
import org.jenkinsci.plugins.workflow.steps.StepContext; | ||
import org.jenkinsci.plugins.workflow.steps.StepDescriptor; | ||
import org.jenkinsci.plugins.workflow.steps.StepExecution; | ||
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.Rule; | ||
import org.jvnet.hudson.test.BuildWatcher; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.LoggerRule; | ||
import org.jvnet.hudson.test.JenkinsSessionRule; | ||
import org.jvnet.hudson.test.TestExtension; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
public class FlowExecutionListTest { | ||
|
||
|
@@ -99,113 +79,4 @@ public class FlowExecutionListTest { | |
}); | ||
} | ||
|
||
@Test public void forceLoadRunningExecutionsAfterRestart() throws Throwable { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or just |
||
logging.capture(50); | ||
sessions.then(r -> { | ||
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); | ||
p.setDefinition(new CpsFlowDefinition("semaphore('wait')", true)); | ||
WorkflowRun b = p.scheduleBuild2(0).waitForStart(); | ||
SemaphoreStep.waitForStart("wait/1", b); | ||
}); | ||
sessions.then(r -> { | ||
/* | ||
Make sure that the build gets loaded automatically by FlowExecutionList$ItemListenerImpl before we load it explictly. | ||
Expected call stack for resuming a Pipelines and its steps: | ||
at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ResumeStepExecutionListener$1.onSuccess(FlowExecutionList.java:250) | ||
at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ResumeStepExecutionListener$1.onSuccess(FlowExecutionList.java:247) | ||
at com.google.common.util.concurrent.Futures$6.run(Futures.java:975) | ||
at org.jenkinsci.plugins.workflow.flow.DirectExecutor.execute(DirectExecutor.java:33) | ||
... Guava Futures API internals ... | ||
at com.google.common.util.concurrent.Futures.addCallback(Futures.java:985) | ||
at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ResumeStepExecutionListener.onResumed(FlowExecutionList.java:247) | ||
at org.jenkinsci.plugins.workflow.flow.FlowExecutionListener.fireResumed(FlowExecutionListener.java:84) | ||
at org.jenkinsci.plugins.workflow.job.WorkflowRun.onLoad(WorkflowRun.java:528) | ||
at hudson.model.RunMap.retrieve(RunMap.java:225) | ||
... RunMap internals ... | ||
at hudson.model.RunMap.getById(RunMap.java:205) | ||
at org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner.run(WorkflowRun.java:937) | ||
at org.jenkinsci.plugins.workflow.job.WorkflowRun$Owner.get(WorkflowRun.java:948) | ||
at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$1.computeNext(FlowExecutionList.java:65) | ||
at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$1.computeNext(FlowExecutionList.java:57) | ||
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:143) | ||
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:138) | ||
at org.jenkinsci.plugins.workflow.flow.FlowExecutionList$ItemListenerImpl.onLoaded(FlowExecutionList.java:175) | ||
at jenkins.model.Jenkins.<init>(Jenkins.java:1019) | ||
*/ | ||
waitFor(logging::getMessages, hasItem(containsString("Will resume [org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep"))); | ||
WorkflowJob p = r.jenkins.getItemByFullName("p", WorkflowJob.class); | ||
SemaphoreStep.success("wait/1", null); | ||
WorkflowRun b = p.getBuildByNumber(1); | ||
r.waitForCompletion(b); | ||
r.assertBuildStatus(Result.SUCCESS, b); | ||
}); | ||
} | ||
|
||
@Issue("JENKINS-67164") | ||
@Test public void resumeStepExecutions() throws Throwable { | ||
sessions.then(r -> { | ||
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p"); | ||
p.setDefinition(new CpsFlowDefinition("noResume()", true)); | ||
WorkflowRun b = p.scheduleBuild2(0).waitForStart(); | ||
r.waitForMessage("Starting non-resumable step", b); | ||
// TODO: Unclear how this might happen in practice. | ||
FlowExecutionList.get().unregister(b.asFlowExecutionOwner()); | ||
}); | ||
sessions.then(r -> { | ||
WorkflowJob p = r.jenkins.getItemByFullName("p", WorkflowJob.class); | ||
WorkflowRun b = p.getBuildByNumber(1); | ||
r.waitForCompletion(b); | ||
r.assertBuildStatus(Result.FAILURE, b); | ||
r.assertLogContains("Unable to resume NonResumableStep", b); | ||
}); | ||
} | ||
|
||
public static class NonResumableStep extends Step implements Serializable { | ||
public static final long serialVersionUID = 1L; | ||
@DataBoundConstructor | ||
public NonResumableStep() { } | ||
@Override | ||
public StepExecution start(StepContext sc) { | ||
return new ExecutionImpl(sc); | ||
} | ||
|
||
private static class ExecutionImpl extends StepExecution implements Serializable { | ||
public static final long serialVersionUID = 1L; | ||
private ExecutionImpl(StepContext sc) { | ||
super(sc); | ||
} | ||
@Override | ||
public boolean start() throws Exception { | ||
getContext().get(TaskListener.class).getLogger().println("Starting non-resumable step"); | ||
return false; | ||
} | ||
@Override | ||
public void onResume() { | ||
getContext().onFailure(new AbortException("Unable to resume NonResumableStep")); | ||
} | ||
} | ||
|
||
@TestExtension public static class DescriptorImpl extends StepDescriptor { | ||
@Override | ||
public Set<? extends Class<?>> getRequiredContext() { | ||
return Collections.singleton(TaskListener.class); | ||
} | ||
@Override | ||
public String getFunctionName() { | ||
return "noResume"; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Wait up to 5 seconds for the given supplier to return a matching value. | ||
*/ | ||
private static <T> void waitFor(Supplier<T> valueSupplier, Matcher<T> matcher) throws InterruptedException { | ||
Instant end = Instant.now().plus(Duration.ofSeconds(5)); | ||
while (!matcher.matches(valueSupplier.get()) && Instant.now().isBefore(end)) { | ||
Thread.sleep(100L); | ||
} | ||
assertThat("Matcher should have matched after 5s", valueSupplier.get(), matcher); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.