use of com.netflix.titus.grpc.protogen.JobDisruptionBudget in project titus-control-plane by Netflix.
the class JobManagementSpringResourceTest method testSetJobDisruptionBudget.
@Test
public void testSetJobDisruptionBudget() throws Exception {
JobDisruptionBudget restRequest = toGrpcDisruptionBudget(DisruptionBudgetGenerator.budgetSelfManagedBasic());
JobDisruptionBudgetUpdate forwardedRequest = JobDisruptionBudgetUpdate.newBuilder().setJobId(JOB_ID_1).setDisruptionBudget(restRequest).build();
when(jobServiceGatewayMock.updateJobDisruptionBudget(forwardedRequest, JUNIT_REST_CALL_METADATA)).thenReturn(Mono.empty());
SpringMockMvcUtil.doPut(mockMvc, String.format("/api/v3/jobs/%s/disruptionBudget", JOB_ID_1), restRequest);
verify(jobServiceGatewayMock, times(1)).updateJobDisruptionBudget(forwardedRequest, JUNIT_REST_CALL_METADATA);
}
use of com.netflix.titus.grpc.protogen.JobDisruptionBudget in project titus-control-plane by Netflix.
the class DefaultJobManagementServiceGrpc method validateAndConvertJobDisruptionBudgetToCoreModel.
private Optional<DisruptionBudget> validateAndConvertJobDisruptionBudgetToCoreModel(com.netflix.titus.api.jobmanager.model.job.Job<?> coreJob, JobDisruptionBudget grpcDisruptionBudget, StreamObserver<Empty> responseObserver) {
DisruptionBudget coreDisruptionBudget;
try {
coreDisruptionBudget = GrpcJobManagementModelConverters.toCoreDisruptionBudget(grpcDisruptionBudget);
} catch (Exception e) {
safeOnError(logger, TitusServiceException.invalidArgument("Error when converting GRPC disruption budget to the internal model: " + e.getMessage()), responseObserver);
return Optional.empty();
}
DisruptionBudget sanitizedCoreDisruptionBudget = entitySanitizer.sanitize(coreDisruptionBudget).orElse(coreDisruptionBudget);
Set<ValidationError> violations = entitySanitizer.validate(sanitizedCoreDisruptionBudget);
if (!violations.isEmpty()) {
safeOnError(logger, TitusServiceException.invalidArgument(violations), responseObserver);
return Optional.empty();
}
return Optional.of(sanitizedCoreDisruptionBudget);
}
Aggregations