Search in sources :

Example 86 with DefaultModel

use of org.btrplace.model.DefaultModel 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 87 with DefaultModel

use of org.btrplace.model.DefaultModel 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 88 with DefaultModel

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

Example 89 with DefaultModel

use of org.btrplace.model.DefaultModel 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 90 with DefaultModel

use of org.btrplace.model.DefaultModel 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);
    }
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Sleeping(org.btrplace.model.constraint.Sleeping) 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

DefaultModel (org.btrplace.model.DefaultModel)201 Test (org.testng.annotations.Test)177 Model (org.btrplace.model.Model)157 Node (org.btrplace.model.Node)91 VM (org.btrplace.model.VM)91 HashSet (java.util.HashSet)48 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)43 SatConstraint (org.btrplace.model.constraint.SatConstraint)40 Mapping (org.btrplace.model.Mapping)39 ArrayList (java.util.ArrayList)26 ShareableResource (org.btrplace.model.view.ShareableResource)24 ScriptBuilder (org.btrplace.btrpsl.ScriptBuilder)22 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)18 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)17 ShutdownableNode (org.btrplace.scheduler.choco.transition.ShutdownableNode)17 MigrateVM (org.btrplace.plan.event.MigrateVM)16 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)16 BootVM (org.btrplace.scheduler.choco.transition.BootVM)16 ForgeVM (org.btrplace.scheduler.choco.transition.ForgeVM)16 KillVM (org.btrplace.scheduler.choco.transition.KillVM)16