Search in sources :

Example 26 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint 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 27 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint 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)

Example 28 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint 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 29 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint 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 30 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint 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)

Aggregations

SatConstraint (org.btrplace.model.constraint.SatConstraint)111 DefaultModel (org.btrplace.model.DefaultModel)90 Test (org.testng.annotations.Test)82 VM (org.btrplace.model.VM)79 Node (org.btrplace.model.Node)77 Model (org.btrplace.model.Model)76 ArrayList (java.util.ArrayList)74 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)72 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)65 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)51 Mapping (org.btrplace.model.Mapping)50 ShareableResource (org.btrplace.model.view.ShareableResource)41 HashSet (java.util.HashSet)33 Fence (org.btrplace.model.constraint.Fence)27 Offline (org.btrplace.model.constraint.Offline)17 Preserve (org.btrplace.model.constraint.Preserve)16 MigrateVM (org.btrplace.plan.event.MigrateVM)15 ScriptBuilder (org.btrplace.btrpsl.ScriptBuilder)14 Instance (org.btrplace.model.Instance)14 Network (org.btrplace.model.view.network.Network)14