use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidateModifiedBondSlavesWhenSlaveAlreadySlavesForDifferentBond.
@Test
public void testValidateModifiedBondSlavesWhenSlaveAlreadySlavesForDifferentBond() throws Exception {
Bond bond = createBond("bond1");
Bond differentBond = createBond("bond2");
VdsNetworkInterface slaveA = createBondSlave(bond, "slaveA");
VdsNetworkInterface slaveB = createBondSlave(differentBond, "slaveB");
setBondSlaves(bond, slaveA, slaveB);
EngineMessage engineMessage = EngineMessage.NETWORK_INTERFACE_ALREADY_IN_BOND;
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addBonds(CreateOrUpdateBond.fromBond(bond))).addExistingInterfaces(bond, differentBond, slaveA, slaveB).build();
doTestValidateModifiedBondSlaves(spy(validator), ValidationResult.VALID, ValidationResult.VALID, failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, slaveB.getName())));
}
use of org.ovirt.engine.core.common.errors.EngineMessage 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.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testValidateModifiedBondSlavesWhenSlaveHasNetworkAssignedWhichIsNotRemovedAsAPartOfRequest.
@Test
public void testValidateModifiedBondSlavesWhenSlaveHasNetworkAssignedWhichIsNotRemovedAsAPartOfRequest() throws Exception {
Bond bond = createBond();
Network networkBeingRemoved = new Network();
networkBeingRemoved.setName("assignedNetwork");
VdsNetworkInterface slaveA = createBondSlave(bond, "slaveA");
slaveA.setNetworkName("assignedNetwork");
NetworkAttachment attachmentOfNetworkToSlaveA = createNetworkAttachment(networkBeingRemoved, slaveA);
VdsNetworkInterface slaveB = createBondSlave(bond, "slaveB");
setBondSlaves(bond, slaveA, slaveB);
EngineMessage engineMessage = EngineMessage.NETWORK_INTERFACE_ATTACHED_TO_NETWORK_CANNOT_BE_SLAVE;
final HostSetupNetworksValidator build = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addBonds(CreateOrUpdateBond.fromBond(bond))).addExistingInterfaces(bond, slaveA, slaveB).addExistingAttachments(attachmentOfNetworkToSlaveA).addNetworks(networkBeingRemoved).build();
doTestValidateModifiedBondSlaves(spy(build), ValidationResult.VALID, ValidationResult.VALID, failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, slaveA.getName()), ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, networkBeingRemoved.getName())));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method testNotMovingLabeledNetworkToDifferentNicWhenRemovingLabeledNetworkUnrelatedToRemovedBond.
@Test
public void testNotMovingLabeledNetworkToDifferentNicWhenRemovingLabeledNetworkUnrelatedToRemovedBond() throws Exception {
String label = "label";
Network labeledNetwork = new Network();
labeledNetwork.setId(Guid.newGuid());
labeledNetwork.setLabel(label);
VdsNetworkInterface existingNic = new VdsNetworkInterface();
existingNic.setLabels(Collections.singleton(label));
existingNic.setId(Guid.newGuid());
existingNic.setName("nic1");
VdsNetworkInterface existingNic2 = new VdsNetworkInterface();
existingNic2.setId(Guid.newGuid());
existingNic2.setName("nic2");
Guid attachmentId = Guid.newGuid();
NetworkAttachment existingNetworkAttachment = createNetworkAttachment(labeledNetwork, attachmentId);
existingNetworkAttachment.setNicId(existingNic.getId());
existingNetworkAttachment.setNicName(existingNic.getName());
NetworkAttachment updatedNetworkAttachment = createNetworkAttachment(labeledNetwork, attachmentId);
updatedNetworkAttachment.setNicId(existingNic2.getId());
updatedNetworkAttachment.setNicName(existingNic2.getName());
HostSetupNetworksValidator validator = new HostSetupNetworksValidatorBuilder().setParams(new ParametersBuilder().addNetworkAttachments(updatedNetworkAttachment)).addExistingInterfaces(Arrays.asList(existingNic, existingNic2)).addExistingAttachments(Collections.singletonList(existingNetworkAttachment)).addNetworks(Collections.singletonList(labeledNetwork)).build();
EngineMessage engineMessage = EngineMessage.ACTION_TYPE_FAILED_CANNOT_MOVE_LABELED_NETWORK_TO_ANOTHER_NIC;
assertThat(validator.notMovingLabeledNetworkToDifferentNic(updatedNetworkAttachment), failsWith(engineMessage, ReplacementUtils.createSetVariableString(HostSetupNetworksValidator.VAR_NETWORK_NAME, labeledNetwork.getName()), ReplacementUtils.getVariableAssignmentString(engineMessage, labeledNetwork.getLabel())));
}
use of org.ovirt.engine.core.common.errors.EngineMessage in project ovirt-engine by oVirt.
the class HostSetupNetworksValidatorTest method assertValidateSlaveHasNoLabelsFailed.
private void assertValidateSlaveHasNoLabelsFailed(HostSetupNetworksValidator validator, String slaveName) {
final EngineMessage engineMessage = EngineMessage.LABEL_ATTACH_TO_IMPROPER_INTERFACE;
assertThat(validator.validateSlaveHasNoLabels(slaveName), failsWith(engineMessage, ReplacementUtils.getVariableAssignmentString(engineMessage, slaveName)));
}
Aggregations