use of com.netflix.titus.common.framework.scheduler.ScheduleReference in project titus-control-plane by Netflix.
the class DefaultLocalSchedulerTest method testTimeout.
@Test
public void testTimeout() throws Exception {
ScheduleReference reference = localScheduler.scheduleMono(scheduleDescriptor.toBuilder().withName("testTimeout").build(), tick -> Mono.never(), Schedulers.parallel());
expectScheduleAdded(reference);
expectScheduleUpdateEvent(SchedulingState.Running);
expectScheduleUpdateEvent(SchedulingState.Failed);
// Replacement
expectScheduleUpdateEvent(SchedulingState.Waiting);
assertThat(reference.getSchedule().getCompletedActions()).hasSize(1);
ScheduledAction failedAction = reference.getSchedule().getCompletedActions().get(0);
assertThat(failedAction.getStatus().getState()).isEqualTo(SchedulingState.Failed);
assertThat(failedAction.getStatus().getError().get()).isInstanceOf(TimeoutException.class);
}
use of com.netflix.titus.common.framework.scheduler.ScheduleReference in project titus-control-plane by Netflix.
the class DefaultLocalSchedulerTest method testScheduleAction.
@Test(timeout = 60_000)
public void testScheduleAction() throws Exception {
AtomicLong tickCounter = new AtomicLong();
ScheduleReference reference = localScheduler.schedule(scheduleDescriptor.toBuilder().withName("testScheduleAction").build(), t -> tickCounter.incrementAndGet(), true);
testExecutionLifecycle(reference, tickCounter);
}
use of com.netflix.titus.common.framework.scheduler.ScheduleReference in project titus-control-plane by Netflix.
the class DefaultLocalSchedulerTest method testScheduleMono.
@Test(timeout = 60_000)
public void testScheduleMono() throws Exception {
AtomicLong tickCounter = new AtomicLong();
ScheduleReference reference = localScheduler.scheduleMono(scheduleDescriptor.toBuilder().withName("testScheduleMono").build(), tick -> Mono.delay(Duration.ofMillis(1)).flatMap(t -> {
tickCounter.incrementAndGet();
return Mono.empty();
}), Schedulers.parallel());
testExecutionLifecycle(reference, tickCounter);
}
use of com.netflix.titus.common.framework.scheduler.ScheduleReference in project titus-control-plane by Netflix.
the class DefaultLocalSchedulerPerf method newMonoAction.
private ScheduleReference newMonoAction(boolean failSometimes) {
int intervalMs = 50;
ScheduleReference reference = localScheduler.scheduleMono(ScheduleDescriptor.newBuilder().withName("monoAction").withDescription("Test...").withInterval(Duration.ofMillis(intervalMs)).withTimeout(Duration.ofSeconds(1)).build(), context -> {
checkSchedulingLatency(intervalMs, context);
if (context.getExecutionId().getTotal() > EXECUTIONS) {
localScheduler.cancel(context.getId()).subscribe();
return Mono.empty();
}
if (failSometimes && context.getExecutionId().getTotal() % 2 == 0) {
expectedFailures.incrementAndGet();
return Mono.error(new RuntimeException("Simulated error"));
}
return Mono.delay(Duration.ofMillis(10)).ignoreElement().cast(Void.class).doOnError(Throwable::printStackTrace).doOnSuccess(next -> successes.incrementAndGet());
}, Schedulers.parallel());
observeEvents(reference);
return reference;
}
use of com.netflix.titus.common.framework.scheduler.ScheduleReference in project titus-control-plane by Netflix.
the class DefaultLocalSchedulerPerf method observeEvents.
private void observeEvents(ScheduleReference reference) {
localScheduler.events().filter(e -> e.getSchedule().getId().equals(reference.getSchedule().getId())).subscribe(event -> {
if (event instanceof ScheduleUpdateEvent) {
ScheduleUpdateEvent updateEvent = (ScheduleUpdateEvent) event;
ScheduledAction action = updateEvent.getSchedule().getCurrentAction();
if (action.getStatus().getState() == SchedulingStatus.SchedulingState.Failed) {
eventFailures.incrementAndGet();
}
} else if (event instanceof ScheduleRemovedEvent) {
removedEvents.incrementAndGet();
}
});
}
Aggregations