use of com.netflix.titus.grpc.protogen.TaskQueryResult in project titus-control-plane by Netflix.
the class JobCursorArchiveQueryTest method testArchiveQuery.
@Test(timeout = TEST_TIMEOUT_MS)
public void testArchiveQuery() {
Evaluators.times(TASKS_PER_JOB, idx -> jobScenarioBuilder.getTaskByIndex(idx).killTask().completeKillInitiated().expectStateUpdateSkipOther(TaskStatus.TaskState.Finished));
Evaluators.times(TASKS_PER_JOB, idx -> jobScenarioBuilder.expectTaskInSlot(idx, 1));
int allTasksCount = TASKS_PER_JOB * 2;
Set<String> taskIds = new HashSet<>();
Page current = TWO_ITEM_PAGE;
for (int i = 0; i < TASKS_PER_JOB; i++) {
TaskQuery query = TaskQuery.newBuilder().setPage(current).putFilteringCriteria("jobIds", jobScenarioBuilder.getJobId()).putFilteringCriteria("taskStates", ALL_TASK_STATES).build();
TaskQueryResult result = client.findTasks(query);
assertThat(result.getPagination().getTotalItems()).isEqualTo(allTasksCount);
assertThat(result.getPagination().getCursor()).isNotEmpty();
taskIds.addAll(result.getItemsList().stream().map(Task::getId).collect(Collectors.toList()));
current = query.getPage().toBuilder().setCursor(result.getPagination().getCursor()).build();
}
assertThat(taskIds).hasSize(allTasksCount);
}
use of com.netflix.titus.grpc.protogen.TaskQueryResult in project titus-control-plane by Netflix.
the class JobCursorQueryTest method testTaskQueryWithCursorAndEmptyResult.
@Test(timeout = TEST_TIMEOUT_MS)
public void testTaskQueryWithCursorAndEmptyResult() {
TaskQueryResult result = client.findTasks(TaskQuery.newBuilder().setPage(Page.newBuilder().setPageSize(4)).putFilteringCriteria("jobState", // Filter by something that gives us empty result
"KillInitiated").build());
assertThat(result.getItemsList()).isEmpty();
assertThat(result.getPagination().getCursor()).isEmpty();
assertThat(result.getPagination().getCursorPosition()).isZero();
assertThat(result.getPagination().getHasMore()).isFalse();
}
use of com.netflix.titus.grpc.protogen.TaskQueryResult in project titus-control-plane by Netflix.
the class JobCursorQueryWithUpdatesTest method testTaskQueryWithRemovedItems.
@Test(timeout = TEST_TIMEOUT_MS)
public void testTaskQueryWithRemovedItems() {
// Page 0
TaskQueryResult result0 = client.findTasks(TaskQuery.newBuilder().setPage(Page.newBuilder().setPageSize(4)).build());
assertThat(result0.getItemsList()).containsExactlyElementsOf(allTasksInOrder.subList(0, 4));
// Remove item at the cursor position
jobsScenarioBuilder.takeJob(result0.getItems(3).getJobId()).getTask(result0.getItems(3).getId()).template(ScenarioTemplates.terminateAndShrinkV3());
TaskQueryResult result1 = client.findTasks(TaskQuery.newBuilder().setPage(Page.newBuilder().setPageSize(4).setCursor(result0.getPagination().getCursor())).build());
assertThat(result1.getItemsList()).containsExactlyElementsOf(allTasksInOrder.subList(4, 8));
// Remove last items
jobsScenarioBuilder.takeJob(allTasksInOrder.get(10).getJobId()).getTask(allTasksInOrder.get(10).getId()).template(ScenarioTemplates.terminateAndShrinkV3());
jobsScenarioBuilder.takeJob(allTasksInOrder.get(11).getJobId()).getTask(allTasksInOrder.get(11).getId()).template(ScenarioTemplates.terminateAndShrinkV3());
TaskQueryResult result2 = client.findTasks(TaskQuery.newBuilder().setPage(Page.newBuilder().setPageSize(2).setCursor(result1.getPagination().getCursor())).build());
assertThat(result2.getItemsList()).containsExactlyElementsOf(allTasksInOrder.subList(8, 10));
}
use of com.netflix.titus.grpc.protogen.TaskQueryResult in project titus-control-plane by Netflix.
the class JobCriteriaQueryTest method testFindArchivedTasksByTaskIdsV3.
@Test(timeout = 60_000)
public void testFindArchivedTasksByTaskIdsV3() {
TaskQueryResult taskQueryResult = client.findTasks(TaskQuery.newBuilder().putFilteringCriteria("jobIds", finishedBatchJobWithFiveTasks).putFilteringCriteria("taskStates", com.netflix.titus.grpc.protogen.TaskStatus.TaskState.Finished.name()).setPage(PAGE).build());
List<Task> tasks = taskQueryResult.getItemsList();
assertThat(tasks).hasSize(5);
assertThat(tasks).allMatch(task -> task.getStatus().getState() == TaskStatus.TaskState.Finished);
}
Aggregations