use of org.btrplace.plan.event.MigrateVM 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.event.MigrateVM 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);
}
use of org.btrplace.plan.event.MigrateVM 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);
}
Aggregations