use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class RunningCapacityBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodCapacities")
public void testGoodSignatures(String str, int nbNodes, int capa, boolean c) throws Exception {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Set<SatConstraint> cstrs = b.build("namespace test; VM[1..10] : tiny;\n@N[1..20] : defaultNode;\n" + str).getConstraints();
Assert.assertEquals(cstrs.size(), 1);
RunningCapacity x = (RunningCapacity) cstrs.iterator().next();
Assert.assertEquals(x.getInvolvedNodes().size(), nbNodes);
Assert.assertEquals(x.getAmount(), capa);
Assert.assertEquals(x.isContinuous(), c);
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class OnlineBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodOnlines")
public void testGoodSignatures(String str, int nbNodes, boolean c) throws Exception {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Set<SatConstraint> cstrs = b.build("namespace test; VM[1..10] : tiny;\n@N[1..20] : defaultNode;\n" + str).getConstraints();
Assert.assertEquals(cstrs.size(), nbNodes);
Set<Node> nodes = new HashSet<>();
for (SatConstraint x : cstrs) {
Assert.assertTrue(nodes.addAll(x.getInvolvedNodes()));
Assert.assertEquals(x.getInvolvedNodes().size(), 1);
Assert.assertEquals(x.isContinuous(), c);
}
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class IssuesTest method issue72.
@Test
public void issue72() throws Exception {
String input = "{\"model\":{\"mapping\":{\"readyVMs\":[],\"onlineNodes\":{\"0\":{\"sleepingVMs\":[],\"runningVMs\":[9,8,7,6,5,4,3,2,1,0]},\"1\":{\"sleepingVMs\":[],\"runningVMs\":[19,18,17,16,15,14,13,12,11,10]}},\"offlineNodes\":[]},\"attributes\":{\"nodes\":{},\"vms\":{}},\"views\":[{\"defConsumption\":0,\"nodes\":{\"0\":32768,\"1\":32768},\"rcId\":\"mem\",\"id\":\"shareableResource\",\"defCapacity\":8192,\"vms\":{\"11\":1024,\"12\":1024,\"13\":1024,\"14\":1024,\"15\":1024,\"16\":1024,\"17\":1024,\"18\":1024,\"19\":1024,\"0\":1024,\"1\":1024,\"2\":1024,\"3\":1024,\"4\":1024,\"5\":1024,\"6\":1024,\"7\":1024,\"8\":1024,\"9\":1024,\"10\":1024}},{\"defConsumption\":0,\"nodes\":{\"0\":700,\"1\":700},\"rcId\":\"cpu\",\"id\":\"shareableResource\",\"defCapacity\":8000,\"vms\":{\"11\":0,\"12\":0,\"13\":0,\"14\":0,\"15\":0,\"16\":70,\"17\":0,\"18\":60,\"19\":0,\"0\":100,\"1\":0,\"2\":0,\"3\":0,\"4\":0,\"5\":0,\"6\":0,\"7\":0,\"8\":90,\"9\":0,\"10\":0}}]},\"constraints\":[],\"objective\":{\"id\":\"minimizeMTTR\"}}";
Instance i = JSON.readInstance(new StringReader(input));
ChocoScheduler s = new DefaultChocoScheduler();
s.setTimeLimit(-1);
i.getModel().detach(ShareableResource.get(i.getModel(), "mem"));
i.getModel().detach(ShareableResource.get(i.getModel(), "cpu"));
List<SatConstraint> cstrs = new ArrayList<>();
ReconfigurationPlan p = s.solve(i.getModel(), cstrs, i.getOptConstraint());
Assert.assertTrue(p.getActions().isEmpty());
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CGatherTest method testContinuousWithNoRunningVMs.
@Test
public void testContinuousWithNoRunningVMs() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2).ready(vm1, vm2);
Gather g = new Gather(map.getAllVMs());
g.setContinuous(true);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.add(g);
cstrs.addAll(Running.newRunning(map.getAllVMs()));
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan plan = cra.solve(mo, cstrs);
Assert.assertNotNull(plan);
}
use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.
the class CGatherTest method testDiscreteWithRunningVMs.
@Test
public void testDiscreteWithRunningVMs() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Mapping map = mo.getMapping().ready(vm1).on(n1, n2).run(n2, vm2);
Gather g = new Gather(map.getAllVMs());
g.setContinuous(false);
ChocoScheduler cra = new DefaultChocoScheduler();
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.add(g);
cstrs.addAll(Running.newRunning(map.getAllVMs()));
ReconfigurationPlan plan = cra.solve(mo, cstrs);
Assert.assertNotNull(plan);
Model res = plan.getResult();
Assert.assertEquals(res.getMapping().getVMLocation(vm1), res.getMapping().getVMLocation(vm2));
}
Aggregations