use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class BootableNodeTest method testForcingOffline.
@Test
public void testForcingOffline() throws SchedulerException, ContradictionException {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
Node n1 = mo.newNode();
map.addOfflineNode(n1);
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(BootNode.class, new ConstantActionDuration<>(5));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).build();
BootableNode na = (BootableNode) rp.getNodeAction(n1);
na.getState().instantiateTo(0, Cause.Null);
ReconfigurationPlan p = rp.solve(0, false);
Assert.assertNotNull(p);
Assert.assertEquals(na.getDuration().getValue(), 0);
Assert.assertEquals(na.getStart().getValue(), 0);
Assert.assertEquals(na.getEnd().getValue(), 0);
Assert.assertEquals(na.getHostingStart().getValue(), rp.getEnd().getValue());
Assert.assertEquals(na.getHostingEnd().getValue(), rp.getEnd().getValue());
Assert.assertNotNull(p);
Assert.assertEquals(p.getSize(), 0);
Model res = p.getResult();
Assert.assertTrue(res.getMapping().getOfflineNodes().contains(n1));
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class BootableNodeTest method testRequiredOnline.
@Test
public void testRequiredOnline() throws SchedulerException {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
VM vm1 = mo.newVM();
Node n1 = mo.newNode();
map.addOfflineNode(n1);
map.addReadyVM(vm1);
ChocoScheduler s = new DefaultChocoScheduler();
Parameters ps = s.getParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(BootNode.class, new ConstantActionDuration<>(5));
dev.register(BootVM.class, new ConstantActionDuration<>(2));
ReconfigurationPlan plan = s.solve(mo, Collections.singleton(new Running(vm1)));
Assert.assertNotNull(plan);
Assert.assertEquals(plan.getSize(), 2);
for (Action a : plan.getActions()) {
if (a instanceof BootNode) {
Assert.assertEquals(a.getStart(), 0);
Assert.assertEquals(a.getEnd(), 5);
} else {
Assert.assertEquals(a.getStart(), 5);
Assert.assertEquals(a.getEnd(), 7);
}
}
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class BootableNodeTest method testDelayedBooting.
@Test
public void testDelayedBooting() throws ContradictionException, SchedulerException {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
Node n2 = mo.newNode();
map.addOfflineNode(n2);
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(BootNode.class, new ConstantActionDuration<>(2));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).build();
BootableNode ma2 = (BootableNode) rp.getNodeAction(n2);
ma2.getState().instantiateTo(1, Cause.Null);
ma2.getStart().updateLowerBound(5, Cause.Null);
new CMinMTTR().inject(ps, rp);
ReconfigurationPlan p = rp.solve(0, false);
// ChocoLogging.flushLogs();
Assert.assertNotNull(p);
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class BootableNodeTest method testActionDurationSimple.
/**
* Unit test for issue #3
*/
@Test
public void testActionDurationSimple() throws SchedulerException, ContradictionException {
Model model = new DefaultModel();
Mapping map = model.getMapping();
Node n1 = model.newNode();
Node n4 = model.newNode();
map.addOnlineNode(n1);
map.addOfflineNode(n4);
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(ShutdownNode.class, new ConstantActionDuration<>(5));
dev.register(BootNode.class, new ConstantActionDuration<>(3));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(model).setParams(ps).build();
ShutdownableNode sn1 = (ShutdownableNode) rp.getNodeAction(n1);
sn1.getState().instantiateTo(0, Cause.Null);
BootableNode bn4 = (BootableNode) rp.getNodeAction(n4);
bn4.getState().instantiateTo(0, Cause.Null);
new CMinMTTR().inject(ps, rp);
ReconfigurationPlan p = rp.solve(0, false);
Assert.assertNotNull(p);
Assert.assertEquals(bn4.getStart().getValue(), 0);
Assert.assertEquals(bn4.getDuration().getValue(), 0);
Assert.assertEquals(bn4.getEnd().getValue(), 0);
Assert.assertEquals(bn4.getHostingStart().getValue(), 0);
Assert.assertEquals(bn4.getHostingEnd().getValue(), 0);
Assert.assertEquals(p.getSize(), 1);
Model res = p.getResult();
Assert.assertTrue(res.getMapping().getOfflineNodes().contains(n1));
Assert.assertTrue(res.getMapping().getOfflineNodes().contains(n4));
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class ForgeVMTest method testResolution.
@Test
public void testResolution() throws SchedulerException, ContradictionException {
Model mo = new DefaultModel();
Mapping m = mo.getMapping();
final VM vm1 = mo.newVM();
Node n1 = mo.newNode();
m.addOnlineNode(n1);
mo.getAttributes().put(vm1, "template", "small");
Parameters ps = new DefaultParameters();
DurationEvaluators dev = ps.getDurationEvaluators();
dev.register(org.btrplace.plan.event.ForgeVM.class, new ConstantActionDuration<>(7));
dev.register(ShutdownNode.class, new ConstantActionDuration<>(20));
ReconfigurationProblem rp = new DefaultReconfigurationProblemBuilder(mo).setParams(ps).setNextVMsStates(Collections.singleton(vm1), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()).build();
// Force the node to get offline
ShutdownableNode n = (ShutdownableNode) rp.getNodeAction(n1);
n.getState().instantiateTo(0, Cause.Null);
new CMinMTTR().inject(ps, rp);
ReconfigurationPlan p = rp.solve(0, false);
Assert.assertNotNull(p);
Assert.assertEquals(p.getDuration(), 20);
for (Action a : p) {
if (a instanceof org.btrplace.plan.event.ForgeVM) {
org.btrplace.plan.event.ForgeVM action = (org.btrplace.plan.event.ForgeVM) a;
Assert.assertTrue(p.getResult().getMapping().isReady(vm1));
Assert.assertEquals(action.getVM(), vm1);
Assert.assertEquals(action.getEnd(), 7);
Assert.assertEquals(action.getStart(), 0);
}
}
}
Aggregations