use of org.btrplace.model.constraint.Lonely in project scheduler by btrplace.
the class CLonelyTest method testFeasibleContinuous.
/**
* vm3 needs to go to n2 . vm1, vm2, vm3 must be lonely. n2 is occupied by "other" VMs, so
* they have to go away before receiving vm3
*
* @throws org.btrplace.scheduler.SchedulerException
*/
@Test
public void testFeasibleContinuous() throws SchedulerException {
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();
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));
ChocoScheduler cra = new DefaultChocoScheduler();
Lonely l = new Lonely(mine);
l.setContinuous(true);
Set<SatConstraint> cstrs = new HashSet<>();
cstrs.add(l);
cstrs.add(new Fence(vm3, Collections.singleton(n2)));
ReconfigurationPlan plan = cra.solve(mo, cstrs);
Assert.assertNotNull(plan);
}
use of org.btrplace.model.constraint.Lonely in project scheduler by btrplace.
the class LonelyConverterTest method testViables.
@Test
public void testViables() throws JSONConverterException {
Model mo = new DefaultModel();
ConstraintsConverter conv = new ConstraintsConverter();
conv.register(new LonelyConverter());
Lonely d = new Lonely(new HashSet<>(Arrays.asList(mo.newVM(), mo.newVM())), false);
Lonely c = new Lonely(new HashSet<>(Arrays.asList(mo.newVM(), mo.newVM())), true);
Assert.assertEquals(conv.fromJSON(mo, conv.toJSON(d)), d);
Assert.assertEquals(conv.fromJSON(mo, conv.toJSON(c)), c);
System.out.println(conv.toJSON(d));
}
use of org.btrplace.model.constraint.Lonely in project scheduler by btrplace.
the class CLonelyTest method testFeasibleDiscrete.
@Test
public void testFeasibleDiscrete() throws SchedulerException {
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();
mo.getMapping().on(n1, n2, n3).run(n1, vm1, vm2).run(n2, vm3, vm4, vm5);
Set<VM> mine = new HashSet<>(Arrays.asList(vm1, vm2, vm3));
ChocoScheduler cra = new DefaultChocoScheduler();
Lonely l = new Lonely(mine);
l.setContinuous(false);
ReconfigurationPlan plan = cra.solve(mo, Collections.singleton(l));
Assert.assertNotNull(plan);
// System.out.println(plan);
// Assert.assertEquals(l.isSatisfied(plan.getResult()), SatConstraint.Sat.SATISFIED);
}
use of org.btrplace.model.constraint.Lonely 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));
}
use of org.btrplace.model.constraint.Lonely in project scheduler by btrplace.
the class LonelyBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodLonelys")
public void testGoodSignatures(String str, int nbVMs, boolean c) throws Exception {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
Lonely x = (Lonely) b.build("namespace test; VM[1..10] : tiny;\n" + str).getConstraints().iterator().next();
Assert.assertEquals(x.getInvolvedVMs().size(), nbVMs);
Assert.assertEquals(x.isContinuous(), c);
}
Aggregations