use of com.netflix.titus.common.framework.reconciler.ModelAction in project titus-control-plane by Netflix.
the class RetryActionInterceptorTest method testRetry.
@Test
public void testRetry() throws Exception {
TitusChangeAction changeAction = SampleTitusChangeActions.failingJob(2);
// First two calls should fail
ModelAction updateAction1 = expectUpdateActionOfType(changeAction, RetryActionInterceptor.RetryModelUpdateAction.class);
EntityHolder modelWithTag1 = expectAboveExecutionLimits(updateAction1, EntityHolder.newRoot("rootId", "data"));
expectBelowExecutionLimitsWhenTimeAdvanced(modelWithTag1, INITIAL_DELAY_MS);
ModelAction updateAction2 = expectUpdateActionOfType(changeAction, RetryActionInterceptor.RetryModelUpdateAction.class);
EntityHolder modelWithTag2 = expectAboveExecutionLimits(updateAction2, modelWithTag1);
expectBelowExecutionLimitsWhenTimeAdvanced(modelWithTag2, INITIAL_DELAY_MS * 2);
// Third call should succeed
ModelAction updateAction3 = expectUpdateActionOfType(changeAction, RetryActionInterceptor.RemoveRetryRecord.class);
expectNoRetryTag(updateAction3, modelWithTag2);
}
use of com.netflix.titus.common.framework.reconciler.ModelAction in project titus-control-plane by Netflix.
the class RateLimiterInterceptorTest method executeRateLimitedAction.
private ModelAction executeRateLimitedAction(TitusChangeAction changeAction) {
ExtTestSubscriber<List<ModelActionHolder>> testSubscriber = new ExtTestSubscriber<>();
rateLimiterInterceptor.apply(changeAction).apply().subscribe(testSubscriber);
ModelAction updateAction = testSubscriber.takeNext().get(0).getAction();
assertThat(updateAction).isInstanceOf(TitusModelAction.class);
return updateAction;
}
use of com.netflix.titus.common.framework.reconciler.ModelAction in project titus-control-plane by Netflix.
the class RateLimiterInterceptorTest method testRateLimiting.
@Test
public void testRateLimiting() throws Exception {
Job<BatchJobExt> job = batchJobs(JobDescriptorGenerator.oneTaskBatchJobDescriptor()).getValue();
// Use all tokens
EntityHolder nextRoot = EntityHolder.newRoot("root", job);
for (int i = 0; i < BUCKET_SIZE; i++) {
assertThat(rateLimiterInterceptor.executionLimits(nextRoot)).isEqualTo(BUCKET_SIZE - i);
ModelAction updateAction = executeRateLimitedAction(SampleTitusChangeActions.successfulJob());
nextRoot = updateAction.apply(nextRoot).get().getRight();
}
assertThat(rateLimiterInterceptor.executionLimits(nextRoot)).isEqualTo(0);
// Refill
testClock.advanceTime(REFILL_INTERVAL_MS, TimeUnit.MILLISECONDS);
assertThat(rateLimiterInterceptor.executionLimits(nextRoot)).isEqualTo(1);
}
Aggregations