Search in sources :

Example 6 with BatchJobExt

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

the class CassandraJobStoreTest method testRetrieveTask.

@Test
public void testRetrieveTask() {
    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));
    Task task = createTaskObject(job);
    store.storeTask(task).await();
    Task retrievedTask = store.retrieveTask(task.getId()).toBlocking().first();
    checkRetrievedTask(task, retrievedTask);
    // Check that archive access does not return anything.
    try {
        store.retrieveArchivedTask(task.getId()).toBlocking().first();
        fail("Should not return active task");
    } catch (JobStoreException e) {
        assertThat(e.getErrorCode()).isEqualTo(JobStoreException.ErrorCode.TASK_DOES_NOT_EXIST);
    }
}
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) JobStoreException(com.netflix.titus.api.jobmanager.store.JobStoreException) 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 7 with BatchJobExt

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

the class CassandraJobStoreTest method testRetrieveArchivedTask.

private void testRetrieveArchivedTask(boolean archive) {
    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();
    if (archive) {
        store.deleteTask(task).await();
    }
    Task archivedTask = store.retrieveArchivedTask(task.getId()).toBlocking().first();
    checkRetrievedTask(task, archivedTask);
}
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)

Example 8 with BatchJobExt

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

the class CassandraJobStoreTest method testRetrieveArchivedTasksForJob.

private void testRetrieveArchivedTasksForJob(boolean archive) {
    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();
    if (archive) {
        store.deleteTask(task).await();
    }
    Task archivedTask = store.retrieveArchivedTasksForJob(job.getId()).toBlocking().first();
    checkRetrievedTask(task, archivedTask);
}
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)

Example 9 with BatchJobExt

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

the class CassandraJobStoreTest method testReplaceTask.

@Test
public void testReplaceTask() {
    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));
    Task firstTask = createTaskObject(job);
    store.storeTask(firstTask).await();
    Task retrievedTask = store.retrieveTask(firstTask.getId()).toBlocking().first();
    checkRetrievedTask(firstTask, retrievedTask);
    Task secondTask = createTaskObject(job);
    store.replaceTask(firstTask, secondTask).await();
    Pair<List<Task>, Integer> tasks = store.retrieveTasksForJob(job.getId()).toBlocking().first();
    assertThat(tasks.getLeft()).hasSize(1);
    assertThat(tasks.getRight()).isEqualTo(0);
    checkRetrievedTask(secondTask, tasks.getLeft().get(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 10 with BatchJobExt

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

the class CassandraJobStoreTest method testRetrieveJobs.

@Test
public void testRetrieveJobs() {
    Session session = cassandraCqlUnit.getSession();
    JobStore bootstrappingStore = getJobStore(session);
    Job<BatchJobExt> job = createBatchJobObject();
    bootstrappingStore.storeJob(job).await();
    JobStore store = getJobStore(session);
    store.init().await();
    Pair<List<Job<?>>, Integer> jobsAndErrors = store.retrieveJobs().toBlocking().first();
    assertThat(jobsAndErrors.getLeft()).hasSize(1);
    assertThat(jobsAndErrors.getRight()).isEqualTo(0);
    checkRetrievedJob(job, jobsAndErrors.getLeft().get(0));
    // Check that archive access does not return anything.
    try {
        store.retrieveArchivedJob(job.getId()).toBlocking().first();
        fail("Should not return active job");
    } catch (JobStoreException e) {
        assertThat(e.getErrorCode()).isEqualTo(JobStoreException.ErrorCode.JOB_DOES_NOT_EXIST);
    }
}
Also used : JobStoreException(com.netflix.titus.api.jobmanager.store.JobStoreException) 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) Session(com.datastax.driver.core.Session) 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