use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testNotRemovingLabeledNetworksWhenRemovingLabeledNetworkUnrelatedToRemovedBond.
@Test
public void testNotRemovingLabeledNetworksWhenRemovingLabeledNetworkUnrelatedToRemovedBond() throws Exception {
String nicName = "nicName";
String label = "label";
Network labeledNetwork = new Network();
labeledNetwork.setName("networkName");
labeledNetwork.setId(Guid.newGuid());
labeledNetwork.setLabel(label);
NetworkAttachment networkAttachment = createNetworkAttachment(labeledNetwork);
networkAttachment.setNicName(nicName);
VdsNetworkInterface existingNic = new VdsNetworkInterface();
existingNic.setLabels(Collections.singleton(label));
existingNic.setName(nicName);
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().addExistingInterfaces(Collections.singletonList(existingNic)).addNetworks(Collections.singletonList(labeledNetwork)).build();
EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_CANNOT_REMOVE_LABELED_NETWORK_FROM_NIC;
assertThat(validator.notRemovingLabeledNetworks(networkAttachment), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentStringWithMultipleValues(engineMessage, labeledNetwork.getName())));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidRemovedBondsWhenReferencedInterfaceIsNotBond.
@Test
public void testValidRemovedBondsWhenReferencedInterfaceIsNotBond() throws Exception {
VdsNetworkInterface notABond = createNic("nicName");
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addRemovedBonds(notABond.getId())).addExistingInterfaces(Collections.singletonList(notABond)).build();
final EngineMessage engineMessage = EngineMessage.NETWORK_INTERFACE_IS_NOT_BOND;
assertThat(validator.validRemovedBonds(Collections.emptyList()), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, notABond.getName())));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class NetworkClusterValidatorTestBase method testDefaultRouteNetworkCannotBeExternal.
@Test
public void testDefaultRouteNetworkCannotBeExternal() throws Exception {
networkCluster.setDefaultRoute(true);
setNetworkExternal(network, true);
EngineMessage message = EngineMessage.ACTION_TYPE_FAILED_DEFAULT_ROUTE_NETWORK_CANNOT_BE_EXTERNAL;
assertThat(validator.defaultRouteNetworkCannotBeExternal(network), both(failsWith(message)).and(replacements(hasItem(NETWORK_NAME_REPLACEMENT))));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidModifiedBondsFailsWhenSlavesValidationFails.
@Test
public void testValidModifiedBondsFailsWhenSlavesValidationFails() throws Exception {
EngineMessage engineMessage = EngineMessage.NETWORK_INTERFACE_ATTACHED_TO_NETWORK_CANNOT_BE_SLAVE;
ValidationResult slavesValidationResult = new ValidationResult(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, "slaveA"), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, "networkName"));
CreateOrUpdateBond createOrUpdateBond = createNewCreateOrUpdateBondWithNameAndId();
createOrUpdateBond.setSlaves(Stream.of("slaveA", "slaveB").collect(toSet()));
doTestValidModifiedBonds(createOrUpdateBond, ValidationResult.VALID, /*this mocks validateModifiedBondSlaves to just verify, that caller method will behave ok, when
validateModifiedBondSlaves return invalid result*/
slavesValidationResult, slavesValidationResult);
}
use of org.ovirt.engine.core.common.errors.EngineMessage 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);
}
Aggregations