use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.
the class VmAffinityPolicyUnitTestBase method createAffinityGroup.
protected AffinityGroup createAffinityGroup(Cluster cluster, EntityAffinityRule vmAffinityRule, boolean enforcing, final VM... vmList) {
AffinityGroup ag = new AffinityGroup();
ag.setId(Guid.newGuid());
ag.setVmAffinityRule(vmAffinityRule);
ag.setClusterId(cluster.getId());
ag.setVmEnforcing(enforcing);
ag.setVmIds(Arrays.stream(vmList).map(VM::getId).collect(Collectors.toList()));
return ag;
}
use of org.ovirt.engine.core.common.scheduling.AffinityGroup 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();
}
use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.
the class VmToHostAffinityPolicyUnitBaseTest method setUp.
@Before
public void setUp() throws Exception {
cluster = new Cluster();
cluster.setId(Guid.newGuid());
vm = new VM();
vm.setId(Guid.newGuid());
vm.setClusterId(cluster.getId());
host_positive_enforcing = new VDS();
host_positive_enforcing.setId(Guid.newGuid());
host_positive_enforcing.setClusterId(cluster.getId());
host_negative_enforcing = new VDS();
host_negative_enforcing.setId(Guid.newGuid());
host_negative_enforcing.setClusterId(cluster.getId());
host_not_in_affinity_group = new VDS();
host_not_in_affinity_group.setId(Guid.newGuid());
host_not_in_affinity_group.setClusterId(cluster.getId());
positive_enforcing_group = new AffinityGroup();
negative_enforcing_group = new AffinityGroup();
positive_enforcing_group.setVdsIds(Arrays.asList(host_positive_enforcing.getId()));
positive_enforcing_group.setVdsAffinityRule(EntityAffinityRule.POSITIVE);
positive_enforcing_group.setVdsEnforcing(true);
negative_enforcing_group.setVdsIds(Arrays.asList(host_negative_enforcing.getId()));
negative_enforcing_group.setVdsAffinityRule(EntityAffinityRule.NEGATIVE);
negative_enforcing_group.setVdsEnforcing(true);
}
use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.
the class EditAffinityGroupCommandTest method createAffinityGroup.
private AffinityGroup createAffinityGroup() {
affinityGroup = new AffinityGroup();
affinityGroup.setName(AFFINITY_GROUP_NAME);
affinityGroup.setClusterId(clusterId);
affinityGroup.setVmIds(new ArrayList<>());
return affinityGroup;
}
use of org.ovirt.engine.core.common.scheduling.AffinityGroup in project ovirt-engine by oVirt.
the class AffinityRulesEnforcerTest method shouldFixEqualSizedAffinityGroupWithHigherIdFirst.
@Test
public void shouldFixEqualSizedAffinityGroupWithHigherIdFirst() {
vm1.setId(Guid.createGuidFromString("00000000-0000-0000-0000-000000000001"));
vm4.setId(Guid.createGuidFromString("00000000-0000-0000-0000-000000000007"));
vm6.setId(Guid.createGuidFromString("00000000-0000-0000-0000-000000000008"));
vm2.setId(Guid.createGuidFromString("00000000-0000-0000-0000-000000000003"));
vm5.setId(Guid.createGuidFromString("00000000-0000-0000-0000-000000000004"));
prepareVmDao(vm1, vm2, vm4, vm5, vm6);
final AffinityGroup lowIdGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, vm1, vm4);
final AffinityGroup highIdGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, vm2, vm5);
affinityGroups.add(lowIdGroup);
affinityGroups.add(highIdGroup);
assertThat(enforcer.chooseNextVmToMigrate(cluster)).isIn(vm2, vm5);
affinityGroups.clear();
affinityGroups.add(highIdGroup);
affinityGroups.add(lowIdGroup);
assertThat(enforcer.chooseNextVmToMigrate(cluster)).isIn(vm2, vm5);
// Bigger groups should always come first
affinityGroups.clear();
final AffinityGroup biggestIdGroup = createAffinityGroup(cluster, EntityAffinityRule.POSITIVE, vm1, vm4, vm6);
affinityGroups.add(highIdGroup);
affinityGroups.add(biggestIdGroup);
assertThat(enforcer.chooseNextVmToMigrate(cluster)).isIn(vm1, vm4, vm6);
}
Aggregations