Search in sources :

Example 1 with ScheduleUpdateEvent

use of com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent in project titus-control-plane by Netflix.

the class DefaultLocalSchedulerTest method expectScheduleUpdateEvent.

private ScheduleUpdateEvent expectScheduleUpdateEvent(SchedulingState expectedState) throws InterruptedException {
    LocalSchedulerEvent event = eventSubscriber.takeNext(Duration.ofSeconds(5));
    assertThat(event).isInstanceOf(ScheduleUpdateEvent.class);
    assertThat(event.getSchedule().getCurrentAction().getStatus().getState()).isEqualTo(expectedState);
    return (ScheduleUpdateEvent) event;
}
Also used : LocalSchedulerEvent(com.netflix.titus.common.framework.scheduler.model.event.LocalSchedulerEvent) ScheduleUpdateEvent(com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent)

Example 2 with ScheduleUpdateEvent

use of com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent in project titus-control-plane by Netflix.

the class LocalSchedulerTransactionLoggerTest method testDoFormatScheduleFailureUpdate.

@Test
public void testDoFormatScheduleFailureUpdate() {
    Schedule schedule = updateStatus(REFERENCE_SCHEDULE, newSchedulingStatus(SchedulingState.Failed));
    verify(LocalSchedulerTransactionLogger.doFormat(new ScheduleUpdateEvent(schedule)));
}
Also used : Schedule(com.netflix.titus.common.framework.scheduler.model.Schedule) ScheduleUpdateEvent(com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent) Test(org.junit.Test)

Example 3 with ScheduleUpdateEvent

use of com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent in project titus-control-plane by Netflix.

the class LocalSchedulerTransactionLoggerTest method testDoFormatScheduleSuccessUpdate.

@Test
public void testDoFormatScheduleSuccessUpdate() {
    Schedule schedule = updateStatus(REFERENCE_SCHEDULE, newSchedulingStatus(SchedulingState.Succeeded));
    verify(LocalSchedulerTransactionLogger.doFormat(new ScheduleUpdateEvent(schedule)));
}
Also used : Schedule(com.netflix.titus.common.framework.scheduler.model.Schedule) ScheduleUpdateEvent(com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent) Test(org.junit.Test)

Example 4 with ScheduleUpdateEvent

use of com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent in project titus-control-plane by Netflix.

the class DefaultLocalSchedulerTest method testExecutionLifecycle.

private void testExecutionLifecycle(ScheduleReference reference, AtomicLong tickCounter) throws InterruptedException {
    // Schedule, and first iteration
    expectScheduleAdded(reference);
    expectScheduleUpdateEvent(SchedulingState.Running);
    expectScheduleUpdateEvent(SchedulingState.Succeeded);
    assertThat(tickCounter.get()).isGreaterThan(0);
    // Next running
    expectScheduleUpdateEvent(SchedulingState.Waiting);
    expectScheduleUpdateEvent(SchedulingState.Running);
    ScheduleUpdateEvent succeededEvent2 = expectScheduleUpdateEvent(SchedulingState.Succeeded);
    assertThat(succeededEvent2.getSchedule().getCompletedActions()).hasSize(1);
    // Now cancel it
    assertThat(reference.isClosed()).isFalse();
    reference.cancel();
    await().atMost(30, TimeUnit.SECONDS).until(reference::isClosed);
    assertThat(reference.getSchedule().getCurrentAction().getStatus().getState().isFinal()).isTrue();
    assertThat(localScheduler.getActiveSchedules()).isEmpty();
    assertThat(localScheduler.getArchivedSchedules()).hasSize(1);
    expectScheduleRemoved(reference);
}
Also used : ScheduleUpdateEvent(com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent)

Example 5 with ScheduleUpdateEvent

use of com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent in project titus-control-plane by Netflix.

the class LocalSchedulerTransactionLoggerTest method testDoFormatScheduleRunningUpdate.

@Test
public void testDoFormatScheduleRunningUpdate() {
    Schedule schedule = updateStatus(REFERENCE_SCHEDULE, newSchedulingStatus(SchedulingState.Running));
    verify(LocalSchedulerTransactionLogger.doFormat(new ScheduleUpdateEvent(schedule)));
}
Also used : Schedule(com.netflix.titus.common.framework.scheduler.model.Schedule) ScheduleUpdateEvent(com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent) Test(org.junit.Test)

Aggregations

ScheduleUpdateEvent (com.netflix.titus.common.framework.scheduler.model.event.ScheduleUpdateEvent)7 Schedule (com.netflix.titus.common.framework.scheduler.model.Schedule)4 Test (org.junit.Test)4 DefaultRegistry (com.netflix.spectator.api.DefaultRegistry)1 ExecutionContext (com.netflix.titus.common.framework.scheduler.ExecutionContext)1 LocalScheduler (com.netflix.titus.common.framework.scheduler.LocalScheduler)1 ScheduleReference (com.netflix.titus.common.framework.scheduler.ScheduleReference)1 ScheduleDescriptor (com.netflix.titus.common.framework.scheduler.model.ScheduleDescriptor)1 ScheduledAction (com.netflix.titus.common.framework.scheduler.model.ScheduledAction)1 SchedulingStatus (com.netflix.titus.common.framework.scheduler.model.SchedulingStatus)1 LocalSchedulerEvent (com.netflix.titus.common.framework.scheduler.model.event.LocalSchedulerEvent)1 ScheduleRemovedEvent (com.netflix.titus.common.framework.scheduler.model.event.ScheduleRemovedEvent)1 Clocks (com.netflix.titus.common.util.time.Clocks)1 Duration (java.time.Duration)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Mono (reactor.core.publisher.Mono)1 Schedulers (reactor.core.scheduler.Schedulers)1