Search in sources :

Example 1 with BatchJobExt

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

the class CachedBatchJobTest method initialSnapshot.

/**
 * Create a snapshot with a single job and size == taskCount. Create up to tasksCreated tasks, leaving
 * the remaining slots empty.
 */
private Triple<PCollectionJobSnapshot, Map<Integer, Task>, Map<Integer, Task>> initialSnapshot(int taskCount, int tasksCreated) {
    Pair<Job<BatchJobExt>, PMap<String, Task>> jobAndTasks = newBatchJobWithTasks(0, taskCount);
    Job<BatchJobExt> job = jobAndTasks.getLeft();
    Map<Integer, Task> tasksByIndex = new HashMap<>();
    Map<String, Task> tasks = new HashMap<>(jobAndTasks.getRight());
    Map<Integer, Task> skipped = new HashMap<>();
    Iterator<Task> it = tasks.values().iterator();
    while (it.hasNext()) {
        Task task = it.next();
        int index = CachedBatchJob.indexOf(task, taskCount, titusRuntime);
        if (index >= tasksCreated) {
            it.remove();
            skipped.put(index, task);
        } else {
            tasksByIndex.put(index, task);
        }
    }
    PCollectionJobSnapshot snapshot = PCollectionJobSnapshot.newInstance("test", Collections.singletonMap(job.getId(), job), Collections.singletonMap(job.getId(), tasks), false, false, error -> {
        throw new IllegalStateException(error);
    }, titusRuntime);
    return Triple.of(snapshot, tasksByIndex, skipped);
}
Also used : Task(com.netflix.titus.api.jobmanager.model.job.Task) HashMap(java.util.HashMap) BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) PMap(org.pcollections.PMap) Job(com.netflix.titus.api.jobmanager.model.job.Job)

Example 2 with BatchJobExt

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

the class CassandraJobStoreTest method testRetrieveArchivedJob.

private void testRetrieveArchivedJob(boolean archive) {
    JobStore store = getJobStore();
    Job<BatchJobExt> job = createFinishedBatchJobObject();
    store.init().await();
    store.storeJob(job).await();
    if (archive) {
        store.deleteJob(job).await();
    }
    Job archivedJob = store.retrieveArchivedJob(job.getId()).toBlocking().first();
    checkRetrievedJob(job, archivedJob);
}
Also used : BatchJobExt(com.netflix.titus.api.jobmanager.model.job.ext.BatchJobExt) JobStore(com.netflix.titus.api.jobmanager.store.JobStore) Job(com.netflix.titus.api.jobmanager.model.job.Job)

Example 3 with BatchJobExt

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

the class CassandraJobStoreTest method testRetrieveArchivedTaskCountForJob.

@Test
public void testRetrieveArchivedTaskCountForJob() {
    JobStore store = getJobStore();
    Job<BatchJobExt> job = createFinishedBatchJobObject();
    store.init().await();
    store.storeJob(job).await();
    Pair<List<Job<?>>, Integer> jobsAndErrors = store.retrieveJobs().toBlocking().first();
    checkRetrievedJob(job, jobsAndErrors.getLeft().get(0));
    Task task = createFinishedTaskObject(job);
    store.storeTask(task).await();
    store.deleteTask(task).await();
    Long count = store.retrieveArchivedTaskCountForJob(job.getId()).toBlocking().first();
    assertThat(count).isEqualTo(1);
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) Task(com.netflix.titus.api.jobmanager.model.job.Task) ServiceJobTask(com.netflix.titus.api.jobmanager.model.job.ServiceJobTask) 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 4 with BatchJobExt

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

the class CassandraJobStoreTest method testDeleteArchivedTask.

@Test
public void testDeleteArchivedTask() {
    JobStore store = getJobStore();
    Job<BatchJobExt> job = createFinishedBatchJobObject();
    store.init().await();
    store.storeJob(job).await();
    Pair<List<Job<?>>, Integer> jobsAndErrors = store.retrieveJobs().toBlocking().first();
    checkRetrievedJob(job, jobsAndErrors.getLeft().get(0));
    Task task = createFinishedTaskObject(job);
    store.storeTask(task).await();
    store.deleteTask(task).await();
    Long count = store.retrieveArchivedTaskCountForJob(job.getId()).toBlocking().first();
    assertThat(count).isEqualTo(1);
    store.deleteArchivedTask(job.getId(), task.getId()).await();
    Long count2 = store.retrieveArchivedTaskCountForJob(job.getId()).toBlocking().first();
    assertThat(count2).isEqualTo(0);
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) Task(com.netflix.titus.api.jobmanager.model.job.Task) ServiceJobTask(com.netflix.titus.api.jobmanager.model.job.ServiceJobTask) 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 5 with BatchJobExt

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

the class CassandraJobStoreTest method testStoreJob.

@Test
public void testStoreJob() {
    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));
}
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)

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