Search in sources :

Example 21 with PerHostMessages

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

the class HugePagesFilterPolicyUnitTest method testHugePagesWrongSizeOnHost.

@Test
public void testHugePagesWrongSizeOnHost() throws Exception {
    vm.setCustomProperties("hugepages=1024");
    host1.setHugePages(Collections.singletonList(new HugePage(2048, 50)));
    HugePagesFilterPolicyUnit unit = new HugePagesFilterPolicyUnit(null, pendingResourceManager);
    List<VDS> hosts = unit.filter(null, Collections.singletonList(host1), vm, Collections.emptyMap(), new PerHostMessages());
    assertThat(hosts).isEmpty();
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Test(org.junit.Test)

Example 22 with PerHostMessages

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

the class HugePagesFilterPolicyUnitTest method testEnoughFreeHugePagesOnHostSimple.

@Test
public void testEnoughFreeHugePagesOnHostSimple() throws Exception {
    vm.setCustomProperties("hugepages=1024");
    host1.setHugePages(Collections.singletonList(new HugePage(1024, 1024)));
    HugePagesFilterPolicyUnit unit = new HugePagesFilterPolicyUnit(null, pendingResourceManager);
    List<VDS> hosts = unit.filter(null, Collections.singletonList(host1), vm, Collections.emptyMap(), new PerHostMessages());
    assertThat(hosts).isNotEmpty().contains(host1);
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Test(org.junit.Test)

Example 23 with PerHostMessages

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

the class HugePagesFilterPolicyUnitTest method testNotEnoughFreeHugePagesOnHost.

@Test
public void testNotEnoughFreeHugePagesOnHost() throws Exception {
    vm.setCustomProperties("hugepages=1024");
    host1.setHugePages(Collections.singletonList(new HugePage(1024, 50)));
    HugePagesFilterPolicyUnit unit = new HugePagesFilterPolicyUnit(null, pendingResourceManager);
    List<VDS> hosts = unit.filter(null, Collections.singletonList(host1), vm, Collections.emptyMap(), new PerHostMessages());
    assertThat(hosts).isEmpty();
}
Also used : VDS(org.ovirt.engine.core.common.businessentities.VDS) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) HugePage(org.ovirt.engine.core.common.businessentities.HugePage) Test(org.junit.Test)

Example 24 with PerHostMessages

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

the class LabelFilterPolicyUnitTest method testSimple.

@Test
public void testSimple() throws Exception {
    Label red = new LabelBuilder().entities(vm, host1).build();
    List<Label> labels = Collections.singletonList(red);
    doReturn(labels).when(labelDao).getAllByEntityIds(any());
    assertThat(unit.filter(cluster, hosts, vm, new HashMap<>(), new PerHostMessages())).contains(host1).doesNotContain(host2);
}
Also used : HashMap(java.util.HashMap) Label(org.ovirt.engine.core.common.businessentities.Label) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) Test(org.junit.Test)

Example 25 with PerHostMessages

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

the class LabelFilterPolicyUnitTest method testHostExtra.

@Test
public void testHostExtra() throws Exception {
    Label red = new LabelBuilder().entities(vm, host1).build();
    Label blue = new LabelBuilder().entities(host1, host2).build();
    List<Label> labels = Arrays.asList(red, blue);
    doReturn(labels).when(labelDao).getAllByEntityIds(any());
    assertThat(unit.filter(cluster, hosts, vm, new HashMap<>(), new PerHostMessages())).contains(host1).doesNotContain(host2);
}
Also used : HashMap(java.util.HashMap) Label(org.ovirt.engine.core.common.businessentities.Label) LabelBuilder(org.ovirt.engine.core.common.businessentities.LabelBuilder) PerHostMessages(org.ovirt.engine.core.common.scheduling.PerHostMessages) Test(org.junit.Test)

Aggregations

PerHostMessages (org.ovirt.engine.core.common.scheduling.PerHostMessages)31 Test (org.junit.Test)24 VDS (org.ovirt.engine.core.common.businessentities.VDS)24 VM (org.ovirt.engine.core.common.businessentities.VM)9 HugePage (org.ovirt.engine.core.common.businessentities.HugePage)8 HashMap (java.util.HashMap)5 AffinityGroup (org.ovirt.engine.core.common.scheduling.AffinityGroup)5 ArrayList (java.util.ArrayList)4 PendingHugePages (org.ovirt.engine.core.bll.scheduling.pending.PendingHugePages)4 Guid (org.ovirt.engine.core.compat.Guid)4 List (java.util.List)3 Map (java.util.Map)3 PolicyUnitImpl (org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl)3 PendingResourceManager (org.ovirt.engine.core.bll.scheduling.pending.PendingResourceManager)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 Label (org.ovirt.engine.core.common.businessentities.Label)3 LabelBuilder (org.ovirt.engine.core.common.businessentities.LabelBuilder)3 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)3 PolicyUnit (org.ovirt.engine.core.common.scheduling.PolicyUnit)3 Logger (org.slf4j.Logger)3