Search in sources :

Example 41 with AffinityGroup

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;
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup)

Example 42 with AffinityGroup

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();
}
Also used : AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

Example 43 with AffinityGroup

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);
}
Also used : VM(org.ovirt.engine.core.common.businessentities.VM) AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

Example 44 with AffinityGroup

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);
}
Also used : AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

Example 45 with AffinityGroup

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;
}
Also used : AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup)

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