Search in sources :

Example 6 with PerHostMessages

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

the class VmAffinityFilterPolicyUnitTest method testPositiveAffinityToMultipleHosts.

@Test
public void testPositiveAffinityToMultipleHosts() {
    List<VDS> hosts = Arrays.asList(host1, host2, host3);
    VM vm1 = createVmRunning(host2);
    VM vm2 = createVmRunning(host2);
    VM vm3 = createVmRunning(host3);
    affinityGroups.add(createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, true, vm1, vm2, vm3, newVm));
    assertThat(policyUnit.filter(cluster, hosts, newVm, null, new PerHostMessages())).containsOnly(host2, host3);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) VM(org.ovirt.engine.core.common.businessentities.VM) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) Test(org.junit.Test)

Example 7 with PerHostMessages

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

the class VmAffinityFilterPolicyUnitTest method testNoAffinityGroups.

@Test
public void testNoAffinityGroups() {
    List<VDS> hosts = Arrays.asList(host1, host2);
    assertThat(policyUnit.filter(cluster, hosts, newVm, null, new PerHostMessages())).containsOnlyElementsOf(hosts);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) Test(org.junit.Test)

Example 8 with PerHostMessages

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

the class VmToHostAffinityFilterPolicyUnitTest method testWithAffinityIntersection.

@Test
public void testWithAffinityIntersection() throws Exception {
    AffinityGroup positiveCollisionGroup = new AffinityGroup();
    positiveCollisionGroup.setVdsIds(Arrays.asList(host_negative_enforcing.getId()));
    positiveCollisionGroup.setVdsAffinityRule(EntityAffinityRule.POSITIVE);
    positiveCollisionGroup.setVdsEnforcing(true);
    hosts = Arrays.asList(host_positive_enforcing, host_negative_enforcing, host_not_in_affinity_group);
    List<AffinityGroup> affinityGroups = Arrays.asList(positiveCollisionGroup, negative_enforcing_group);
    doReturn(affinityGroups).when(affinityGroupDao).getAllAffinityGroupsByVmId(any());
    assertThat(unit.filter(cluster, hosts, vm, new HashMap<>(), new PerHostMessages())).isEmpty();
}
Also used : PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

Example 9 with PerHostMessages

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

the class ClusterInMaintenanceFilterPolicyUnitTest method testNonHaCanMigrate.

@Test
public void testNonHaCanMigrate() throws Exception {
    vm.setRunOnVds(Guid.newGuid());
    ClusterInMaintenanceFilterPolicyUnit unit = new ClusterInMaintenanceFilterPolicyUnit(null, null);
    List<VDS> result = unit.filter(null, Collections.singletonList(host), vm, Collections.emptyMap(), new PerHostMessages());
    assertThat(result).isNotNull().isNotEmpty().contains(host);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) Test(org.junit.Test)

Example 10 with PerHostMessages

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

the class ClusterInMaintenanceFilterPolicyUnitTest method testHaCanStart.

@Test
public void testHaCanStart() throws Exception {
    vm.setAutoStartup(true);
    ClusterInMaintenanceFilterPolicyUnit unit = new ClusterInMaintenanceFilterPolicyUnit(null, null);
    List<VDS> result = unit.filter(null, Collections.singletonList(host), vm, Collections.emptyMap(), new PerHostMessages());
    assertThat(result).isNotNull().isNotEmpty().contains(host);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) Test(org.junit.Test)

Aggregations

PerHostMessages (org.ovirt.engine.core.common.scheduling.PerHostMessages)31 Test (org.junit.Test)24 VDS (org.ovirt.engine.core.common.businessentities.VDS)24 VM (org.ovirt.engine.core.common.businessentities.VM)9 HugePage (org.ovirt.engine.core.common.businessentities.HugePage)8 HashMap (java.util.HashMap)5 AffinityGroup (org.ovirt.engine.core.common.scheduling.AffinityGroup)5 ArrayList (java.util.ArrayList)4 PendingHugePages (org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages)4 Guid (org.ovirt.engine.core.compat.Guid)4 List (java.util.List)3 Map (java.util.Map)3 PolicyUnitImpl (org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl)3 PendingResourceManager (org.ovirt.engine.core.bll.scheduling.pending.PendingResourceManager)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 Label (org.ovirt.engine.core.common.businessentities.Label)3 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)3 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)3 PolicyUnit (org.ovirt.engine.core.common.scheduling.PolicyUnit)3 Logger (org.slf4j.Logger)3