use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class COfflineTest method testUnsolvableProblem.
@Test
public void testUnsolvableProblem() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
Node n1 = mo.newNode();
mo.getMapping().on(n1).run(n1, vm1);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan plan = cra.solve(mo, Collections.singleton(new Offline(n1)));
Assert.assertNull(plan);
SolvingStatistics stats = cra.getStatistics();
Assert.assertTrue(stats.completed());
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class COfflineTest method simpleTest.
/**
* Simple test, no VMs.
*/
@Test
public void simpleTest() throws SchedulerException {
Model model = new DefaultModel();
Node n1 = model.newNode();
Node n2 = model.newNode();
Mapping map = model.getMapping().on(n1, n2);
DefaultChocoScheduler cra = new DefaultChocoScheduler();
cra.getDurationEvaluators().register(ShutdownNode.class, new ConstantActionDuration<>(10));
cra.setTimeLimit(-1);
ReconfigurationPlan plan = cra.solve(model, Offline.newOffline(map.getAllNodes()));
Assert.assertNotNull(plan);
Assert.assertEquals(plan.getSize(), 2);
Assert.assertEquals(plan.getDuration(), 10);
Model res = plan.getResult();
Assert.assertEquals(res.getMapping().getOfflineNodes().size(), 2);
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class COverbookTest method testBasic.
@Test
public void testBasic() throws SchedulerException {
Node[] nodes = new Node[2];
VM[] vms = new VM[3];
Model mo = new DefaultModel();
Mapping m = mo.getMapping();
org.btrplace.model.view.ShareableResource rcCPU = new ShareableResource("cpu");
for (int i = 0; i < vms.length; i++) {
if (i < nodes.length) {
nodes[i] = mo.newNode();
rcCPU.setCapacity(nodes[i], 2);
m.addOnlineNode(nodes[i]);
}
vms[i] = mo.newVM();
rcCPU.setConsumption(vms[i], 1);
m.addReadyVM(vms[i]);
}
mo.attach(rcCPU);
Overbook o = new Overbook(nodes[0], "cpu", 2);
Overbook o2 = new Overbook(nodes[1], "cpu", 2);
Collection<SatConstraint> c = new HashSet<>();
c.add(o);
c.add(o2);
c.addAll(Running.newRunning(m.getAllVMs()));
c.add(new Preserve(vms[0], "cpu", 1));
c.addAll(Online.newOnline(m.getAllNodes()));
DefaultChocoScheduler cra = new DefaultChocoScheduler();
cra.getMapper().mapConstraint(Overbook.class, COverbook.class);
ReconfigurationPlan p = cra.solve(mo, c);
Assert.assertNotNull(p);
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class COverbookTest method testWithIncrease.
/**
* Test with a root VM that has increasing need and another one that prevent it
* to get the resources immediately
*/
@Test
public void testWithIncrease() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Mapping map = mo.getMapping().on(n1).run(n1, vm1, vm2);
org.btrplace.model.view.ShareableResource rc = new ShareableResource("foo");
rc.setCapacity(n1, 5);
rc.setConsumption(vm1, 3);
rc.setConsumption(vm2, 2);
mo.attach(rc);
ChocoScheduler cra = new DefaultChocoScheduler();
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.addAll(Online.newOnline(map.getAllNodes()));
Overbook o = new Overbook(n1, "foo", 1);
o.setContinuous(true);
cstrs.add(o);
cstrs.add(new Ready(vm2));
cstrs.add(new Preserve(vm1, "foo", 5));
ReconfigurationPlan p = cra.solve(mo, cstrs);
Assert.assertNotNull(p);
Assert.assertEquals(p.getSize(), 2);
Action al = p.getActions().stream().filter(s -> s instanceof Allocate).findAny().get();
Action sh = p.getActions().stream().filter(s -> s instanceof ShutdownVM).findAny().get();
Assert.assertTrue(sh.getEnd() <= al.getStart());
}
use of org.btrplace.scheduler.choco.DefaultChocoScheduler in project scheduler by btrplace.
the class COverbookTest method testNoSolution.
@Test
public void testNoSolution() throws SchedulerException {
Node[] nodes = new Node[2];
VM[] vms = new VM[7];
Model mo = new DefaultModel();
Mapping m = mo.getMapping();
ShareableResource rcMem = new ShareableResource("mem");
for (int i = 0; i < vms.length; i++) {
if (i < nodes.length) {
nodes[i] = mo.newNode();
rcMem.setCapacity(nodes[i], 3);
m.addOnlineNode(nodes[i]);
}
vms[i] = mo.newVM();
rcMem.setConsumption(vms[i], 1);
m.addReadyVM(vms[i]);
}
mo.attach(rcMem);
Collection<SatConstraint> c = new HashSet<>();
c.add(new Overbook(nodes[0], "mem", 1));
c.add(new Overbook(nodes[1], "mem", 1));
c.addAll(Running.newRunning(m.getAllVMs()));
for (VM v : vms) {
c.add(new Preserve(v, "mem", 1));
}
ChocoScheduler cra = new DefaultChocoScheduler();
cra.getDurationEvaluators().register(BootVM.class, new LinearToAResourceActionDuration<VM>("mem", 2, 3));
Assert.assertNull(cra.solve(mo, c));
}
Aggregations