use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class DefaultPodAffinityFactoryTest method relocationBinPacking.
@Test
public void relocationBinPacking() {
Job<ServiceJobExt> job = JobGenerator.oneServiceJob();
job = job.toBuilder().withJobDescriptor(job.getJobDescriptor().but(jd -> jd.getDisruptionBudget().toBuilder().withDisruptionBudgetPolicy(SelfManagedDisruptionBudgetPolicy.newBuilder().build()))).build();
ServiceJobTask task = JobGenerator.oneServiceTask();
V1Affinity affinity = factory.buildV1Affinity(job, task).getLeft();
List<V1WeightedPodAffinityTerm> podAffinityTerms = affinity.getPodAffinity().getPreferredDuringSchedulingIgnoredDuringExecution();
assertThat(podAffinityTerms).hasSize(1);
V1PodAffinityTerm podAffinityTerm = podAffinityTerms.get(0).getPodAffinityTerm();
assertThat(podAffinityTerm.getTopologyKey()).isEqualTo(KubeConstants.NODE_LABEL_MACHINE_ID);
assertThat(podAffinityTerm.getLabelSelector().getMatchExpressions()).hasSize(1);
V1LabelSelectorRequirement affinityRequirement = podAffinityTerm.getLabelSelector().getMatchExpressions().get(0);
assertThat(affinityRequirement.getKey()).isEqualTo(KubeConstants.POD_LABEL_RELOCATION_BINPACK);
assertThat(affinityRequirement.getOperator()).isEqualTo(KubeConstants.SELECTOR_OPERATOR_EXISTS);
List<V1WeightedPodAffinityTerm> antiAffinityTerms = affinity.getPodAntiAffinity().getPreferredDuringSchedulingIgnoredDuringExecution();
assertThat(antiAffinityTerms).hasSize(1);
V1PodAffinityTerm antiAffinityTerm = antiAffinityTerms.get(0).getPodAffinityTerm();
assertThat(antiAffinityTerm.getTopologyKey()).isEqualTo(KubeConstants.NODE_LABEL_MACHINE_ID);
assertThat(antiAffinityTerm.getLabelSelector().getMatchExpressions()).hasSize(1);
V1LabelSelectorRequirement antiAffinityRequirement = antiAffinityTerm.getLabelSelector().getMatchExpressions().get(0);
assertThat(antiAffinityRequirement.getKey()).isEqualTo(KubeConstants.POD_LABEL_RELOCATION_BINPACK);
assertThat(antiAffinityRequirement.getOperator()).isEqualTo(KubeConstants.SELECTOR_OPERATOR_DOES_NOT_EXIST);
}
use of com.netflix.titus.api.jobmanager.model.job.ext.ServiceJobExt in project titus-control-plane by Netflix.
the class ArchivedTasksGcTest method createServiceJob.
private Job<ServiceJobExt> createServiceJob(int archivedTasksCount) {
Job<ServiceJobExt> job = JobGenerator.serviceJobs(JobDescriptorGenerator.oneTaskServiceJobDescriptor()).getValue();
jobStore.storeJob(job).get();
for (int i = 0; i < archivedTasksCount; i++) {
Task task = JobGenerator.serviceTasks(job).getValue().toBuilder().withId("task" + i).build();
task = JobFunctions.changeTaskStatus(task, TaskStatus.newBuilder().withState(TaskState.Finished).build());
jobStore.addArchivedTaskInternal(task);
}
when(jobOperations.getJobs()).thenReturn(new ArrayList<>(jobStore.getJobsInternal().values()));
return job;
}
Aggregations