Search in sources :

Example 1 with Quarantine

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

the class QuarantineConverterTest method testViables.

@Test
public void testViables() throws JSONConverterException {
    Model mo = new DefaultModel();
    ConstraintsConverter conv = new ConstraintsConverter();
    conv.register(new QuarantineConverter());
    Quarantine d = new Quarantine(mo.newNode());
    Assert.assertEquals(conv.fromJSON(mo, conv.toJSON(d)), d);
    System.out.println(conv.toJSON(d));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Quarantine(org.btrplace.model.constraint.Quarantine) Test(org.testng.annotations.Test)

Example 2 with Quarantine

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

the class CQuarantineTest method testWithNoSolution2.

/**
 * A VM try to leave the quarantine zone.
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testWithNoSolution2() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2, vm3).run(n3, vm4);
    Quarantine q = new Quarantine(n2);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(q);
    cstrs.add(new Fence(vm1, Collections.singleton(n2)));
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Quarantine(org.btrplace.model.constraint.Quarantine) ArrayList(java.util.ArrayList) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Example 3 with Quarantine

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

the class CQuarantineTest method testWithNoSolution1.

/**
 * A VM try to come into the quarantine zone.
 *
 * @throws org.btrplace.scheduler.SchedulerException
 */
@Test
public void testWithNoSolution1() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2, vm3).run(n3, vm4);
    Quarantine q = new Quarantine(n1);
    List<SatConstraint> cstrs = new ArrayList<>();
    cstrs.add(q);
    cstrs.add(new Fence(vm4, Collections.singleton(n1)));
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, cstrs);
    Assert.assertNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) SatConstraint(org.btrplace.model.constraint.SatConstraint) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Quarantine(org.btrplace.model.constraint.Quarantine) ArrayList(java.util.ArrayList) Fence(org.btrplace.model.constraint.Fence) Test(org.testng.annotations.Test)

Example 4 with Quarantine

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

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

the class CQuarantineTest method testWithSatisfiedModel.

@Test
public void testWithSatisfiedModel() throws SchedulerException {
    Model mo = new DefaultModel();
    VM vm1 = mo.newVM();
    VM vm2 = mo.newVM();
    VM vm3 = mo.newVM();
    VM vm4 = mo.newVM();
    Node n1 = mo.newNode();
    Node n2 = mo.newNode();
    Node n3 = mo.newNode();
    mo.getMapping().on(n1, n2, n3).run(n1, vm1).run(n2, vm2, vm3).run(n3, vm4);
    Quarantine q = new Quarantine(n2);
    ChocoScheduler cra = new DefaultChocoScheduler();
    ReconfigurationPlan p = cra.solve(mo, Collections.singleton(q));
    Assert.assertNotNull(p);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) ChocoScheduler(org.btrplace.scheduler.choco.ChocoScheduler) DefaultChocoScheduler(org.btrplace.scheduler.choco.DefaultChocoScheduler) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Quarantine(org.btrplace.model.constraint.Quarantine) Test(org.testng.annotations.Test)

Aggregations

DefaultModel (org.btrplace.model.DefaultModel)5 Quarantine (org.btrplace.model.constraint.Quarantine)5 Test (org.testng.annotations.Test)5 Model (org.btrplace.model.Model)4 Node (org.btrplace.model.Node)4 VM (org.btrplace.model.VM)3 SatConstraint (org.btrplace.model.constraint.SatConstraint)3 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)3 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)3 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)3 ArrayList (java.util.ArrayList)2 Fence (org.btrplace.model.constraint.Fence)2 HashSet (java.util.HashSet)1 ScriptBuilder (org.btrplace.btrpsl.ScriptBuilder)1