Search in sources :

Example 16 with ValidationError

use of com.netflix.titus.common.model.sanitizer.ValidationError 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);
}
Also used : Arrays(java.util.Arrays) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) TitusValidatorConfiguration(com.netflix.titus.common.model.admission.TitusValidatorConfiguration) StepVerifier(reactor.test.StepVerifier) Collection(java.util.Collection) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Set(java.util.Set) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) Mockito.when(org.mockito.Mockito.when) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Collectors(java.util.stream.Collectors) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) Duration(java.time.Duration) Registry(com.netflix.spectator.api.Registry) AdmissionValidator(com.netflix.titus.common.model.admission.AdmissionValidator) Collections(java.util.Collections) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) Set(java.util.Set) AdmissionValidator(com.netflix.titus.common.model.admission.AdmissionValidator) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Test(org.junit.Test)

Example 17 with ValidationError

use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.

the class AggregatingValidatorTest method validateHardSoftPass.

@Test
public void validateHardSoftPass() {
    AdmissionValidator pass0 = new PassJobValidator();
    AdmissionValidator pass1 = new PassJobValidator();
    AdmissionValidator validator = new AggregatingValidator(configuration, registry, Arrays.asList(pass0, pass1));
    Mono<Set<ValidationError>> mono = validator.validate(MOCK_JOB);
    StepVerifier.create(mono).expectNextMatches(errors -> errors.size() == 0).verifyComplete();
}
Also used : Arrays(java.util.Arrays) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) TitusValidatorConfiguration(com.netflix.titus.common.model.admission.TitusValidatorConfiguration) StepVerifier(reactor.test.StepVerifier) Collection(java.util.Collection) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Set(java.util.Set) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) Mockito.when(org.mockito.Mockito.when) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Collectors(java.util.stream.Collectors) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) Duration(java.time.Duration) Registry(com.netflix.spectator.api.Registry) AdmissionValidator(com.netflix.titus.common.model.admission.AdmissionValidator) Collections(java.util.Collections) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) Set(java.util.Set) AdmissionValidator(com.netflix.titus.common.model.admission.AdmissionValidator) Test(org.junit.Test)

Example 18 with ValidationError

use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.

the class AggregatingValidatorTest method validateHardPassFail.

@Test
public void validateHardPassFail() {
    AdmissionValidator pass = new PassJobValidator();
    AdmissionValidator fail = new FailJobValidator(ValidationError.Type.HARD);
    AggregatingValidator validator = new AggregatingValidator(configuration, registry, Arrays.asList(pass, fail));
    Mono<Set<ValidationError>> mono = validator.validate(MOCK_JOB);
    StepVerifier.create(mono).expectNextMatches(errors -> errors.size() == 1).verifyComplete();
    Set<ValidationError> errors = mono.block();
    validateFailErrors(errors);
    validateErrorType(errors, ValidationError.Type.HARD);
}
Also used : Arrays(java.util.Arrays) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) TitusValidatorConfiguration(com.netflix.titus.common.model.admission.TitusValidatorConfiguration) StepVerifier(reactor.test.StepVerifier) Collection(java.util.Collection) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Set(java.util.Set) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) Mockito.when(org.mockito.Mockito.when) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Collectors(java.util.stream.Collectors) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) Duration(java.time.Duration) Registry(com.netflix.spectator.api.Registry) AdmissionValidator(com.netflix.titus.common.model.admission.AdmissionValidator) Collections(java.util.Collections) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) Set(java.util.Set) AdmissionValidator(com.netflix.titus.common.model.admission.AdmissionValidator) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Test(org.junit.Test)

Example 19 with ValidationError

use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.

the class AggregatingValidatorTest method validateSoftFailure.

@Test
public void validateSoftFailure() {
    AdmissionValidator fail = new FailJobValidator(ValidationError.Type.HARD);
    AdmissionValidator validator = new AggregatingValidator(configuration, registry, Arrays.asList(fail));
    Mono<Set<ValidationError>> mono = validator.validate(MOCK_JOB);
    StepVerifier.create(mono).expectNextMatches(errors -> errors.size() == 1).verifyComplete();
    Collection<ValidationError> errors = mono.block();
    validateFailErrors(errors);
    validateErrorType(errors, ValidationError.Type.HARD);
}
Also used : Arrays(java.util.Arrays) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) TitusValidatorConfiguration(com.netflix.titus.common.model.admission.TitusValidatorConfiguration) StepVerifier(reactor.test.StepVerifier) Collection(java.util.Collection) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Set(java.util.Set) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) Mockito.when(org.mockito.Mockito.when) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Collectors(java.util.stream.Collectors) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) Duration(java.time.Duration) Registry(com.netflix.spectator.api.Registry) AdmissionValidator(com.netflix.titus.common.model.admission.AdmissionValidator) Collections(java.util.Collections) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) Set(java.util.Set) AdmissionValidator(com.netflix.titus.common.model.admission.AdmissionValidator) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Test(org.junit.Test)

Example 20 with ValidationError

use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.

the class AggregatingValidatorTest method validateHardSoftFail.

@Test
public void validateHardSoftFail() {
    AdmissionValidator fail0 = new FailJobValidator(ValidationError.Type.HARD);
    AdmissionValidator fail1 = new FailJobValidator(ValidationError.Type.HARD);
    AdmissionValidator 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();
    Collection<ValidationError> errors = mono.block();
    validateFailErrors(errors);
    assertThat(errors).allMatch(error -> error.getType().equals(ValidationError.Type.HARD));
}
Also used : Arrays(java.util.Arrays) JobDescriptor(com.netflix.titus.api.jobmanager.model.job.JobDescriptor) TitusValidatorConfiguration(com.netflix.titus.common.model.admission.TitusValidatorConfiguration) StepVerifier(reactor.test.StepVerifier) Collection(java.util.Collection) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Set(java.util.Set) Test(org.junit.Test) Mono(reactor.core.publisher.Mono) Mockito.when(org.mockito.Mockito.when) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Collectors(java.util.stream.Collectors) DefaultRegistry(com.netflix.spectator.api.DefaultRegistry) Duration(java.time.Duration) Registry(com.netflix.spectator.api.Registry) AdmissionValidator(com.netflix.titus.common.model.admission.AdmissionValidator) Collections(java.util.Collections) Before(org.junit.Before) Mockito.mock(org.mockito.Mockito.mock) Set(java.util.Set) AdmissionValidator(com.netflix.titus.common.model.admission.AdmissionValidator) ValidationError(com.netflix.titus.common.model.sanitizer.ValidationError) Test(org.junit.Test)

Aggregations

ValidationError (com.netflix.titus.common.model.sanitizer.ValidationError)24 Test (org.junit.Test)14 DefaultRegistry (com.netflix.spectator.api.DefaultRegistry)10 Registry (com.netflix.spectator.api.Registry)10 JobDescriptor (com.netflix.titus.api.jobmanager.model.job.JobDescriptor)10 AdmissionValidator (com.netflix.titus.common.model.admission.AdmissionValidator)10 TitusValidatorConfiguration (com.netflix.titus.common.model.admission.TitusValidatorConfiguration)10 Duration (java.time.Duration)10 Arrays (java.util.Arrays)10 Collection (java.util.Collection)10 Collections (java.util.Collections)10 Set (java.util.Set)10 Collectors (java.util.stream.Collectors)10 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)10 Before (org.junit.Before)10 Mockito.mock (org.mockito.Mockito.mock)10 Mockito.when (org.mockito.Mockito.when)10 Mono (reactor.core.publisher.Mono)10 StepVerifier (reactor.test.StepVerifier)10 AutoScalingPolicy (com.netflix.titus.api.appscale.model.AutoScalingPolicy)2