use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class SingleRunnerStatisticsTest method testInstantiate.
@Test
public void testInstantiate() {
Parameters ps = new DefaultParameters();
Model mo = new DefaultModel();
long st = System.currentTimeMillis();
List<SatConstraint> cstrs = new ArrayList<>();
Instance i = new Instance(mo, cstrs, new MinMTTR());
SingleRunnerStatistics stats = new SingleRunnerStatistics(ps, i, st);
Assert.assertEquals(stats.getStart(), st);
Assert.assertEquals(stats.getCoreBuildDuration(), -1);
Assert.assertEquals(stats.getSpecializationDuration(), -1);
Assert.assertEquals(stats.getInstance(), i);
Assert.assertEquals(stats.getNbManagedVMs(), -1);
Assert.assertEquals(stats.getParameters(), ps);
Assert.assertEquals(stats.getSolutions().size(), 0);
Assert.assertEquals(stats.completed(), false);
Assert.assertEquals(stats.getMetrics(), null);
stats.setCoreBuildDuration(12);
stats.setSpecialisationDuration(17);
stats.setNbManagedVMs(18);
stats.setCompleted(true);
Assert.assertEquals(stats.getCoreBuildDuration(), 12);
Assert.assertEquals(stats.getSpecializationDuration(), 17);
Assert.assertEquals(stats.getNbManagedVMs(), 18);
Assert.assertEquals(stats.completed(), true);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
SolutionStatistics sol = new SolutionStatistics(new Metrics(), plan);
stats.addSolution(sol);
Assert.assertEquals(stats.getSolutions().size(), 1);
Assert.assertEquals(stats.getSolutions().get(0), sol);
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class DefaultChocoSchedulerTest method testOnSolutionHook.
@Test
public void testOnSolutionHook() {
ChocoScheduler cra = new DefaultChocoScheduler();
Model mo = new DefaultModel();
VM vm = mo.newVM();
Node node = mo.newNode();
mo.getMapping().on(node).run(node, vm);
Instance i = new Instance(mo, Running.newRunning(vm), new MinMTTR());
List<ReconfigurationPlan> onSolutions = new ArrayList<>();
cra.addSolutionListener((rp, plan) -> onSolutions.add(plan));
Assert.assertEquals(1, cra.solutionListeners().size());
ReconfigurationPlan plan = cra.solve(i);
Assert.assertEquals(1, onSolutions.size());
Assert.assertEquals(plan, onSolutions.get(0));
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class CBanTest method testGetMisPlaced.
/**
* Test getMisPlaced() in various situations.
*/
@Test
public void testGetMisPlaced() {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
VM vm4 = mo.newVM();
VM vm5 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
Node n4 = mo.newNode();
Node n5 = mo.newNode();
mo.getMapping().on(n1, n2, n3, n4, n5).run(n1, vm1, vm2).run(n2, vm3).run(n3, vm4).sleep(n4, vm5);
Set<Node> ns = new HashSet<>(Arrays.asList(n3, n4));
CBan c = new CBan(new Ban(vm1, ns));
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
Assert.assertTrue(c.getMisPlacedVMs(i).isEmpty());
ns.add(mo.newNode());
Assert.assertTrue(c.getMisPlacedVMs(i).isEmpty());
ns.add(n1);
Set<VM> bad = c.getMisPlacedVMs(i);
Assert.assertEquals(1, bad.size());
Assert.assertTrue(bad.contains(vm1));
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class CGatherTest method testGetMisplaced.
@Test
public void testGetMisplaced() {
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);
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
Gather g = new Gather(map.getAllVMs());
CGather c = new CGather(g);
Assert.assertTrue(c.getMisPlacedVMs(i).isEmpty());
map.addRunningVM(vm1, n2);
Assert.assertTrue(c.getMisPlacedVMs(i).isEmpty());
map.addRunningVM(vm1, n1);
Assert.assertEquals(c.getMisPlacedVMs(i), map.getAllVMs());
}
use of org.btrplace.model.constraint.MinMTTR in project scheduler by btrplace.
the class CLonelyTest method testGetMisplaced.
@Test
public void testGetMisplaced() {
Model mo = new DefaultModel();
VM vm1 = mo.newVM();
VM vm2 = mo.newVM();
VM vm3 = mo.newVM();
VM vm4 = mo.newVM();
VM vm5 = mo.newVM();
Node n1 = mo.newNode();
Node n2 = mo.newNode();
Node n3 = mo.newNode();
Mapping map = mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm2, vm3).run(n2, vm4, vm5);
Set<VM> mine = new HashSet<>(Arrays.asList(vm1, vm2, vm3));
CLonely c = new CLonely(new Lonely(mine));
Instance i = new Instance(mo, Collections.emptyList(), new MinMTTR());
Assert.assertTrue(c.getMisPlacedVMs(i).isEmpty());
map.addRunningVM(vm2, n2);
Assert.assertEquals(c.getMisPlacedVMs(i), map.getRunningVMs(n2));
}
Aggregations