use of com.netflix.titus.grpc.protogen.TaskRelocationPlan in project titus-control-plane by Netflix.
the class TaskRelocationIntegrationTest method testPlannedRelocation.
@Test(timeout = 60_000)
public void testPlannedRelocation() throws Exception {
Task task = createAndPlaceOneTaskJob(TestDataFactory.REMOVABLE_INSTANCE_GROUP_ID);
relocationConnectorStubs.setQuota(task.getJobId(), 1);
// Get the plan
TaskRelocationPlan plan = doTry(() -> findRelocationPlan(task.getId()));
assertThat(plan.getTaskId()).isEqualTo(task.getId());
assertThat(plan.getReasonCode()).isEqualTo(TaskRelocationReason.SelfManagedMigration.name());
assertThat(plan.getRelocationTime()).isLessThanOrEqualTo(clock.wallTime() + RELOCATION_TIME_MS);
// Wait for the relocation
TaskRelocationStatus status = doTry(() -> findRelocationStatus(task.getId()));
assertThat(status.getState()).isEqualTo(TaskRelocationStatus.TaskRelocationState.Success);
assertThat(status.getStatusCode()).isEqualTo(com.netflix.titus.api.relocation.model.TaskRelocationStatus.STATUS_CODE_TERMINATED);
assertThat(status.getStatusMessage()).isNotEmpty();
}
use of com.netflix.titus.grpc.protogen.TaskRelocationPlan in project titus-control-plane by Netflix.
the class TaskRelocationIntegrationTest method findRelocationPlan.
private Optional<TaskRelocationPlan> findRelocationPlan(String taskId) {
TaskRelocationPlans plans;
try {
TestStreamObserver<TaskRelocationPlans> events = new TestStreamObserver<>();
client.getCurrentTaskRelocationPlans(TaskRelocationQuery.getDefaultInstance(), events);
plans = events.getLast();
} catch (Exception e) {
if (e.getMessage().contains("Relocation workflow not ready yet")) {
return Optional.empty();
}
throw new RuntimeException(e);
}
Optional<TaskRelocationPlan> taskPlan = plans.getPlansList().stream().filter(p -> p.getTaskId().equals(taskId)).findFirst();
if (taskPlan.isPresent()) {
return taskPlan;
}
// Check if already processed
try {
TestStreamObserver<TaskRelocationExecution> events = new TestStreamObserver<>();
client.getTaskRelocationResult(RelocationTaskId.newBuilder().setId(taskId).build(), events);
return Optional.of(events.getLast().getTaskRelocationPlan());
} catch (Exception e) {
Status status = Status.fromThrowable(e);
if (status.getCode() == Status.Code.NOT_FOUND) {
return Optional.empty();
}
throw new RuntimeException(e);
}
}
Aggregations