Search in sources :

Example 1 with ScriptBuilder

use of org.btrplace.btrpsl.ScriptBuilder in project scheduler by btrplace.

the class SeqBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodseqs")
public void testGoodSignatures(String str, int nbVMs) throws Exception {
    ScriptBuilder b = new ScriptBuilder(new DefaultModel());
    Seq x = (Seq) b.build("namespace test; VM[1..10] : tiny;\n" + str).getConstraints().iterator().next();
    Assert.assertEquals(x.getInvolvedVMs().size(), nbVMs);
    Assert.assertEquals(x.isContinuous(), true);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) Seq(org.btrplace.model.constraint.Seq) Test(org.testng.annotations.Test)

Example 2 with ScriptBuilder

use of org.btrplace.btrpsl.ScriptBuilder in project scheduler by btrplace.

the class SplitAmongBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodSplitAmongs")
public void testGoodSignatures(String str, int nbVGrp, int nbVMs, int nbPGrp, int nbNodes) throws Exception {
    ScriptBuilder b = new ScriptBuilder(new DefaultModel());
    SplitAmong x = (SplitAmong) b.build("namespace test; VM[1..10] : tiny;\n@N[1..20] : defaultNode;\n" + str).getConstraints().iterator().next();
    Assert.assertEquals(x.getGroupsOfVMs().size(), nbVGrp);
    Assert.assertEquals(x.getInvolvedVMs().size(), nbVMs);
    Assert.assertEquals(x.getGroupsOfNodes().size(), nbPGrp);
    Assert.assertEquals(x.getInvolvedNodes().size(), nbNodes);
    Assert.assertEquals(x.isContinuous(), !str.startsWith(">>"));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SplitAmong(org.btrplace.model.constraint.SplitAmong) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) Test(org.testng.annotations.Test)

Example 3 with ScriptBuilder

use of org.btrplace.btrpsl.ScriptBuilder in project scheduler by btrplace.

the class SpreadBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodSpreads")
public void testGoodSignatures(String str, int nbVMs) throws Exception {
    ScriptBuilder b = new ScriptBuilder(new DefaultModel());
    Spread x = (Spread) b.build("namespace test; VM[1..10] : tiny;\n" + str).getConstraints().iterator().next();
    Assert.assertEquals(x.getInvolvedVMs().size(), nbVMs);
    Assert.assertEquals(x.isContinuous(), !str.startsWith(">>"));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Spread(org.btrplace.model.constraint.Spread) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) Test(org.testng.annotations.Test)

Example 4 with ScriptBuilder

use of org.btrplace.btrpsl.ScriptBuilder in project scheduler by btrplace.

the class AmongBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodAmongs")
public void testGoodSignatures(String str, int nbVMs, int nbNs1, int nbNs2, boolean c) throws Exception {
    ScriptBuilder b = new ScriptBuilder(new DefaultModel());
    Set<SatConstraint> cstrs = b.build("namespace test; VM[1..10] : tiny;\n@N[1..10] : defaultNode;\n" + str).getConstraints();
    Assert.assertEquals(cstrs.size(), 1);
    Among x = (Among) cstrs.iterator().next();
    Assert.assertEquals(x.getGroupsOfNodes().iterator().next().size(), nbNs1);
    Assert.assertEquals(x.getInvolvedNodes().size(), nbNs1 + nbNs2);
    Assert.assertEquals(x.getInvolvedVMs().size(), nbVMs);
    Assert.assertEquals(x.isContinuous(), c);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SatConstraint(org.btrplace.model.constraint.SatConstraint) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) Among(org.btrplace.model.constraint.Among) Test(org.testng.annotations.Test)

Example 5 with ScriptBuilder

use of org.btrplace.btrpsl.ScriptBuilder in project scheduler by btrplace.

the class FenceBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodFences")
public void testGoodSignatures(String str, int nbVMs, 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(), nbVMs);
    Set<VM> vms = new HashSet<>();
    for (SatConstraint x : cstrs) {
        Assert.assertTrue(x instanceof Fence);
        Assert.assertEquals(x.getInvolvedNodes().size(), nbNodes);
        Assert.assertTrue(vms.addAll(x.getInvolvedVMs()));
        Assert.assertEquals(x.isContinuous(), c);
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SatConstraint(org.btrplace.model.constraint.SatConstraint) VM(org.btrplace.model.VM) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) Fence(org.btrplace.model.constraint.Fence) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

ScriptBuilder (org.btrplace.btrpsl.ScriptBuilder)22 DefaultModel (org.btrplace.model.DefaultModel)22 Test (org.testng.annotations.Test)22 SatConstraint (org.btrplace.model.constraint.SatConstraint)14 HashSet (java.util.HashSet)12 VM (org.btrplace.model.VM)8 Node (org.btrplace.model.Node)4 Among (org.btrplace.model.constraint.Among)1 Ban (org.btrplace.model.constraint.Ban)1 Fence (org.btrplace.model.constraint.Fence)1 Gather (org.btrplace.model.constraint.Gather)1 Killed (org.btrplace.model.constraint.Killed)1 Lonely (org.btrplace.model.constraint.Lonely)1 MaxOnline (org.btrplace.model.constraint.MaxOnline)1 Overbook (org.btrplace.model.constraint.Overbook)1 Preserve (org.btrplace.model.constraint.Preserve)1 Quarantine (org.btrplace.model.constraint.Quarantine)1 Ready (org.btrplace.model.constraint.Ready)1 ResourceCapacity (org.btrplace.model.constraint.ResourceCapacity)1 Root (org.btrplace.model.constraint.Root)1