JCloudsComputer extends AbstractCloudComputer<JCloudsSlave> implements TrackedItem { @Override public boolean isAcceptingTasks() { if (getRetentionTime() == 0 && used.get() > 1) { return false; } return super.isAcceptingTasks(); } JCloudsComputer(JCloudsSlave slave); static @Nonnull List<JCloudsComputer> getAll(); @Override @CheckForNull JCloudsSlave getNode(); @Override @Nonnull ProvisioningActivity.Id getId(); void setPendingDelete(boolean newVal); boolean isPendingDelete(); @Override // Overridden for type safety only JCloudsRetentionStrategy getRetentionStrategy(); @Override boolean isAcceptingTasks(); @Override void taskCompleted(Executor executor, Queue.Task task, long durationMS); @Override void taskCompletedWithProblems(Executor executor, Queue.Task task, long durationMS, Throwable problems); @Restricted(DoNotUse.class) void doConfigure(StaplerResponse rsp); @Override @Restricted(NoExternalUse.class) @RequirePOST HttpResponse doDoDelete(); @Restricted(NoExternalUse.class) @RequirePOST HttpRedirect doScheduleTermination(); void setChannel(Channel channel, OutputStream launchLog, Channel.Listener listener); long getConnectedSince();  }
@Test public void slaveWithRetentionTimeNonZeroStillAcceptsTasksAfterFirstTaskRun() throws Exception { JCloudsCloud cloud = j.configureSlaveLaunchingWithFloatingIP(j.dummyCloud(j.dummySlaveTemplate( j.defaultSlaveOptions().getBuilder().retentionTime(10).instancesMin(1).build(), "label" ))); JCloudsSlave slave = j.provision(cloud, "label"); JCloudsComputer computer = slave.getComputer(); computer.waitUntilOnline(); FreeStyleProject p = j.createFreeStyleProject(); p.setAssignedNode(slave); FreeStyleBuild build = p.scheduleBuild2(0).waitForStart(); j.waitForCompletion(build); j.waitUntilNoActivity(); assertTrue(computer.isAcceptingTasks()); }