use of org.btrplace.model.constraint.Running in project scheduler by btrplace.
the class CRunningTest method testGetMisplaced.
@Test
public void testGetMisplaced() {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
Node n1 = mo.newNode();
mo.getMapping().on(n1).ready(vm1).run(n1, vm2);
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
CRunning k = new CRunning(new Running(vm1));
Assert.assertEquals(1, k.getMisPlacedVMs(i).size());
Assert.assertTrue(k.getMisPlacedVMs(i).contains(vm1));
k = new CRunning(new Running(vm2));
Assert.assertEquals(0, k.getMisPlacedVMs(i).size());
}
use of org.btrplace.model.constraint.Running in project scheduler by btrplace.
the class CSeqTest method testWithOnlyTransitions.
@Test
public void testWithOnlyTransitions() throws SchedulerException {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
VM vm4 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2).ready(vm1).run(n1, vm2, vm4).sleep(n2, vm3);
List<SatConstraint> cstrs = new ArrayList<>();
cstrs.add(new Running(vm1));
cstrs.add(new Sleeping(vm2));
cstrs.add(new Running(vm3));
cstrs.add(new Ready(vm4));
cstrs.addAll(Online.newOnline(map.getAllNodes()));
ChocoScheduler cra = new DefaultChocoScheduler();
List<VM> seq = Arrays.asList(vm1, vm2, vm3, vm4);
cstrs.add(new Seq(seq));
ReconfigurationPlan plan = cra.solve(mo, cstrs);
Assert.assertNotNull(plan);
}
use of org.btrplace.model.constraint.Running in project scheduler by btrplace.
the class RunningBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodRunnings")
public void testGoodSignatures(String str, int nbVMs, 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;" + str).getConstraints();
Assert.assertEquals(cstrs.size(), nbVMs);
Set<VM> vms = new HashSet<>();
for (SatConstraint x : cstrs) {
Assert.assertTrue(x instanceof Running);
Assert.assertTrue(vms.addAll(x.getInvolvedVMs()));
Assert.assertEquals(x.isContinuous(), c);
}
}
use of org.btrplace.model.constraint.Running in project scheduler by btrplace.
the class DefaultChocoSchedulerTest method testGetStatisticsWithNoSolution.
@Test
public void testGetStatisticsWithNoSolution() throws SchedulerException {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
VM v = mo.newVM();
Node n = mo.newNode();
map.addReadyVM(v);
map.addOfflineNode(n);
ChocoScheduler cra = new DefaultChocoScheduler();
ReconfigurationPlan p = cra.solve(mo, Arrays.asList(new Running(v), new Offline(n)));
Assert.assertNull(p);
SolvingStatistics stats = cra.getStatistics();
Assert.assertNotNull(stats);
Assert.assertTrue(stats.getSolutions().isEmpty());
// Assert.assertFalse(stats.hitTimeout());
}
use of org.btrplace.model.constraint.Running in project scheduler by btrplace.
the class DefaultChocoSchedulerTest method testNonHomogeneousIncrease.
/**
* Issue #14
*
* @throws org.btrplace.scheduler.SchedulerException
*/
@Test
public void testNonHomogeneousIncrease() throws SchedulerException {
ShareableResource cpu = new ShareableResource("cpu");
ShareableResource mem = new ShareableResource("mem");
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
VM vm4 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
cpu.setCapacity(n1, 10);
mem.setCapacity(n1, 10);
cpu.setCapacity(n2, 10);
mem.setCapacity(n2, 10);
cpu.setConsumption(vm1, 5);
mem.setConsumption(vm1, 4);
cpu.setConsumption(vm2, 3);
mem.setConsumption(vm2, 8);
cpu.setConsumption(vm3, 5);
cpu.setConsumption(vm3, 4);
cpu.setConsumption(vm4, 4);
cpu.setConsumption(vm4, 5);
// vm1 requires more cpu resources, but fewer mem resources
Preserve pCPU = new Preserve(vm1, "cpu", 7);
Preserve pMem = new Preserve(vm1, "mem", 2);
mo.getMapping().on(n1, n2).run(n1, vm1).run(n2, vm3, vm4).ready(vm2);
mo.attach(cpu);
mo.attach(mem);
ChocoScheduler cra = new DefaultChocoScheduler();
cra.setMaxEnd(5);
ReconfigurationPlan p = cra.solve(mo, Arrays.asList(pCPU, pMem, new Online(n1), new Running(vm2), new Ready(vm3)));
Assert.assertNotNull(p);
}
Aggregations