@Test public void testGetPendingReasonFailsSlavesSet() throws Exception { Builder query = Query.unscoped().bySlave("host1"); control.replay(); assertResponse(INVALID_REQUEST, thrift.getPendingReason(query.get())); }
@Test public void testGetPendingReasonFailsStatusSet() throws Exception { Builder query = Query.unscoped().byStatus(ScheduleStatus.ASSIGNED); control.replay(); assertResponse(INVALID_REQUEST, thrift.getPendingReason(query.get())); }
@Test public void testGetPendingReason() throws Exception { Builder query = Query.unscoped().byJob(JOB_KEY); Builder filterQuery = Query.unscoped().byJob(JOB_KEY).byStatus(ScheduleStatus.PENDING); String taskId1 = "task_id_test1"; String taskId2 = "task_id_test2"; ImmutableSet<Veto> result = ImmutableSet.of(Veto.constraintMismatch("first"), Veto.constraintMismatch("second")); ITaskConfig taskConfig = ITaskConfig.build(defaultTask(true)); IScheduledTask pendingTask1 = IScheduledTask.build( new ScheduledTask() .setAssignedTask( new AssignedTask().setTaskId(taskId1).setTask(taskConfig.newBuilder())) .setStatus(ScheduleStatus.PENDING)); IScheduledTask pendingTask2 = IScheduledTask.build( new ScheduledTask() .setAssignedTask( new AssignedTask().setTaskId(taskId2).setTask(taskConfig.newBuilder())) .setStatus(ScheduleStatus.PENDING)); storageUtil.expectTaskFetch(filterQuery, pendingTask1, pendingTask2); expect(nearestFit.getNearestFit(TaskGroupKey.from(taskConfig))).andReturn(result).times(2); control.replay(); String reason = "Constraint not satisfied: first,Constraint not satisfied: second"; Set<PendingReason> expected = ImmutableSet.of( new PendingReason().setTaskId(taskId1).setReason(reason), new PendingReason().setTaskId(taskId2).setReason(reason)); Response response = assertOkResponse(thrift.getPendingReason(query.get())); assertEquals(expected, response.getResult().getGetPendingReasonResult().getReasons()); }