use of com.netflix.titus.common.model.admission.AdmissionValidator in project titus-control-plane by Netflix.
the class AggregatingValidatorTest method validateHardSoftTimeout.
// Hard/Soft validation tests
@Test
public void validateHardSoftTimeout() {
AdmissionValidator<JobDescriptor> never0 = new NeverJobValidator(ValidationError.Type.HARD);
AdmissionValidator never1 = new NeverJobValidator(ValidationError.Type.SOFT);
AdmissionValidator validator = new AggregatingValidator(configuration, registry, Arrays.asList(never0, never1));
Mono<Set<ValidationError>> mono = validator.validate(MOCK_JOB);
StepVerifier.create(mono).expectNextMatches(errors -> errors.size() == 2).verifyComplete();
Collection<ValidationError> errors = mono.block();
validateTimeoutErrors(errors);
Collection<ValidationError> hardErrors = errors.stream().filter(error -> error.getType().equals(ValidationError.Type.HARD)).collect(Collectors.toList());
assertThat(hardErrors).hasSize(1);
Collection<ValidationError> softErrors = errors.stream().filter(error -> error.getType().equals(ValidationError.Type.SOFT)).collect(Collectors.toList());
assertThat(softErrors).hasSize(1);
}
use of com.netflix.titus.common.model.admission.AdmissionValidator in project titus-control-plane by Netflix.
the class AggregatingValidatorTest method validateSoftTimeout.
// Soft validation tests
@Test
public void validateSoftTimeout() {
AdmissionValidator never = new NeverJobValidator(ValidationError.Type.SOFT);
AdmissionValidator validator = new AggregatingValidator(configuration, registry, Arrays.asList(never));
Mono<Set<ValidationError>> mono = validator.validate(MOCK_JOB);
StepVerifier.create(mono).expectNextMatches(errors -> errors.size() == 1).verifyComplete();
Collection<ValidationError> errors = mono.block();
validateTimeoutErrors(errors);
validateErrorType(errors, ValidationError.Type.SOFT);
}
use of com.netflix.titus.common.model.admission.AdmissionValidator in project titus-control-plane by Netflix.
the class AggregatingValidatorTest method validateSoftPass.
@Test
public void validateSoftPass() {
AdmissionValidator pass = new PassJobValidator();
AdmissionValidator validator = new AggregatingValidator(configuration, registry, Arrays.asList(pass));
Mono<Set<ValidationError>> mono = validator.validate(MOCK_JOB);
StepVerifier.create(mono).expectNextMatches(errors -> errors.size() == 0).verifyComplete();
}
use of com.netflix.titus.common.model.admission.AdmissionValidator in project titus-control-plane by Netflix.
the class AggregatingValidatorTest method validateHardPassFailTimeout.
@Test
public void validateHardPassFailTimeout() {
AdmissionValidator pass = new PassJobValidator();
AdmissionValidator fail = new FailJobValidator();
AdmissionValidator never = new NeverJobValidator();
AdmissionValidator parallelValidator = new AggregatingValidator(configuration, registry, Arrays.asList(pass, fail, never));
Mono<Set<ValidationError>> mono = parallelValidator.validate(MOCK_JOB);
StepVerifier.create(mono).expectNextMatches(errors -> errors.size() == 2).verifyComplete();
Set<ValidationError> errors = mono.block();
validateErrorType(errors, ValidationError.Type.HARD);
Collection<ValidationError> failErrors = errors.stream().filter(error -> error.getField().equals(FailJobValidator.ERR_FIELD)).collect(Collectors.toList());
assertThat(failErrors).hasSize(1);
validateFailErrors(failErrors);
Collection<ValidationError> timeoutErrors = errors.stream().filter(error -> error.getField().equals(NeverJobValidator.class.getSimpleName())).collect(Collectors.toList());
assertThat(timeoutErrors).hasSize(1);
validateTimeoutErrors(timeoutErrors);
}
use of com.netflix.titus.common.model.admission.AdmissionValidator in project titus-control-plane by Netflix.
the class AggregatingValidatorTest method validateHardFailFail.
@Test
public void validateHardFailFail() {
AdmissionValidator fail0 = new FailJobValidator(ValidationError.Type.HARD);
AdmissionValidator fail1 = new FailJobValidator(ValidationError.Type.HARD);
AggregatingValidator validator = new AggregatingValidator(configuration, registry, Arrays.asList(fail0, fail1));
Mono<Set<ValidationError>> mono = validator.validate(MOCK_JOB);
StepVerifier.create(mono).expectNextMatches(errors -> errors.size() == 2).verifyComplete();
Set<ValidationError> errors = mono.block();
validateFailErrors(errors);
validateErrorType(errors, ValidationError.Type.HARD);
}
Aggregations