use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.
the class ScalingPolicyModelSanitizationTest method testInvalidStepScalingPolicyNoAlarmConfiguration.
@Test
public void testInvalidStepScalingPolicyNoAlarmConfiguration() {
PolicyConfiguration policyConfiguration = PolicyConfiguration.newBuilder().withStepScalingPolicyConfiguration(mock(StepScalingPolicyConfiguration.class)).build();
AutoScalingPolicy autoScalingPolicy = AutoScalingPolicy.newBuilder().withPolicyConfiguration(policyConfiguration).build();
Set<ValidationError> validationErrors = newScalingPolicySanitizer().validate(autoScalingPolicy);
assertThat(validationErrors).hasSize(1);
assertThat(CollectionsExt.first(validationErrors).getDescription()).isEqualTo("alarmConfiguration must be specified for a step scaling policy");
}
use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.
the class JobAssertions method validateMatchingEbsAndIpZones.
public static Set<ValidationError> validateMatchingEbsAndIpZones(List<EbsVolume> ebsVolumes, List<SignedIpAddressAllocation> ipSignedAddressAllocations) {
if (ebsVolumes == null || ipSignedAddressAllocations == null) {
return Collections.emptySet();
}
if (ebsVolumes.isEmpty() || ipSignedAddressAllocations.isEmpty()) {
return Collections.emptySet();
}
int numElements = Math.min(ebsVolumes.size(), ipSignedAddressAllocations.size());
for (int i = 0; i < numElements; i++) {
EbsVolume ebsVolume = ebsVolumes.get(i);
IpAddressAllocation ipAddressAllocation = ipSignedAddressAllocations.get(i).getIpAddressAllocation();
if (!ebsVolume.getVolumeAvailabilityZone().equals(ipAddressAllocation.getIpAddressLocation().getAvailabilityZone())) {
return Collections.singleton(new ValidationError("containerResources.ebsVolumes", String.format("EBS volume %s zone %s conflicts with Static IP %s zone %s and index %d", ebsVolume.getVolumeId(), ebsVolume.getVolumeAvailabilityZone(), ipAddressAllocation.getAllocationId(), ipAddressAllocation.getIpAddressLocation().getAvailabilityZone(), i)));
}
}
return Collections.emptySet();
}
use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.
the class JobS3LogLocationValidator method toValidationError.
private Set<ValidationError> toValidationError(List<ValidationFailure> failures) {
Set<ValidationError> result = new HashSet<>();
failures.forEach(failure -> {
result.add(new ValidationError(JobAttributes.JOB_CONTAINER_ATTRIBUTE_S3_BUCKET_NAME, String.format("Access denied: errorCode=%s, errorMessage=%s", failure.getErrorCode(), failure.getErrorMessage())));
});
return result;
}
use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.
the class JobModelSanitizationTest method testJobWithInvalidPlatformSidecar.
@Test
public void testJobWithInvalidPlatformSidecar() {
PlatformSidecar badPS = PlatformSidecar.newBuilder().withName("BAD_NAME").withChannel("BAD_CHANNEL").build();
JobDescriptor<BatchJobExt> badJobDescriptor = oneTaskBatchJobDescriptor().but(jd -> jd.toBuilder().withPlatformSidecars(Collections.singletonList(badPS)).build());
Set<ValidationError> violations = entitySanitizer.validate(badJobDescriptor);
assertThat(violations).hasSize(2);
}
use of com.netflix.titus.common.model.sanitizer.ValidationError in project titus-control-plane by Netflix.
the class JobModelSanitizationTest method testJobWithInvalidVolume.
@Test
public void testJobWithInvalidVolume() {
VolumeSource vs = new SaaSVolumeSource("BAD_SAAS_NAME");
Volume badVolume = Volume.newBuilder().withName("BAD_NAME").withVolumeSource(vs).build();
JobDescriptor<BatchJobExt> badJobDescriptor = oneTaskBatchJobDescriptor().but(jd -> jd.toBuilder().withVolumes(Collections.singletonList(badVolume)).build());
Set<ValidationError> violations = entitySanitizer.validate(badJobDescriptor);
assertThat(violations).hasSize(2);
}
Aggregations