Search in sources :

Example 46 with AffinityGroup

use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.

the class EditAffinityGroupCommandTest method validate_testNameChange_Test.

@Test
public void validate_testNameChange_Test() {
    doReturn(new AffinityGroup()).when(affinityGroupDao).getByName(affinityGroup.getName());
    ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_AFFINITY_GROUP_NAME_EXISTS);
}
Also used : AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 47 with AffinityGroup

use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.

the class EditAffinityGroupCommandTest method setup.

@Before
public void setup() {
    AffinityGroup affinityGroup2 = new AffinityGroup();
    affinityGroup2.setClusterId(clusterId);
    affinityGroup2.setName(AFFINITY_GROUP_NAME + "##");
    doReturn(affinityGroup2).when(command).getAffinityGroup();
    doReturn(new Cluster()).when(command).getCluster();
    VmStatic vmStatic = new VmStatic();
    vmStatic.setClusterId(clusterId);
    doReturn(Collections.singletonList(vmStatic)).when(vmStaticDao).getByIds(any());
    doReturn(clusterId).when(command).getClusterId();
}
Also used : Cluster(org.ovirt.engine.core.common.businessentities.Cluster) VmStatic(org.ovirt.engine.core.common.businessentities.VmStatic) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Before(org.junit.Before)

Example 48 with AffinityGroup

use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.

the class VmToHostAffinityFilterPolicyUnitTest method testNoAffinityGroups.

@Test
public void testNoAffinityGroups() {
    hosts = Arrays.asList(host_positive_enforcing, host_negative_enforcing, host_not_in_affinity_group);
    List<AffinityGroup> affinityGroups = new ArrayList<>();
    doReturn(affinityGroups).when(affinityGroupDao).getAllAffinityGroupsByVmId(any());
    assertThat(unit.filter(cluster, hosts, vm, new HashMap<>(), new PerHostMessages())).contains(host_positive_enforcing, host_negative_enforcing, host_not_in_affinity_group);
}
Also used : ArrayList(java.util.ArrayList) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

Example 49 with AffinityGroup

use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.

the class VmToHostAffinityFilterPolicyUnitTest method testNegativeAffinity.

@Test
public void testNegativeAffinity() throws Exception {
    hosts = Arrays.asList(host_negative_enforcing, host_not_in_affinity_group);
    List<AffinityGroup> affinityGroups = Arrays.asList(negative_enforcing_group);
    doReturn(affinityGroups).when(affinityGroupDao).getAllAffinityGroupsByVmId(any());
    assertThat(unit.filter(cluster, hosts, vm, new HashMap<>(), new PerHostMessages())).contains(host_not_in_affinity_group);
}
Also used : PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

Aggregations

AffinityGroup (org.ovirt.engine.core.common.scheduling.AffinityGroup)49 Test (org.junit.Test)20 Guid (org.ovirt.engine.core.compat.Guid)12 ArrayList (java.util.ArrayList)11 VM (org.ovirt.engine.core.common.businessentities.VM)11 HashSet (java.util.HashSet)9 HashMap (java.util.HashMap)7 List (java.util.List)5 Map (java.util.Map)5 Set (java.util.Set)5 Collectors (java.util.stream.Collectors)5 Inject (javax.inject.Inject)5 PerHostMessages (org.ovirt.engine.core.common.scheduling.PerHostMessages)5 AffinityGroupDao (org.ovirt.engine.core.dao.scheduling.AffinityGroupDao)5 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)4 VDS (org.ovirt.engine.core.common.businessentities.VDS)4 AffinityGroupCRUDParameters (org.ovirt.engine.core.common.scheduling.parameters.AffinityGroupCRUDParameters)4 Logger (org.slf4j.Logger)4 LoggerFactory (org.slf4j.LoggerFactory)4 Collections (java.util.Collections)3