use of org.btrplace.btrpsl.ScriptBuilder in project scheduler by btrplace.
the class SleepingBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodsleepings")
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();
Set<VM> vms = new HashSet<>();
Assert.assertEquals(cstrs.size(), nbVMs);
for (SatConstraint x : cstrs) {
Assert.assertTrue(x instanceof Sleeping);
Assert.assertTrue(vms.addAll(x.getInvolvedVMs()));
Assert.assertEquals(x.isContinuous(), c);
}
}
use of org.btrplace.btrpsl.ScriptBuilder in project scheduler by btrplace.
the class KilledBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodKilleds")
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();
Set<VM> vms = new HashSet<>();
Assert.assertEquals(cstrs.size(), nbVMs);
for (SatConstraint x : cstrs) {
Assert.assertTrue(x instanceof Killed);
Assert.assertTrue(vms.addAll(x.getInvolvedVMs()));
Assert.assertEquals(x.isContinuous(), c);
}
}
use of org.btrplace.btrpsl.ScriptBuilder in project scheduler by btrplace.
the class MaxOnlineBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodMaxOnline")
public void testGoodSignatures(String str, int nbNodes) throws Exception {
ScriptBuilder b = new ScriptBuilder(new DefaultModel());
MaxOnline x = (MaxOnline) b.build("namespace test; VM[1..10] : tiny;\n@N[1..10] : mock;" + str).getConstraints().iterator().next();
Assert.assertEquals(x.getInvolvedNodes().size(), nbNodes);
Assert.assertEquals(x.isContinuous(), !str.startsWith(">>"));
}
use of org.btrplace.btrpsl.ScriptBuilder in project scheduler by btrplace.
the class OfflineBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodOfflines")
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;" + 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.btrpsl.ScriptBuilder in project scheduler by btrplace.
the class OverbookBuilderTest method testGoodSignatures.
@Test(dataProvider = "goodOverbooks")
public void testGoodSignatures(String str, int nbNodes, String rcId, double ratio) 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 s : cstrs) {
Assert.assertTrue(s instanceof Overbook);
Assert.assertTrue(nodes.addAll(s.getInvolvedNodes()));
Assert.assertEquals(s.getInvolvedNodes().size(), 1);
Assert.assertEquals(((Overbook) s).getResource(), rcId);
Assert.assertEquals(((Overbook) s).getRatio(), ratio);
Assert.assertEquals(s.isContinuous(), !str.startsWith(">>"));
}
}
Aggregations