use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.
the class BackendFiltersResource method list.
@Override
public Filters list() {
ClusterPolicy clusterPolicy = getClusterPolicy();
Filters filters = new Filters();
if (clusterPolicy.getFilters() != null) {
for (Guid filterGuid : clusterPolicy.getFilters()) {
Filter filter = new Filter();
filter.setId(filterGuid.toString());
filters.getFilters().add(addLinks(map(clusterPolicy, filter)));
}
}
return filters;
}
use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.
the class ClusterPolicyCRUDCommandTest method testCheckAddEditValidationsFailOnParameters.
@Test
public void testCheckAddEditValidationsFailOnParameters() {
Guid clusterPolicyId = new Guid("e754440b-76a6-4099-8235-4565ab4b5521");
ClusterPolicy clusterPolicy = new ClusterPolicy();
clusterPolicy.setId(clusterPolicyId);
HashMap<String, String> parameterMap = new HashMap<>();
parameterMap.put("fail?", "sure, fail!");
clusterPolicy.setParameterMap(parameterMap);
ClusterPolicyCRUDCommand command = new ClusterPolicyCRUDCommand(new ClusterPolicyCRUDParameters(clusterPolicyId, clusterPolicy), null) {
@Override
protected void executeCommand() {
}
};
command.schedulingManager = schedulingManager;
assertFalse(command.checkAddEditValidations());
}
use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.
the class InternalClusterPoliciesTest method testPolicyCreation.
@Test
public void testPolicyCreation() throws Exception {
Guid uuid = Guid.newGuid();
ClusterPolicy policy = InternalClusterPolicies.createBuilder(uuid.toString()).name("test-policy").isDefault().description("test-description").set(PolicyUnitParameter.CPU_OVERCOMMIT_DURATION_MINUTES, "5").set(PolicyUnitParameter.SPM_VM_GRACE, "1").setBalancer(EvenDistributionBalancePolicyUnit.class).addFilters(CpuLevelFilterPolicyUnit.class).addFilters(MemoryPolicyUnit.class).addFilters(PinToHostPolicyUnit.class).addFunction(1, HaReservationWeightPolicyUnit.class).addFunction(2, VmAffinityWeightPolicyUnit.class).getPolicy();
assertNotNull(policy);
assertEquals(uuid, policy.getId());
assertEquals("test-policy", policy.getName());
assertEquals("test-description", policy.getDescription());
assertTrue(policy.isDefaultPolicy());
assertTrue(policy.isLocked());
assertNotNull(policy.getFilterPositionMap());
assertEquals(-1L, (long) policy.getFilterPositionMap().get(getUnitId(CpuLevelFilterPolicyUnit.class)));
assertEquals(0, (long) policy.getFilterPositionMap().get(getUnitId(MemoryPolicyUnit.class)));
assertEquals(1L, (long) policy.getFilterPositionMap().get(getUnitId(PinToHostPolicyUnit.class)));
assertNotNull(policy.getParameterMap());
assertEquals(2, policy.getParameterMap().size());
assertEquals("5", policy.getParameterMap().get(PolicyUnitParameter.CPU_OVERCOMMIT_DURATION_MINUTES.getDbName()));
assertEquals("1", policy.getParameterMap().get(PolicyUnitParameter.SPM_VM_GRACE.getDbName()));
assertNotNull(policy.getFunctions());
assertNotNull(policy.getFilters());
assertEquals(3, policy.getFilters().size());
assertEquals(2, policy.getFunctions().size());
Map<Guid, Integer> funcMap = new HashMap<>();
for (Pair<Guid, Integer> pair : policy.getFunctions()) {
funcMap.put(pair.getFirst(), pair.getSecond());
}
assertEquals(1, (long) funcMap.get(getUnitId(HaReservationWeightPolicyUnit.class)));
assertEquals(2, (long) funcMap.get(getUnitId(VmAffinityWeightPolicyUnit.class)));
}
use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.
the class ClusterPolicyDaoTest method testUpdate.
@Test
public void testUpdate() {
dao.save(dummyPolicy);
dummyPolicy.setName("Altered dummy policy");
dao.update(dummyPolicy);
ClusterPolicy result = dao.get(dummyPolicy.getId(), Collections.emptyMap());
assertEquals(result, dummyPolicy);
}
use of org.ovirt.engine.core.common.scheduling.ClusterPolicy in project ovirt-engine by oVirt.
the class ClusterPolicyDaoTest method testRemove.
@Test
public void testRemove() {
dao.save(dummyPolicy);
dao.remove(dummyPolicy.getId());
ClusterPolicy result = dao.get(dummyPolicy.getId(), Collections.emptyMap());
assertNull(result);
}
Aggregations