Search in sources :

Example 6 with ScriptBuilder

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

the class QuarantineBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodQuarantines")
public void testGoodSignatures(String str, int nbNodes) 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 x : cstrs) {
        Assert.assertTrue(x instanceof Quarantine);
        Assert.assertTrue(nodes.addAll(x.getInvolvedNodes()));
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SatConstraint(org.btrplace.model.constraint.SatConstraint) Node(org.btrplace.model.Node) Quarantine(org.btrplace.model.constraint.Quarantine) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 7 with ScriptBuilder

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

the class BanBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodBans")
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..10] : defaultNode;\n" + str).getConstraints();
    Assert.assertEquals(cstrs.size(), nbVMs);
    Set<VM> vms = new HashSet<>();
    for (SatConstraint s : cstrs) {
        Assert.assertTrue(s instanceof Ban);
        Assert.assertEquals(s.getInvolvedVMs().size(), 1);
        Assert.assertTrue(vms.addAll(s.getInvolvedVMs()));
        Assert.assertEquals(s.getInvolvedNodes().size(), nbNodes);
        Assert.assertEquals(s.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) Ban(org.btrplace.model.constraint.Ban) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 8 with ScriptBuilder

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

the class GatherBuilderTest method testGoodSignatures.

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

Example 9 with ScriptBuilder

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

the class PreserveBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodPreserves")
public void testGoodSignatures(String str, int nbVMs, String rcId, int a) 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 Preserve);
        Assert.assertTrue(vms.addAll(x.getInvolvedVMs()));
        Assert.assertEquals(x.isContinuous(), false);
        Assert.assertEquals(((Preserve) x).getResource(), rcId);
        Assert.assertEquals(((Preserve) x).getAmount(), a);
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SatConstraint(org.btrplace.model.constraint.SatConstraint) VM(org.btrplace.model.VM) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) Preserve(org.btrplace.model.constraint.Preserve) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 10 with ScriptBuilder

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

the class ReadyBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodReadys")
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 Ready);
        Assert.assertTrue(vms.addAll(x.getInvolvedVMs()));
        Assert.assertEquals(x.isContinuous(), c);
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Ready(org.btrplace.model.constraint.Ready) SatConstraint(org.btrplace.model.constraint.SatConstraint) VM(org.btrplace.model.VM) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) 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