Search in sources :

Example 66 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint 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);
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SatConstraint(org.btrplace.model.constraint.SatConstraint) Node(org.btrplace.model.Node) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 67 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.

the class OnlineBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodOnlines")
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;\n" + 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);
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SatConstraint(org.btrplace.model.constraint.SatConstraint) Node(org.btrplace.model.Node) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 68 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint 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(">>"));
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) SatConstraint(org.btrplace.model.constraint.SatConstraint) Node(org.btrplace.model.Node) Overbook(org.btrplace.model.constraint.Overbook) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 69 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.

the class RootBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodRoots")
public void testGoodSignatures(String str, int nbVMs) throws Exception {
    ScriptBuilder b = new ScriptBuilder(new DefaultModel());
    Set<SatConstraint> cstrs = b.build("namespace test; VM[1..10] : tiny;\n" + str).getConstraints();
    Assert.assertEquals(cstrs.size(), nbVMs);
    Set<VM> vms = new HashSet<>();
    for (SatConstraint x : cstrs) {
        Assert.assertTrue(x instanceof Root);
        Assert.assertTrue(vms.addAll(x.getInvolvedVMs()));
        Assert.assertEquals(x.isContinuous(), true);
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Root(org.btrplace.model.constraint.Root) 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)

Example 70 with SatConstraint

use of org.btrplace.model.constraint.SatConstraint in project scheduler by btrplace.

the class RunningBuilderTest method testGoodSignatures.

@Test(dataProvider = "goodRunnings")
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 Running);
        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) Running(org.btrplace.model.constraint.Running) ScriptBuilder(org.btrplace.btrpsl.ScriptBuilder) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

SatConstraint (org.btrplace.model.constraint.SatConstraint)78 Test (org.testng.annotations.Test)54 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)43 ArrayList (java.util.ArrayList)39 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)38 DefaultModel (org.btrplace.model.DefaultModel)33 ShareableResource (org.btrplace.model.view.ShareableResource)30 VM (org.btrplace.model.VM)27 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)27 Node (org.btrplace.model.Node)23 Model (org.btrplace.model.Model)20 HashSet (java.util.HashSet)17 Fence (org.btrplace.model.constraint.Fence)16 ScriptBuilder (org.btrplace.btrpsl.ScriptBuilder)14 Network (org.btrplace.model.view.network.Network)14 Offline (org.btrplace.model.constraint.Offline)13 Switch (org.btrplace.model.view.network.Switch)13 MigrateVM (org.btrplace.plan.event.MigrateVM)13 MinMTTRMig (org.btrplace.model.constraint.migration.MinMTTRMig)11 Preserve (org.btrplace.model.constraint.Preserve)9