use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class JobRuntimePredictionSanitizerTest method emptyPredictionsCauseSanitizationToBeSkipped.
@Test
public void emptyPredictionsCauseSanitizationToBeSkipped() {
JobDescriptor<BatchJobExt> noRuntimeLimit = jobDescriptor.but(jd -> jd.getExtensions().toBuilder().withRuntimeLimitMs(0));
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(noRuntimeLimit)).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").doesNotContainKeys(JOB_ATTRIBUTES_RUNTIME_PREDICTION_SEC, JOB_ATTRIBUTES_RUNTIME_PREDICTION_CONFIDENCE, JOB_ATTRIBUTES_RUNTIME_PREDICTION_AVAILABLE)).verifyComplete();
}
use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class CachedBatchJobWithOneTaskTest method testInitial.
@Test
public void testInitial() {
Pair<Job<BatchJobExt>, PMap<String, Task>> jobAndTasks = newBatchJobWithTasks(0, 1);
Job<BatchJobExt> job = jobAndTasks.getLeft();
PMap<String, Task> tasks = jobAndTasks.getRight();
// Create finished task for slot 0 to test filtering.
Task task = CollectionsExt.first(tasks.values());
Task finishedTask = task.toBuilder().withId("finishedTaskId").withStatus(TaskStatus.newBuilder().withState(TaskState.Finished).build()).withVersion(Version.newBuilder().withTimestamp(task.getVersion().getTimestamp() - 1_000).build()).build();
tasks = tasks.plus(finishedTask.getId(), finishedTask);
CachedJob cached1 = CachedBatchJobWithOneTask.newBatchInstance(job, tasks, titusRuntime);
assertThat(cached1.getJob()).isEqualTo(job);
assertThat(cached1.getTasks()).hasSize(1);
assertThat(cached1.getTasks()).containsValue(task);
}
use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class CachedBatchJobWithOneTaskTest method initialSnapshot.
private Pair<PCollectionJobSnapshot, Task> initialSnapshot(boolean create) {
Pair<Job<BatchJobExt>, PMap<String, Task>> jobAndTasks = newBatchJobWithTasks(0, 1);
Job<BatchJobExt> job = jobAndTasks.getLeft();
Task task = CollectionsExt.first(jobAndTasks.getRight().values());
PCollectionJobSnapshot snapshot = PCollectionJobSnapshot.newInstance("test", Collections.singletonMap(job.getId(), job), Collections.singletonMap(job.getId(), create ? Collections.singletonMap(task.getId(), task) : Collections.emptyMap()), false, false, error -> {
throw new IllegalStateException(error);
}, titusRuntime);
return Pair.of(snapshot, task);
}
use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class JobSnapshotPerf method newJobWithTasks.
private Pair<Job<?>, Map<String, Task>> newJobWithTasks() {
Job<BatchJobExt> job = JobGenerator.oneBatchJob().toBuilder().withId("job#" + jobIdx.getAndIncrement()).build();
Map<String, Task> tasks = new HashMap<>();
for (int t = 0; t < taskPerJobCount; t++) {
BatchJobTask task = newTask(job);
tasks.put(task.getId(), task);
}
return Pair.of(job, tasks);
}
use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.
the class JobScenarioBuilder method updateJobCapacityDesiredInvalid.
public JobScenarioBuilder updateJobCapacityDesiredInvalid(int targetDesired, int currentDesired) {
logger.info("[{}] Changing job {} capacity desired to {}...", discoverActiveTest(), jobId, targetDesired);
TestStreamObserver<Empty> responseObserver = new TestStreamObserver<>();
client.updateJobCapacityWithOptionalAttributes(JobCapacityUpdateWithOptionalAttributes.newBuilder().setJobId(jobId).setJobCapacityWithOptionalAttributes(JobCapacityWithOptionalAttributes.newBuilder().setDesired(UInt32Value.newBuilder().setValue(targetDesired).build()).build()).build(), responseObserver);
await().timeout(TIMEOUT_MS, TimeUnit.MILLISECONDS).until(responseObserver::hasError);
Throwable error = responseObserver.getError();
assertThat(error).isNotNull();
assertThat(error).isInstanceOf(StatusRuntimeException.class);
StatusRuntimeException statusRuntimeException = (StatusRuntimeException) error;
assertThat(statusRuntimeException.getStatus().getCode() == Status.Code.INVALID_ARGUMENT).isTrue();
// Make sure desired count is unchanged
Job job = getJob();
JobDescriptor.JobDescriptorExt ext = job.getJobDescriptor().getExtensions();
int currentCapacity = ext instanceof BatchJobExt ? ((BatchJobExt) ext).getSize() : ((ServiceJobExt) ext).getCapacity().getDesired();
assertThat(currentCapacity).isEqualTo(currentDesired);
return this;
}
Aggregations