use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizerTest method errorsCauseFallbackToRuntimeLimit.
@Test
public void errorsCauseFallbackToRuntimeLimit() {
JobRuntimePredictionClient errorClient = mock(JobRuntimePredictionClient.class);
when(errorClient.getRuntimePredictions(any())).thenReturn(Mono.error(TitusServiceException.internal("bad request")));
AdmissionSanitizer<JobDescriptor> sanitizer = new JobRuntimePredictionSanitizer(errorClient, 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_CONFIDENCE, "1.0").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_SEC, "60.0")).verifyComplete();
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizerTest method emptyPredictionsCauseFallbackToRuntimeLimit.
@Test
public void emptyPredictionsCauseFallbackToRuntimeLimit() {
JobRuntimePredictionClient client = mock(JobRuntimePredictionClient.class);
JobRuntimePredictions predictions = new JobRuntimePredictions("v1", modelId, new TreeSet<>());
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_RUNTIME_PREDICTION_CONFIDENCE, "1.0").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_SEC, "60.0").containsEntry(JOB_ATTRIBUTES_SANITIZATION_SKIPPED_RUNTIME_PREDICTION, "true").containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_MODEL_ID, modelId).containsEntry(JOB_ATTRIBUTES_RUNTIME_PREDICTION_VERSION, "v1").doesNotContainKeys(JOB_ATTRIBUTES_RUNTIME_PREDICTION_AVAILABLE)).verifyComplete();
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizerTest method zeroedPredictionsCauseSanitizationToBeSkipped.
@Test
public void zeroedPredictionsCauseSanitizationToBeSkipped() {
JobRuntimePredictionClient client = mock(JobRuntimePredictionClient.class);
JobRuntimePredictions predictions = new JobRuntimePredictions("v1", modelId, new TreeSet<>(Arrays.asList(new JobRuntimePrediction(0.05, 0.0), new JobRuntimePrediction(0.25, 6.0), new JobRuntimePrediction(0.90, 21.2))));
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=0.0;0.25=6.0;0.9=21.2")).verifyComplete();
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class ExtendedJobSanitizerTest method testLegacyBatchJobDisruptionBudgetRewrite.
@Test
public void testLegacyBatchJobDisruptionBudgetRewrite() {
JobDescriptor<BatchJobExt> jobDescriptor = newBatchJob().getValue().toBuilder().withDisruptionBudget(DisruptionBudget.none()).build();
ExtendedJobSanitizer sanitizer = new ExtendedJobSanitizer(configuration, jobAssertions, entitySanitizer, disruptionBudgetSanitizer, jd -> false, jd -> false, titusRuntime);
Optional<JobDescriptor<BatchJobExt>> sanitizedOpt = sanitizer.sanitize(jobDescriptor);
assertThat(sanitizedOpt).isNotEmpty();
JobDescriptor<BatchJobExt> sanitized = sanitizedOpt.get();
String nonCompliant = sanitized.getAttributes().get(TITUS_NON_COMPLIANT_FEATURES);
assertThat(nonCompliant).contains(JobFeatureComplianceChecks.DISRUPTION_BUDGET_FEATURE);
SelfManagedDisruptionBudgetPolicy policy = (SelfManagedDisruptionBudgetPolicy) sanitized.getDisruptionBudget().getDisruptionBudgetPolicy();
assertThat(policy.getRelocationTimeMs()).isEqualTo((long) ((jobDescriptor.getExtensions()).getRuntimeLimitMs() * BATCH_RUNTIME_LIMIT_FACTOR));
}
use of com.netflix.titus.api.jobmanager.model.job.JobDescriptor in project titus-control-plane by Netflix.
the class ExtendedJobSanitizerTest method testLegacyServiceJobDisruptionBudgetRewrite.
@Test
public void testLegacyServiceJobDisruptionBudgetRewrite() {
JobDescriptor<ServiceJobExt> jobDescriptor = newServiceJob().getValue().toBuilder().withDisruptionBudget(DisruptionBudget.none()).build();
ExtendedJobSanitizer sanitizer = new ExtendedJobSanitizer(configuration, jobAssertions, entitySanitizer, disruptionBudgetSanitizer, jd -> false, jd -> false, titusRuntime);
Optional<JobDescriptor<ServiceJobExt>> sanitizedOpt = sanitizer.sanitize(jobDescriptor);
assertThat(sanitizedOpt).isNotEmpty();
JobDescriptor<ServiceJobExt> sanitized = sanitizedOpt.get();
String nonCompliant = sanitized.getAttributes().get(TITUS_NON_COMPLIANT_FEATURES);
assertThat(nonCompliant).contains(JobFeatureComplianceChecks.DISRUPTION_BUDGET_FEATURE);
SelfManagedDisruptionBudgetPolicy policy = (SelfManagedDisruptionBudgetPolicy) sanitized.getDisruptionBudget().getDisruptionBudgetPolicy();
assertThat(policy.getRelocationTimeMs()).isEqualTo(DisruptionBudgetSanitizer.DEFAULT_SERVICE_RELOCATION_TIME_MS);
}
Aggregations