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());
}
}
}
}
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());
}
}
}
}
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;
}
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;
}
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);
}
}
}
}
Aggregations