use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class DefaultAppScaleManagerTest method mockV3OperationsForJobs.
private V3JobOperations mockV3OperationsForJobs(List<String> jobIds) {
V3JobOperations v3JobOperations = mock(V3JobOperations.class);
for (String jobId : jobIds) {
// FIXME Use JobGenerator instead of mocking.
Job job = mock(Job.class);
when(job.getId()).thenReturn(jobId);
JobDescriptor jobDescriptorOne = mock(JobDescriptor.class);
ServiceJobExt serviceJobExtOne = mock(ServiceJobExt.class);
JobGroupInfo jobGroupInfoOne = buildMockJobGroupInfo(jobId);
Capacity capacityOne = mock(Capacity.class);
when(capacityOne.getMax()).thenReturn(10);
when(capacityOne.getMin()).thenReturn(1);
when(serviceJobExtOne.getCapacity()).thenReturn(capacityOne);
when(jobDescriptorOne.getExtensions()).thenReturn(serviceJobExtOne);
when(job.getJobDescriptor()).thenReturn(jobDescriptorOne);
when(jobDescriptorOne.getJobGroupInfo()).thenReturn(jobGroupInfoOne);
when(jobDescriptorOne.getApplicationName()).thenReturn("testApp");
when(v3JobOperations.getJob(jobId)).thenReturn(Optional.of(job));
JobManagerEvent<?> jobUpdateEvent = JobUpdateEvent.newJob(job, callMetadata);
when(v3JobOperations.observeJobs()).thenAnswer(invocation -> Observable.from(asList(jobUpdateEvent)));
}
return v3JobOperations;
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class MoveTaskTest method testMoveWithIncompatibleTargetJob.
@Test
public void testMoveWithIncompatibleTargetJob() {
JobDescriptor<ServiceJobExt> jobDescriptor = oneTaskServiceJobDescriptor();
JobScenarioBuilder sourceJobBuilder = startNewJob(jobDescriptor);
String sourceJobId = sourceJobBuilder.getJobId();
JobDescriptor<ServiceJobExt> incompatible = jobDescriptor.but(descriptor -> descriptor.getContainer().but(container -> container.getImage().toBuilder().withName("other/image").build()));
String targetJobId = startNewJob(incompatible).getJobId();
try {
sourceJobBuilder.moveTask(0, 0, sourceJobId, targetJobId);
} catch (JobManagerException e) {
assertThat(e.getErrorCode()).isEqualTo(JobManagerException.ErrorCode.JobsNotCompatible);
assertThat(e.getMessage()).contains("container.image.name");
}
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class AggregatingValidatorTest method validateHardSoftTimeout.
// Hard/Soft validation tests
@Test
public void validateHardSoftTimeout() {
AdmissionValidator<JobDescriptor> never0 = new NeverJobValidator(ValidationError.Type.HARD);
AdmissionValidator never1 = new NeverJobValidator(ValidationError.Type.SOFT);
AdmissionValidator validator = new AggregatingValidator(configuration, registry, Arrays.asList(never0, never1));
Mono<Set<ValidationError>> mono = validator.validate(MOCK_JOB);
StepVerifier.create(mono).expectNextMatches(errors -> errors.size() == 2).verifyComplete();
Collection<ValidationError> errors = mono.block();
validateTimeoutErrors(errors);
Collection<ValidationError> hardErrors = errors.stream().filter(error -> error.getType().equals(ValidationError.Type.HARD)).collect(Collectors.toList());
assertThat(hardErrors).hasSize(1);
Collection<ValidationError> softErrors = errors.stream().filter(error -> error.getType().equals(ValidationError.Type.SOFT)).collect(Collectors.toList());
assertThat(softErrors).hasSize(1);
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizerTest method runtimeLimitIsOnlyUsedWhenWithinAllowedConfig.
@Test
public void runtimeLimitIsOnlyUsedWhenWithinAllowedConfig() {
JobRuntimePredictionClient client = mock(JobRuntimePredictionClient.class);
JobRuntimePredictions predictions = new JobRuntimePredictions("v1", modelId, new TreeSet<>());
when(client.getRuntimePredictions(any())).thenReturn(Mono.just(predictions));
JobRuntimePredictionConfiguration lowConfig = mock(JobRuntimePredictionConfiguration.class);
// lower than the 60s runtime limit on the job
when(lowConfig.getMaxOpportunisticRuntimeLimitMs()).thenReturn(30_000L);
AdmissionSanitizer<JobDescriptor> sanitizer = new JobRuntimePredictionSanitizer(client, JobRuntimePredictionSelectors.best(), lowConfig, TitusRuntimes.test());
StepVerifier.create(sanitizer.sanitizeAndApply(jobDescriptor)).assertNext(result -> assertThat(((JobDescriptor<?>) result).getAttributes()).doesNotContainKeys(JOB_ATTRIBUTES_RUNTIME_PREDICTION_CONFIDENCE, JOB_ATTRIBUTES_RUNTIME_PREDICTION_SEC, JOB_ATTRIBUTES_RUNTIME_PREDICTION_AVAILABLE).containsEntry(JOB_ATTRIBUTES_SANITIZATION_SKIPPED_RUNTIME_PREDICTION, "true").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_MODEL_ID, modelId).containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_VERSION, "v1")).verifyComplete();
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizerTest method higherQualityPredictionsMustBeLonger.
@Test
public void higherQualityPredictionsMustBeLonger() {
JobRuntimePredictionClient client = mock(JobRuntimePredictionClient.class);
JobRuntimePredictions predictions = new JobRuntimePredictions("v1", modelId, new TreeSet<>(Arrays.asList(new JobRuntimePrediction(0.05, 5.1), new JobRuntimePrediction(0.25, 4.0), new JobRuntimePrediction(0.35, 4.1), new JobRuntimePrediction(0.90, 4.0))));
when(client.getRuntimePredictions(any())).thenReturn(Mono.just(predictions));
AdmissionSanitizer<JobDescriptor> sanitizer = new JobRuntimePredictionSanitizer(client, JobRuntimePredictionSelectors.best(), config, TitusRuntimes.test());
StepVerifier.create(sanitizer.sanitizeAndApply(jobDescriptor)).assertNext(result -> assertThat(((JobDescriptor<?>) result).getAttributes()).containsEntry(JOB_ATTRIBUTES_SANITIZATION_SKIPPED_RUNTIME_PREDICTION, "true").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_MODEL_ID, modelId).containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_VERSION, "v1").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_AVAILABLE, "0.05=5.1;0.25=4.0;0.35=4.1;0.9=4.0")).verifyComplete();
}
Aggregations