DefaultTaintTolerationFactory implements TaintTolerationFactory { @Override public List<V1Toleration> buildV1Toleration(Job job, Task task) { List<V1Toleration> tolerations = new ArrayList<>(); tolerations.add(Tolerations.TOLERATION_VIRTUAL_KUBLET); tolerations.add(Tolerations.TOLERATION_KUBE_SCHEDULER); tolerations.add(resolveTierToleration(job)); resolveAvailabilityZoneToleration(job).ifPresent(tolerations::add); resolveGpuInstanceTypeToleration(job).ifPresent(tolerations::add); resolveKubeBackendToleration(job).ifPresent(tolerations::add); return tolerations; } @Inject  DefaultTaintTolerationFactory(DirectKubeConfiguration configuration,
                                         ApplicationSlaManagementService capacityManagement); @Override List<V1Toleration> buildV1Toleration(Job job, Task task);  }
@Test public void testGpuInstanceAssignment() { List<V1Toleration> tolerations = factory.buildV1Toleration(newGpuJob(), JobGenerator.oneBatchTask()); V1Toleration gpuToleration = tolerations.stream().filter(t -> t.getKey().equals(KubeConstants.TAINT_GPU_INSTANCE)).findFirst().orElse(null); assertThat(gpuToleration).isEqualTo(Tolerations.TOLERATION_GPU_INSTANCE); }
@Test public void testKubeBackendToleration() { List<V1Toleration> tolerations = factory.buildV1Toleration(newJobWithConstraint(JobConstraints.KUBE_BACKEND, "kublet"), JobGenerator.oneBatchTask()); V1Toleration gpuToleration = tolerations.stream().filter(t -> t.getKey().equals(KubeConstants.TAINT_KUBE_BACKEND)).findFirst().orElse(null); assertThat(gpuToleration.getKey()).isEqualTo(KubeConstants.TAINT_KUBE_BACKEND); assertThat(gpuToleration.getValue()).isEqualTo("kublet"); }