Search in sources :

Example 26 with AffinityGroup

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

the class AffinityGroupDaoTest method testRemoveVdsFromAffinityGroups.

@Test
public void testRemoveVdsFromAffinityGroups() {
    AffinityGroup existing = dao.get(FixturesTool.EXISTING_AFFINITY_GROUP_ID);
    assertFalse(existing.getVdsIds().isEmpty());
    dao.removeVdsFromAffinityGroups(FixturesTool.VDS_RHEL6_NFS_SPM);
    assertTrue(dao.get(FixturesTool.EXISTING_AFFINITY_GROUP_ID).getVdsIds().isEmpty());
}
Also used : AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

Example 27 with AffinityGroup

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

the class AffinityGroupDaoTest method testAddVmsForExistingAffinityGroup.

@Test
public void testAddVmsForExistingAffinityGroup() {
    AffinityGroup existing = dao.get(FixturesTool.EXISTING_AFFINITY_GROUP_ID);
    assertEquals(NUM_OF_VMS_IN_EXISTING_AFFINITY_GROUP, existing.getVmEntityNames().size());
    existing.getVmIds().add(FixturesTool.VM_RHEL5_POOL_51);
    dao.update(existing);
    AffinityGroup fetched = dao.get(existing.getId());
    assertEquals(NUM_OF_VMS_IN_EXISTING_AFFINITY_GROUP + 1, fetched.getVmEntityNames().size());
}
Also used : AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

Example 28 with AffinityGroup

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

the class AffinityGroupDaoTest method testRemoveVmsFromExistingAffinityGroup.

@Test
public void testRemoveVmsFromExistingAffinityGroup() {
    AffinityGroup existing = dao.get(FixturesTool.EXISTING_AFFINITY_GROUP_ID);
    assertFalse(existing.getVmEntityNames().isEmpty());
    existing.getVmIds().clear();
    dao.update(existing);
    AffinityGroup fetched = dao.get(existing.getId());
    assertTrue(fetched.getVmEntityNames().isEmpty());
}
Also used : AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

Example 29 with AffinityGroup

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

the class AffinityGroupDaoTest method testGetById.

@Test
public void testGetById() {
    AffinityGroup affinityGroup = dao.get(FixturesTool.EXISTING_AFFINITY_GROUP_ID);
    assertNotNull(affinityGroup);
    assertEquals(FixturesTool.EXISTING_AFFINITY_GROUP_ID, affinityGroup.getId());
    // empty
    affinityGroup = dao.get(null);
    assertNull(affinityGroup);
    affinityGroup = dao.get(Guid.Empty);
    assertNull(affinityGroup);
    affinityGroup = dao.get(Guid.newGuid());
    assertNull(affinityGroup);
}
Also used : AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

Example 30 with AffinityGroup

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

the class AffinityGroupDaoTest method testSimpleUpdate.

@Test
public void testSimpleUpdate() {
    AffinityGroup existing = dao.get(FixturesTool.EXISTING_AFFINITY_GROUP_ID);
    existing.setName("my_new_name");
    existing.setVmAffinityRule(EntityAffinityRule.NEGATIVE);
    existing.setVmEnforcing(true);
    dao.update(existing);
    AffinityGroup fetched = dao.get(existing.getId());
    assertTrue(equals(existing, fetched));
}
Also used : AffinityGroup(org.ovirt.engine.core.common.scheduling.AffinityGroup) Test(org.junit.Test)

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