Search in sources :

Example 1 with CacheUpdater

use of com.netflix.titus.runtime.connector.jobmanager.replicator.GrpcJobReplicatorEventStream.CacheUpdater in project titus-control-plane by Netflix.

the class GrpcJobReplicatorEventStreamTest method testCacheSnapshotFiltersCompletedJobs.

@Test
public void testCacheSnapshotFiltersCompletedJobs() {
    Job<?> acceptedJob = JobGenerator.oneBatchJob();
    BatchJobTask acceptedTask = JobGenerator.oneBatchTask().toBuilder().withJobId(acceptedJob.getId()).withStatus(TaskStatus.newBuilder().withState(TaskState.Accepted).build()).build();
    Job<?> finishedJob = JobFunctions.changeJobStatus(acceptedJob, JobStatus.newBuilder().withState(JobState.Finished).build());
    Task finishedTask = JobFunctions.changeTaskStatus(acceptedTask, TaskStatus.newBuilder().withState(TaskState.Finished).build());
    CacheUpdater cacheUpdater = new CacheUpdater(JobSnapshotFactories.newDefault(titusRuntime), false, titusRuntime);
    assertThat(cacheUpdater.onEvent(JobUpdateEvent.newJob(acceptedJob, CallMetadataConstants.UNDEFINED_CALL_METADATA))).isEmpty();
    assertThat(cacheUpdater.onEvent(TaskUpdateEvent.newTask(acceptedJob, acceptedTask, CallMetadataConstants.UNDEFINED_CALL_METADATA))).isEmpty();
    assertThat(cacheUpdater.onEvent(TaskUpdateEvent.taskChange(acceptedJob, finishedTask, acceptedTask, CallMetadataConstants.UNDEFINED_CALL_METADATA))).isEmpty();
    assertThat(cacheUpdater.onEvent(JobUpdateEvent.jobChange(finishedJob, acceptedJob, CallMetadataConstants.UNDEFINED_CALL_METADATA))).isEmpty();
    ReplicatorEvent<JobSnapshot, JobManagerEvent<?>> snapshotEvent = cacheUpdater.onEvent(JobManagerEvent.snapshotMarker()).orElse(null);
    assertThat(snapshotEvent).isNotNull();
    assertThat(snapshotEvent.getSnapshot().getJobMap()).isEmpty();
    assertThat(snapshotEvent.getSnapshot().getTaskMap()).isEmpty();
}
Also used : BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) Task(com.netflix.titus.api.jobmanager.model.job.Task) CacheUpdater(com.netflix.titus.runtime.connector.jobmanager.replicator.GrpcJobReplicatorEventStream.CacheUpdater) JobManagerEvent(com.netflix.titus.api.jobmanager.model.job.event.JobManagerEvent) BatchJobTask(com.netflix.titus.api.jobmanager.model.job.BatchJobTask) JobSnapshot(com.netflix.titus.runtime.connector.jobmanager.snapshot.JobSnapshot) Test(org.junit.Test)

Aggregations

BatchJobTask (com.netflix.titus.api.jobmanager.model.job.BatchJobTask)1 Task (com.netflix.titus.api.jobmanager.model.job.Task)1 JobManagerEvent (com.netflix.titus.api.jobmanager.model.job.event.JobManagerEvent)1 CacheUpdater (com.netflix.titus.runtime.connector.jobmanager.replicator.GrpcJobReplicatorEventStream.CacheUpdater)1 JobSnapshot (com.netflix.titus.runtime.connector.jobmanager.snapshot.JobSnapshot)1 Test (org.junit.Test)1