use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class NoDelayTest method testIsSatisfied.
@Test
public void testIsSatisfied() {
// Create a new default model
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
// Create 4 nodes
List<Node> ns = Util.newNodes(mo, 4);
// Create 2 vms
List<VM> vms = Util.newVMs(mo, 2);
// Set the nodes online
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addOnlineNode(ns.get(2));
map.addOnlineNode(ns.get(3));
// Run the 2 vms on the two first nodes
map.addRunningVM(vms.get(0), ns.get(0));
map.addRunningVM(vms.get(1), ns.get(1));
// Set as initial plan
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
// Create a NoDelay constraint by constraining the first VM
NoDelay nd = new NoDelay(vms.get(0));
// The constraint should be satisfied by default
Assert.assertEquals(nd.isSatisfied(plan), true);
// Migrate the first VM (constrained) at t=0 to the third node
plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(2), 0, 1));
Assert.assertEquals(nd.isSatisfied(plan), true);
// Migrate the second VM at t=0 to the last node
plan.add(new MigrateVM(vms.get(1), ns.get(1), ns.get(3), 0, 1));
Assert.assertEquals(nd.isSatisfied(plan), true);
// Re-Migrate the second VM at t=1 to the second node
plan.add(new MigrateVM(vms.get(1), ns.get(3), ns.get(1), 1, 2));
Assert.assertEquals(nd.isSatisfied(plan), true);
// Re-Migrate the first VM (constrained) at t=1 to the first node
plan.add(new MigrateVM(vms.get(0), ns.get(2), ns.get(0), 1, 2));
Assert.assertEquals(nd.isSatisfied(plan), false);
// Shutdown node
// plan.add(new ShutdownNode(ns.get(2), 0, 1));
// Assert.assertEquals(nd.isSatisfied(plan), true);
// Boot node
// plan.add(new BootNode(ns.get(2), 1, 3));
// Assert.assertEquals(nd.isSatisfied(plan), false);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class OfflineTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 10);
List<VM> vms = Util.newVMs(mo, 10);
Mapping map = mo.getMapping();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
Offline off = new Offline(ns.get(0));
map.addRunningVM(vms.get(0), ns.get(0));
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(off.isSatisfied(plan), false);
plan.add(new ShutdownNode(ns.get(1), 0, 1));
plan.add(new ShutdownVM(vms.get(0), ns.get(0), 0, 1));
Assert.assertEquals(off.isSatisfied(plan), false);
plan.add(new ShutdownNode(ns.get(0), 1, 2));
Assert.assertEquals(off.isSatisfied(plan), true);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class PreserveTest method testIsSatisfied.
@Test(dependsOnMethods = { "testInstantiation" })
public void testIsSatisfied() {
Model m = new DefaultModel();
List<VM> vms = Util.newVMs(m, 5);
List<Node> ns = Util.newNodes(m, 5);
ShareableResource rc = new ShareableResource("cpu", 3, 3);
Mapping map = m.getMapping();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addRunningVM(vms.get(0), ns.get(0));
map.addSleepingVM(vms.get(1), ns.get(0));
map.addRunningVM(vms.get(2), ns.get(0));
m.attach(rc);
Preserve p = new Preserve(vms.get(0), "cpu", 3);
rc.setConsumption(vms.get(0), 3);
// Not running so we don't care
rc.setConsumption(vms.get(1), 1);
rc.setConsumption(vms.get(2), 3);
Assert.assertEquals(true, p.isSatisfied(m));
// Set to 3 by default
rc.unset(vms.get(2));
Assert.assertEquals(true, p.isSatisfied(m));
Assert.assertEquals(false, new Preserve(vms.get(2), "mem", 3).isSatisfied(m));
ReconfigurationPlan plan = new DefaultReconfigurationPlan(m);
rc.setConsumption(vms.get(1), 1);
Assert.assertFalse(new Preserve(vms.get(2), "cpu", 4).isSatisfied(plan));
plan.add(new Allocate(vms.get(2), ns.get(0), "cpu", 7, 5, 7));
Assert.assertTrue(p.isSatisfied(plan));
rc.setConsumption(vms.get(0), 1);
AllocateEvent e = new AllocateEvent(vms.get(0), "cpu", 4);
Assert.assertFalse(p.isSatisfied(plan));
MigrateVM mig = new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 0, 3);
mig.addEvent(Action.Hook.POST, e);
plan.add(mig);
Assert.assertTrue(p.isSatisfied(plan));
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class QuarantineTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
List<VM> vms = Util.newVMs(mo, 5);
List<Node> ns = Util.newNodes(mo, 5);
Mapping map = mo.getMapping();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addOnlineNode(ns.get(2));
map.addRunningVM(vms.get(0), ns.get(0));
map.addRunningVM(vms.get(1), ns.get(1));
map.addReadyVM(vms.get(2));
map.addRunningVM(vms.get(3), ns.get(2));
Quarantine q = new Quarantine(ns.get(0));
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(q.isSatisfied(plan), true);
plan.add(new ShutdownVM(vms.get(1), ns.get(1), 1, 2));
Assert.assertEquals(q.isSatisfied(plan), true);
plan.add(new BootVM(vms.get(2), ns.get(0), 0, 1));
Assert.assertEquals(q.isSatisfied(plan), false);
plan = new DefaultReconfigurationPlan(mo);
plan.add(new BootVM(vms.get(2), ns.get(2), 0, 1));
Assert.assertEquals(new Quarantine(ns.get(1)).isSatisfied(plan), true);
plan.add(new MigrateVM(vms.get(3), ns.get(2), ns.get(1), 0, 1));
Assert.assertEquals(new Quarantine(ns.get(1)).isSatisfied(plan), false);
plan = new DefaultReconfigurationPlan(mo);
plan.add(new MigrateVM(vms.get(1), ns.get(1), ns.get(0), 0, 1));
Assert.assertEquals(q.isSatisfied(plan), false);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class RootTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
List<Node> ns = Util.newNodes(mo, 3);
VM vm1 = mo.newVM();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addRunningVM(vm1, ns.get(0));
ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
Root r = new Root(vm1);
Assert.assertEquals(r.isSatisfied(p), true);
p.add(new MigrateVM(vm1, ns.get(0), ns.get(1), 1, 2));
Assert.assertEquals(r.isSatisfied(p), false);
}
Aggregations