Search in sources :

Example 11 with Executor

use of hudson.model.Executor in project workflow-job-plugin by jenkinsci.

the class WorkflowRunRestartTest method termAndKillInSidePanel.

@Issue("JENKINS-33721")
@Test
public void termAndKillInSidePanel() throws Exception {
    story.then(r -> {
        WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
        p.setDefinition(new CpsFlowDefinition("def seq = 0; retry (99) {zombie id: ++seq}", true));
        WorkflowRun b = p.scheduleBuild2(0).waitForStart();
        r.waitForMessage("[1] undead", b);
        Executor ex = b.getExecutor();
        assertNotNull(ex);
        ex.interrupt();
        r.waitForMessage("[1] bwahaha FlowInterruptedException #1", b);
        ex.interrupt();
        r.waitForMessage("[1] bwahaha FlowInterruptedException #2", b);
        assertFalse(hasTermOrKillLink(b, "term"));
        assertFalse(hasTermOrKillLink(b, "kill"));
        r.waitForMessage("Click here to forcibly terminate running steps", b);
        assertTrue(hasTermOrKillLink(b, "term"));
        assertFalse(hasTermOrKillLink(b, "kill"));
        b.doTerm();
        r.waitForMessage("[2] undead", b);
        r.waitForMessage("Click here to forcibly kill entire build", b);
        assertTrue(hasTermOrKillLink(b, "term"));
        assertTrue(hasTermOrKillLink(b, "kill"));
        b.doKill();
        r.waitForMessage("Hard kill!", b);
        r.waitForCompletion(b);
        r.assertBuildStatus(Result.ABORTED, b);
    });
}
Also used : Executor(hudson.model.Executor) CpsFlowDefinition(org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) Issue(org.jvnet.hudson.test.Issue) Test(org.junit.Test)

Example 12 with Executor

use of hudson.model.Executor in project hudson-2.x by hudson.

the class InstallToolCommand method install.

/**
 * Performs an installation.
 */
private int install(ToolInstallation t, BuildIDs id, AbstractProject p) throws IOException, InterruptedException {
    Run b = p.getBuildByNumber(Integer.parseInt(id.number));
    if (b == null)
        throw new AbortException("No such build: " + id.number);
    Executor exec = b.getExecutor();
    if (exec == null)
        throw new AbortException(b.getFullDisplayName() + " is not building");
    Node node = exec.getOwner().getNode();
    if (t instanceof NodeSpecific) {
        NodeSpecific n = (NodeSpecific) t;
        t = (ToolInstallation) n.forNode(node, new StreamTaskListener(stderr));
    }
    if (t instanceof EnvironmentSpecific) {
        EnvironmentSpecific e = (EnvironmentSpecific) t;
        t = (ToolInstallation) e.forEnvironment(EnvVars.getRemote(channel));
    }
    stdout.println(t.getHome());
    return 0;
}
Also used : Executor(hudson.model.Executor) EnvironmentSpecific(hudson.model.EnvironmentSpecific) StreamTaskListener(hudson.util.StreamTaskListener) Node(hudson.model.Node) NodeSpecific(hudson.slaves.NodeSpecific) Run(hudson.model.Run) AbortException(hudson.AbortException)

Example 13 with Executor

use of hudson.model.Executor in project hudson-2.x by hudson.

the class WorkUnitContext method synchronizeEnd.

/**
 * All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the end of the task.
 *
 * @throws InterruptedException
 *      If any of the member thread is interrupted while waiting for other threads to join, all
 *      the member threads will report {@link InterruptedException}.
 */
public void synchronizeEnd(Queue.Executable executable, Throwable problems, long duration) throws InterruptedException {
    endLatch.synchronize();
    // the main thread will send a notification
    Executor e = Executor.currentExecutor();
    WorkUnit wu = e.getCurrentWorkUnit();
    if (wu.isMainWork()) {
        if (problems == null) {
            future.set(executable);
            e.getOwner().taskCompleted(e, task, duration);
        } else {
            future.set(problems);
            e.getOwner().taskCompletedWithProblems(e, task, duration, problems);
        }
    }
}
Also used : Executor(hudson.model.Executor)

Example 14 with Executor

use of hudson.model.Executor in project hudson-2.x by hudson.

the class WorkUnitContext method abort.

/**
 * When one of the work unit is aborted, call this method to abort all the other work units.
 */
public synchronized void abort(Throwable cause) {
    if (cause == null)
        throw new IllegalArgumentException();
    // already aborted
    if (aborted != null)
        return;
    aborted = cause;
    startLatch.abort(cause);
    endLatch.abort(cause);
    Thread c = Thread.currentThread();
    for (WorkUnit wu : workUnits) {
        Executor e = wu.getExecutor();
        if (e != null && e != c)
            e.interrupt();
    }
}
Also used : Executor(hudson.model.Executor)

Example 15 with Executor

use of hudson.model.Executor in project workflow-cps-plugin by jenkinsci.

the class WorkflowTest method liveness.

private void liveness() {
    assertFalse(jenkins().toComputer().isIdle());
    Executor e = b.getOneOffExecutor();
    assertNotNull(e);
    assertEquals(e, b.getExecutor());
    assertTrue(e.isActive());
/* TODO seems flaky:
        assertFalse(e.isAlive());
        */
}
Also used : Executor(hudson.model.Executor)

Aggregations

Executor (hudson.model.Executor)18 Computer (hudson.model.Computer)8 Node (hudson.model.Node)5 Test (org.junit.Test)5 AbortException (hudson.AbortException)2 FilePath (hudson.FilePath)2 Run (hudson.model.Run)2 CpsFlowDefinition (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition)2 WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob)2 WorkflowRun (org.jenkinsci.plugins.workflow.job.WorkflowRun)2 Issue (org.jvnet.hudson.test.Issue)2 AbstractBuild (hudson.model.AbstractBuild)1 EnvironmentSpecific (hudson.model.EnvironmentSpecific)1 Queue (hudson.model.Queue)1 StreamBuildListener (hudson.model.StreamBuildListener)1 ExecutorChunk (hudson.model.queue.MappingWorksheet.ExecutorChunk)1 Mapping (hudson.model.queue.MappingWorksheet.Mapping)1 WorkChunk (hudson.model.queue.MappingWorksheet.WorkChunk)1 Promotion (hudson.plugins.promoted_builds.Promotion)1 NodeSpecific (hudson.slaves.NodeSpecific)1