Search in sources :

Example 26 with TaskQueryResult

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);
}
Also used : Task(com.netflix.titus.grpc.protogen.Task) TaskQuery(com.netflix.titus.grpc.protogen.TaskQuery) Page(com.netflix.titus.grpc.protogen.Page) TaskQueryResult(com.netflix.titus.grpc.protogen.TaskQueryResult) HashSet(java.util.HashSet) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Example 27 with TaskQueryResult

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();
}
Also used : TaskQueryResult(com.netflix.titus.grpc.protogen.TaskQueryResult) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Example 28 with TaskQueryResult

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));
}
Also used : TaskQueryResult(com.netflix.titus.grpc.protogen.TaskQueryResult) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Example 29 with TaskQueryResult

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);
}
Also used : Task(com.netflix.titus.grpc.protogen.Task) TaskQueryResult(com.netflix.titus.grpc.protogen.TaskQueryResult) BaseIntegrationTest(com.netflix.titus.master.integration.BaseIntegrationTest) IntegrationTest(com.netflix.titus.testkit.junit.category.IntegrationTest) Test(org.junit.Test)

Aggregations

TaskQueryResult (com.netflix.titus.grpc.protogen.TaskQueryResult)29 Test (org.junit.Test)20 TaskQuery (com.netflix.titus.grpc.protogen.TaskQuery)13 BaseIntegrationTest (com.netflix.titus.master.integration.BaseIntegrationTest)12 IntegrationTest (com.netflix.titus.testkit.junit.category.IntegrationTest)12 Task (com.netflix.titus.grpc.protogen.Task)11 JobQueryResult (com.netflix.titus.grpc.protogen.JobQueryResult)9 Page (com.netflix.titus.grpc.protogen.Page)8 HashSet (java.util.HashSet)8 List (java.util.List)8 Job (com.netflix.titus.grpc.protogen.Job)7 ArrayList (java.util.ArrayList)7 Function (java.util.function.Function)6 JobQuery (com.netflix.titus.grpc.protogen.JobQuery)5 TaskStatus (com.netflix.titus.grpc.protogen.TaskStatus)5 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)3 JobFunctions (com.netflix.titus.api.jobmanager.model.job.JobFunctions)3 BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)3 ServiceJobExt (com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt)3 Pair (com.netflix.titus.common.util.tuple.Pair)3