Search in sources :

Example 26 with PerHostMessages

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

the class ClusterInMaintenanceFilterPolicyUnitTest method testHaCanMigrate.

@Test
public void testHaCanMigrate() throws Exception {
    vm.setRunOnVds(Guid.newGuid());
    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)

Example 27 with PerHostMessages

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

the class ClusterInMaintenanceFilterPolicyUnitTest method testNonHaCannotStart.

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

Example 28 with PerHostMessages

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

the class VmAffinityFilterPolicyUnitTest method testFirstVm.

@Test
public void testFirstVm() {
    List<VDS> hosts = Arrays.asList(host1, host2);
    VM vm1 = createVMDown(cluster);
    VM vm2 = createVMDown(cluster);
    affinityGroups.add(createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, true, vm1, vm2, newVm));
    assertThat(policyUnit.filter(cluster, hosts, newVm, null, new PerHostMessages())).containsOnlyElementsOf(hosts);
    affinityGroups.clear();
    affinityGroups.add(createAffinityGroup(cluster, EntityAffinityRule.NEGATIVE, true, vm1, vm2, newVm));
    assertThat(policyUnit.filter(cluster, hosts, newVm, null, new PerHostMessages())).containsOnlyElementsOf(hosts);
}
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 29 with PerHostMessages

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

the class VmAffinityFilterPolicyUnitTest method testNegativeAffinity.

@Test
public void testNegativeAffinity() {
    List<VDS> hosts = Arrays.asList(host1, host2, host3);
    VM vm1 = createVmRunning(host1);
    VM vm2 = createVmRunning(host3);
    affinityGroups.add(createAffinityGroup(cluster, EntityAffinityRule.NEGATIVE, true, vm1, vm2, newVm));
    assertThat(policyUnit.filter(cluster, hosts, newVm, null, new PerHostMessages())).doesNotContain(host1, 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 30 with PerHostMessages

use of org.ovirt.engine.core.common.scheduling.PerHostMessages 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)

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