use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class GatherTest method testContinuousIsSatisfied.
@Test(dependsOnMethods = { "testDiscreteIsSatisfied" })
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 10);
List<VM> vms = Util.newVMs(mo, 10);
Set<VM> s = new HashSet<>(Arrays.asList(vms.get(0), vms.get(1)));
Gather g = new Gather(s);
g.setContinuous(true);
Mapping map = mo.getMapping();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addRunningVM(vms.get(0), ns.get(0));
map.addReadyVM(vms.get(1));
map.addRunningVM(vms.get(1), ns.get(1));
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(g.isSatisfied(plan), false);
map.addReadyVM(vms.get(1));
Assert.assertEquals(g.isSatisfied(plan), true);
plan.add(new BootVM(vms.get(1), ns.get(0), 0, 1));
Assert.assertEquals(g.isSatisfied(plan), true);
map.addRunningVM(vms.get(1), ns.get(0));
plan = new DefaultReconfigurationPlan(mo);
plan.add(new MigrateVM(vms.get(1), ns.get(0), ns.get(1), 0, 1));
plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 0, 1));
Assert.assertEquals(g.isSatisfied(plan), false);
}
use of org.btrplace.plan.ReconfigurationPlan in project scheduler by btrplace.
the class MaxOnlineTest method isSatisfiedReconfigurationPlan.
@Test
public void isSatisfiedReconfigurationPlan() {
Model model = new DefaultModel();
Mapping map = model.getMapping();
Node n1 = model.newNode();
Node n2 = model.newNode();
Node n3 = model.newNode();
map.addOnlineNode(n1);
map.addOnlineNode(n2);
map.addOfflineNode(n3);
Set<Node> s = new HashSet<>(Arrays.asList(n1, n2, n3));
MaxOnline mo = new MaxOnline(s, 2);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(model);
Assert.assertTrue(mo.isSatisfied(plan));
plan.add(new BootNode(n3, 3, 9));
Assert.assertFalse(mo.isSatisfied(plan));
plan.add(new ShutdownNode(n2, 0, 5));
Assert.assertTrue(mo.isSatisfied(plan));
}
use of org.btrplace.plan.ReconfigurationPlan 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.ReconfigurationPlan 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.ReconfigurationPlan 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));
}
Aggregations