use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.
the class AffinityRulesEnforcerTest method createAffinityGroup.
private AffinityGroup createAffinityGroup(Cluster cluster, EntityAffinityRule vmAffinityRule, EntityAffinityRule vdsRule, boolean isVdsEnforcing, List<VDS> vdsList, VM... vmList) {
AffinityGroup ag = createAffinityGroup(cluster, vmAffinityRule, vmList);
ag.setVdsIds(vdsList.stream().map(VDS::getId).collect(Collectors.toList()));
ag.setVdsAffinityRule(vdsRule);
ag.setVdsEnforcing(isVdsEnforcing);
return ag;
}
use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.
the class AffinityRulesEnforcerTest method shouldDoNothingWhenSatisfied.
@Test
public void shouldDoNothingWhenSatisfied() {
AffinityGroup positiveGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, vm1, vm2);
AffinityGroup negativeGroup = createAffinityGroup(cluster, EntityAffinityRule.NEGATIVE, vm1, vm4);
affinityGroups.add(positiveGroup);
affinityGroups.add(negativeGroup);
assertThat(enforcer.chooseNextVmToMigrate(cluster)).isNull();
positiveGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, EntityAffinityRule.POSITIVE, true, Arrays.asList(host1), vm1, vm2, vm3);
negativeGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, EntityAffinityRule.NEGATIVE, true, Arrays.asList(host1), vm4);
affinityGroups.clear();
affinityGroups.add(positiveGroup);
affinityGroups.add(negativeGroup);
assertThat(enforcer.chooseNextVmToMigrate(cluster)).isNull();
}
use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.
the class AffinityRulesEnforcerTest method shouldMigrateCandidateFromNegativeGroup.
@Test
public void shouldMigrateCandidateFromNegativeGroup() {
AffinityGroup positiveSatisfiedGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, vm1, vm2);
AffinityGroup negativeUnsatisfiedGroup = createAffinityGroup(cluster, EntityAffinityRule.NEGATIVE, vm2, vm3, vm6);
affinityGroups.add(negativeUnsatisfiedGroup);
affinityGroups.add(positiveSatisfiedGroup);
VM candidate = enforcer.chooseNextVmToMigrate(cluster);
assertThat(candidate).isIn(vm2, vm3);
positiveSatisfiedGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, EntityAffinityRule.POSITIVE, true, Arrays.asList(host1, host2), vm1, vm2, vm3);
negativeUnsatisfiedGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, EntityAffinityRule.NEGATIVE, true, Arrays.asList(host1, host3), vm5, vm6);
affinityGroups.clear();
affinityGroups.add(negativeUnsatisfiedGroup);
affinityGroups.add(positiveSatisfiedGroup);
candidate = enforcer.chooseNextVmToMigrate(cluster);
assertThat(candidate).isIn(vm5, vm6);
}
use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.
the class AffinityRulesEnforcerTest method shouldFixBiggerAffinityGroupFirst.
@Test
public void shouldFixBiggerAffinityGroupFirst() {
AffinityGroup bigGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, vm1, vm4, vm6);
AffinityGroup smallGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, vm2, vm5);
affinityGroups.add(bigGroup);
affinityGroups.add(smallGroup);
assertThat(enforcer.chooseNextVmToMigrate(cluster)).isIn(vm1, vm4, vm6);
affinityGroups.clear();
affinityGroups.add(smallGroup);
affinityGroups.add(bigGroup);
assertThat(enforcer.chooseNextVmToMigrate(cluster)).isIn(vm1, vm4, vm6);
}
use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.
the class AddAffinityGroupCommandTest method createAffinityGroup.
private AffinityGroup createAffinityGroup() {
affinityGroup = new AffinityGroup();
affinityGroup.setVmIds(new ArrayList<>());
affinityGroup.getVmIds().add(vmId);
affinityGroup.setClusterId(clusterId);
return affinityGroup;
}
Aggregations