Search in sources :

Example 16 with Computer

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

the class CpsFlowDefinition2Test method endlessRecursion.

/**
 * Verify that we kill endlessly recursive CPS code cleanly.
 */
@Test
@Ignore
public /**
 * Intermittent failures because triggers a longstanding unrelated SandboxResolvingClassloader bug
 *     resolved in https://github.com/jenkinsci/script-security-plugin/pull/160
 */
void endlessRecursion() throws Exception {
    // Sidestep false failures specific to a few Windows build environments.
    Assume.assumeTrue(!Functions.isWindows());
    String script = "def getThing(){return thing == null}; \n" + "node { echo getThing(); } ";
    WorkflowJob job = jenkins.jenkins.createProject(WorkflowJob.class, "recursion");
    job.setDefinition(new CpsFlowDefinition(script, true));
    // Should have failed with error about excessive recursion depth
    WorkflowRun r = jenkins.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get());
    jenkins.assertLogContains("look for unbounded recursion", r);
    Assert.assertTrue("No queued FlyWeightTask for job should remain after failure", jenkins.jenkins.getQueue().isEmpty());
    for (Computer c : jenkins.jenkins.getComputers()) {
        for (Executor ex : c.getExecutors()) {
            if (ex.isBusy()) {
                fail(ex.getCurrentExecutable().toString());
            }
        }
    }
}
Also used : Executor(hudson.model.Executor) Computer(hudson.model.Computer) Matchers.containsString(org.hamcrest.Matchers.containsString) WorkflowJob(org.jenkinsci.plugins.workflow.job.WorkflowJob) WorkflowRun(org.jenkinsci.plugins.workflow.job.WorkflowRun) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 17 with Computer

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

the class FlowDurabilityTest method assertNoTasksRunning.

private static void assertNoTasksRunning(Jenkins j) {
    j.getQueue().maintain();
    assert j.getQueue().isEmpty();
    Computer[] computerList = j.getComputers();
    for (Computer c : computerList) {
        List<Executor> executors = c.getExecutors();
        for (Executor ex : executors) {
            if (ex.isBusy()) {
                Assert.fail("Computer " + c + " has an Executor " + ex + " still running a task: " + ex.getCurrentWorkUnit());
            }
        }
    }
}
Also used : Executor(hudson.model.Executor) Computer(hudson.model.Computer)

Example 18 with Computer

use of hudson.model.Computer in project vsphere-cloud-plugin by jenkinsci.

the class vSphereCloudSlave method EndLimitedTestRun.

public boolean EndLimitedTestRun(Run r) {
    boolean ret = true;
    // See if the run maps to an existing computer; remove if found.
    Computer slave = RunToSlaveMapper.get(r);
    if (slave != null) {
        RunToSlaveMapper.remove(r);
    }
    if (LimitedTestRunCount > 0) {
        if (NumberOfLimitedTestRuns >= LimitedTestRunCount) {
            ret = false;
            NumberOfLimitedTestRuns = 0;
            try {
                if (slave != null) {
                    vSphereCloud.Log(this, "Disconnecting the slave agent on %s due to limited build threshold", slave.getName());
                    final VSphereOfflineCause tempOffline = new VSphereOfflineCause(Messages._vSphereCloudSlave_LimitedBuild_TemporarilyOnline());
                    slave.setTemporarilyOffline(true, tempOffline);
                    slave.waitUntilOffline();
                    final VSphereOfflineCause disconnect = new VSphereOfflineCause(Messages._vSphereCloudSlave_LimitedBuild_Disconnect());
                    slave.disconnect(disconnect);
                    final VSphereOfflineCause tempOnline = new VSphereOfflineCause(Messages._vSphereCloudSlave_LimitedBuild_TemporarilyOnline());
                    slave.setTemporarilyOffline(false, tempOnline);
                } else {
                    vSphereCloud.Log(this, "Attempting to shutdown slave due to limited build threshold, but cannot determine slave");
                }
            } catch (NullPointerException ex) {
                vSphereCloud.Log(this, ex, "NullPointerException thrown while retrieving the slave agent");
            } catch (InterruptedException ex) {
                vSphereCloud.Log(this, ex, "InterruptedException thrown while marking the slave as online or offline");
            }
        }
    } else {
        ret = true;
    }
    return ret;
}
Also used : Computer(hudson.model.Computer) VSphereOfflineCause(org.jenkinsci.plugins.vsphere.VSphereOfflineCause)

Example 19 with Computer

use of hudson.model.Computer in project vsphere-cloud-plugin by jenkinsci.

the class vSphereCloudSlave method StartLimitedTestRun.

public boolean StartLimitedTestRun(Run r, TaskListener listener) {
    boolean ret = false;
    boolean DoUpdates = false;
    if (LimitedTestRunCount > 0) {
        DoUpdates = true;
        if (NumberOfLimitedTestRuns < LimitedTestRunCount) {
            ret = true;
        }
    } else {
        ret = true;
    }
    Executor executor = r.getExecutor();
    if (executor != null && DoUpdates) {
        if (ret) {
            NumberOfLimitedTestRuns++;
            vSphereCloud.Log(this, listener, "Starting limited count build: %d of %d", NumberOfLimitedTestRuns, LimitedTestRunCount);
            Computer slave = executor.getOwner();
            RunToSlaveMapper.put(r, slave);
        } else {
            vSphereCloud.Log(this, listener, "Terminating build due to limited build count: %d of %d", NumberOfLimitedTestRuns, LimitedTestRunCount);
            executor.interrupt(Result.ABORTED);
        }
    }
    return ret;
}
Also used : Executor(hudson.model.Executor) Computer(hudson.model.Computer)

Example 20 with Computer

use of hudson.model.Computer in project vsphere-cloud-plugin by jenkinsci.

the class vSphereCloudRunListener method onStarted.

@Override
public void onStarted(Run r, TaskListener listener) {
    super.onStarted(r, listener);
    if (r != null) {
        Executor exec = r.getExecutor();
        if (exec != null) {
            Computer owner = exec.getOwner();
            Node node = owner.getNode();
            if ((node != null) && (node instanceof vSphereCloudSlave)) {
                LimitedRuns.add(r);
                vSphereCloudSlave s = (vSphereCloudSlave) node;
                s.StartLimitedTestRun(r, listener);
            }
        }
    }
}
Also used : Executor(hudson.model.Executor) Node(hudson.model.Node) Computer(hudson.model.Computer)

Aggregations

Computer (hudson.model.Computer)26 IOException (java.io.IOException)10 Node (hudson.model.Node)8 Executor (hudson.model.Executor)6 AbortException (hudson.AbortException)4 FilePath (hudson.FilePath)4 Jenkins (jenkins.model.Jenkins)4 EnvVars (hudson.EnvVars)3 VirtualChannel (hudson.remoting.VirtualChannel)3 PrintWriter (java.io.PrintWriter)3 Test (org.junit.Test)3 Content (com.cloudbees.jenkins.support.api.Content)2 SlaveComputer (hudson.slaves.SlaveComputer)2 WorkspaceList (hudson.slaves.WorkspaceList)2 InterruptedIOException (java.io.InterruptedIOException)2 ArrayList (java.util.ArrayList)2 Folder (com.cloudbees.hudson.plugins.folder.Folder)1 FileContent (com.cloudbees.jenkins.support.api.FileContent)1 FilePathContent (com.cloudbees.jenkins.support.api.FilePathContent)1 PrintedContent (com.cloudbees.jenkins.support.api.PrintedContent)1