SchedulerDriverService extends AbstractIdleService implements Driver { @Override public void killTask(String taskId) { ensureRunning(); Protos.Status status = Futures.getUnchecked(driverFuture).killTask( Protos.TaskID.newBuilder().setValue(taskId).build()); if (status != DRIVER_RUNNING) { LOG.error("Attempt to kill task {} failed with code {}", taskId, status); killFailures.incrementAndGet(); } } @Inject  SchedulerDriverService(
      Scheduler scheduler,
      Storage storage,
      DriverSettings driverSettings,
      DriverFactory driverFactory); @Override void blockUntilStopped(); @Override void abort(); @Override void launchTask(Protos.OfferID offerId, Protos.TaskInfo task); @Override void declineOffer(Protos.OfferID offerId); @Override void killTask(String taskId); @Override void acknowledgeStatusUpdate(Protos.TaskStatus status); @Override void reconcileTasks(Collection<Protos.TaskStatus> statuses);  }
@Test public void testNormalLifecycle() { expectCreateDriver(NEW_FRAMEWORK_ID); expect(schedulerDriver.killTask(createTaskId(TASK_1))).andReturn(DRIVER_RUNNING); expect(schedulerDriver.killTask(createTaskId(TASK_2))).andReturn(DRIVER_RUNNING); expect(schedulerDriver.stop(true)).andReturn(DRIVER_ABORTED); control.replay(); driverService.startAsync().awaitRunning(); driverService.killTask(TASK_1); driverService.killTask(TASK_2); driverService.stopAsync().awaitTerminated(); }
@Test(expected = IllegalStateException.class) public void testMustRunBeforeKill() { control.replay(); driverService.killTask(TASK_1); }