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);
}
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());
}
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);
}
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);
}
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);
}
Aggregations