Search in sources :

Example 11 with BatchJobExt

use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.

the class CassandraJobStoreTest method testDeleteJob.

@Test
public void testDeleteJob() {
    JobStore store = getJobStore();
    Job<BatchJobExt> job = createBatchJobObject();
    store.init().await();
    store.storeJob(job).await();
    Pair<List<Job<?>>, Integer> jobsAndErrors = store.retrieveJobs().toBlocking().first();
    checkRetrievedJob(job, jobsAndErrors.getLeft().get(0));
    store.deleteJob(job).await();
    jobsAndErrors = store.retrieveJobs().toBlocking().first();
    assertThat(jobsAndErrors.getLeft()).isEmpty();
}
Also used : BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) JobStore(com.netflix.titus.api.jobmanager.store.JobStore) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) IntegrationNotParallelizableTest(com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)

Example 12 with BatchJobExt

use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.

the class TestStoreLoadCommand method createJobObject.

private Job<BatchJobExt> createJobObject() {
    String jobId = UUID.randomUUID().toString();
    JobDescriptor<BatchJobExt> jobDescriptor = JobDescriptor.<BatchJobExt>newBuilder().withExtensions(new BatchJobExt(1, 1, null, false)).build();
    JobStatus status = new JobStatus(Accepted, "code", "message", System.currentTimeMillis());
    return new Job<>(jobId, jobDescriptor, status, new ArrayList<>(), Version.undefined());
}
Also used : JobStatus(com.netflix.titus.api.jobmanager.model.job.JobStatus) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) Job(com.netflix.titus.api.jobmanager.model.job.Job)

Example 13 with BatchJobExt

use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.

the class JobModelSanitizationTest method testJobWithInvalidPlatformSidecar.

@Test
public void testJobWithInvalidPlatformSidecar() {
    PlatformSidecar badPS = PlatformSidecar.newBuilder().withName("BAD_NAME").withChannel("BAD_CHANNEL").build();
    JobDescriptor<BatchJobExt> badJobDescriptor = oneTaskBatchJobDescriptor().but(jd -> jd.toBuilder().withPlatformSidecars(Collections.singletonList(badPS)).build());
    Set<ValidationError> violations = entitySanitizer.validate(badJobDescriptor);
    assertThat(violations).hasSize(2);
}
Also used : PlatformSidecar(com.netflix.titus.api.jobmanager.model.job.PlatformSidecar) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Test(org.junit.Test)

Example 14 with BatchJobExt

use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.

the class JobModelSanitizationTest method testJobWithInvalidVolume.

@Test
public void testJobWithInvalidVolume() {
    VolumeSource vs = new SaaSVolumeSource("BAD_SAAS_NAME");
    Volume badVolume = Volume.newBuilder().withName("BAD_NAME").withVolumeSource(vs).build();
    JobDescriptor<BatchJobExt> badJobDescriptor = oneTaskBatchJobDescriptor().but(jd -> jd.toBuilder().withVolumes(Collections.singletonList(badVolume)).build());
    Set<ValidationError> violations = entitySanitizer.validate(badJobDescriptor);
    assertThat(violations).hasSize(2);
}
Also used : SaaSVolumeSource(com.netflix.titus.api.jobmanager.model.job.volume.SaaSVolumeSource) VolumeSource(com.netflix.titus.api.jobmanager.model.job.volume.VolumeSource) SaaSVolumeSource(com.netflix.titus.api.jobmanager.model.job.volume.SaaSVolumeSource) Volume(com.netflix.titus.api.jobmanager.model.job.volume.Volume) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Test(org.junit.Test)

Example 15 with BatchJobExt

use of com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt in project titus-control-plane by Netflix.

the class JobDescriptorGenerator method oneTaskBatchJobDescriptor.

public static JobDescriptor<BatchJobExt> oneTaskBatchJobDescriptor() {
    JobDescriptor<BatchJobExt> jobDescriptor = batchJobDescriptors().getValue();
    Image imageWithTag = JobModel.newImage().withName("titusops/alpine").withTag("latest").build();
    return JobModel.newJobDescriptor(jobDescriptor).withContainer(JobModel.newContainer(jobDescriptor.getContainer()).withImage(imageWithTag).build()).withDisruptionBudget(DisruptionBudgetGenerator.budget(DisruptionBudgetGenerator.perTaskRelocationLimitPolicy(3), DisruptionBudgetGenerator.hourlyRatePercentage(50), Collections.singletonList(DisruptionBudgetGenerator.officeHourTimeWindow()))).withExtensions(JobModel.newBatchJobExt(jobDescriptor.getExtensions()).withSize(1).withRetryPolicy(JobModel.newImmediateRetryPolicy().withRetries(0).build()).build()).withExtraContainers(jobDescriptor.getExtraContainers()).withPlatformSidecars(jobDescriptor.getPlatformSidecars()).build();
}
Also used : BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) Image(com.netflix.titus.api.jobmanager.model.job.Image)

Aggregations

BatchJobExt (com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt)73 Test (org.junit.Test)55 Task (com.netflix.titus.api.jobmanager.model.job.Task)30 BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)25 List (java.util.List)20 ArrayList (java.util.ArrayList)19 JobStore (com.netflix.titus.api.jobmanager.store.JobStore)17 HashMap (java.util.HashMap)16 V1Affinity (io.kubernetes.client.openapi.models.V1Affinity)14 IntegrationNotParallelizableTest (com.netflix.titus.testkit.junit.category.IntegrationNotParallelizableTest)13 ServiceJobTask (com.netflix.titus.api.jobmanager.model.job.ServiceJobTask)11 V1Pod (io.kubernetes.client.openapi.models.V1Pod)11 Job (com.netflix.titus.api.jobmanager.model.job.Job)10 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)10 Container (com.netflix.titus.api.jobmanager.model.job.Container)6 Map (java.util.Map)6 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)6 V1Container (io.kubernetes.client.openapi.models.V1Container)5 BasicContainer (com.netflix.titus.api.jobmanager.model.job.BasicContainer)4 Image (com.netflix.titus.api.jobmanager.model.job.Image)4