use of org.ovirt.engine.core.bll.validator.HostNetworkQosValidator in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidateQosOverriddenInterfacesWhenAttachmentHasQosOverriddenAndRequiredValuesNotPresent.
@Test
public void testValidateQosOverriddenInterfacesWhenAttachmentHasQosOverriddenAndRequiredValuesNotPresent() {
EngineMessage hostNetworkQosValidatorFailure = EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_SETUP_NETWORKS_MISSING_VALUES;
Network network = createNetworkWithName("network");
HostSetupNetworksValidator validator = createValidatorForTestingValidateQosOverridden(network);
HostSetupNetworksValidator validatorSpy = spy(validator);
HostNetworkQosValidator hostNetworkQosValidatorMock = mock(HostNetworkQosValidator.class);
when(hostNetworkQosValidatorMock.requiredQosValuesPresentForOverriding(eq(network.getName()))).thenReturn(new ValidationResult(hostNetworkQosValidatorFailure));
doReturn(hostNetworkQosValidatorMock).when(validatorSpy).createHostNetworkQosValidator(any());
assertThat(validatorSpy.validateQosOverriddenInterfaces(), ValidationResultMatchers.failsWith(hostNetworkQosValidatorFailure));
verify(hostNetworkQosValidatorMock).requiredQosValuesPresentForOverriding(eq(network.getName()));
verifyNoMoreInteractions(hostNetworkQosValidatorMock);
}
use of org.ovirt.engine.core.bll.validator.HostNetworkQosValidator in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidateQosOverriddenInterfacesWhenAttachmentHasQosOverriddenAndRequiredValuesPresentButInconsistent.
@Test
public void testValidateQosOverriddenInterfacesWhenAttachmentHasQosOverriddenAndRequiredValuesPresentButInconsistent() {
EngineMessage hostNetworkQosValidatorFailure = EngineMessage.ACTION_TYPE_FAILED_HOST_NETWORK_QOS_INCONSISTENT_VALUES;
Network network = createNetworkWithName("network");
HostSetupNetworksValidator validator = createValidatorForTestingValidateQosOverridden(network);
HostSetupNetworksValidator validatorSpy = spy(validator);
HostNetworkQosValidator hostNetworkQosValidatorMock = mock(HostNetworkQosValidator.class);
when(hostNetworkQosValidatorMock.valuesConsistent(eq(network.getName()))).thenReturn(new ValidationResult(hostNetworkQosValidatorFailure));
doReturn(hostNetworkQosValidatorMock).when(validatorSpy).createHostNetworkQosValidator(any());
assertThat(validatorSpy.validateQosOverriddenInterfaces(), ValidationResultMatchers.failsWith(hostNetworkQosValidatorFailure));
verify(hostNetworkQosValidatorMock).requiredQosValuesPresentForOverriding(eq(network.getName()));
verify(hostNetworkQosValidatorMock).valuesConsistent(eq(network.getName()));
verifyNoMoreInteractions(hostNetworkQosValidatorMock);
}
use of org.ovirt.engine.core.bll.validator.HostNetworkQosValidator in project ovirt-engine by oVirt.
the class HostSetupNetworksValidator method validateQosOverriddenInterfaces.
/**
* Validates that the feature is supported if any QoS configuration was specified, and that the values associated
* with it are valid.
*/
ValidationResult validateQosOverriddenInterfaces() {
for (NetworkAttachment networkAttachment : params.getNetworkAttachments()) {
if (networkAttachment.isQosOverridden()) {
Network network = getNetworkRelatedToAttachment(networkAttachment);
String networkName = network.getName();
HostNetworkQos hostNetworkQos = HostNetworkQos.fromAnonymousHostNetworkQos(networkAttachment.getHostNetworkQos());
HostNetworkQosValidator qosValidator = createHostNetworkQosValidator(hostNetworkQos);
ValidationResult requiredValuesPresent = qosValidator.requiredQosValuesPresentForOverriding(networkName);
if (!requiredValuesPresent.isValid()) {
return requiredValuesPresent;
}
ValidationResult valuesConsistent = qosValidator.valuesConsistent(networkName);
if (!valuesConsistent.isValid()) {
return valuesConsistent;
}
}
}
return ValidationResult.VALID;
}
Aggregations