use of com.hubspot.singularity.data.history.TaskHistoryHelper in project Singularity by HubSpot.
the class SingularityHistoryTest method testPersisterRaceCondition.
@Test
public void testPersisterRaceCondition() {
final TaskManager taskManagerSpy = spy(taskManager);
final TaskHistoryHelper taskHistoryHelperWithMockedTaskManager = new TaskHistoryHelper(taskManagerSpy, historyManager, requestManager, configuration);
initScheduledRequest();
initFirstDeploy();
requestResource.scheduleImmediately(singularityUser, requestId);
resourceOffers();
final SingularityTaskId taskId = taskManager.getActiveTaskIds().get(0);
statusUpdate(taskManager.getTask(taskId).get(), Protos.TaskState.TASK_FINISHED, Optional.of(System.currentTimeMillis()));
// persist inactive task(s)
taskHistoryPersister.runActionOnPoll();
// mimic the persister race condition by overriding the inactive task IDs in ZK to the persisted task ID
doReturn(Arrays.asList(taskId)).when(taskManagerSpy).getInactiveTaskIdsForRequest(eq(requestId));
// assert that the history works, but more importantly, that we don't NPE
Assert.assertEquals(1, taskHistoryHelperWithMockedTaskManager.getBlendedHistory(new SingularityTaskHistoryQuery(requestId), 0, 5).size());
}
Aggregations