use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class RunningCapacityTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
Mapping m = mo.getMapping();
List<Node> ns = Util.newNodes(mo, 10);
List<VM> vms = Util.newVMs(mo, 10);
m.addOnlineNode(ns.get(0));
m.addOnlineNode(ns.get(1));
m.addRunningVM(vms.get(0), ns.get(0));
m.addReadyVM(vms.get(1));
m.addRunningVM(vms.get(2), ns.get(1));
m.addReadyVM(vms.get(3));
RunningCapacity c = new RunningCapacity(m.getAllNodes(), 2);
c.setContinuous(true);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(c.isSatisfied(plan), true);
plan.add(new BootVM(vms.get(3), ns.get(1), 2, 4));
Assert.assertEquals(c.isSatisfied(plan), false);
plan.add(new ShutdownVM(vms.get(0), ns.get(0), 0, 1));
Assert.assertEquals(c.isSatisfied(plan), true);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class SeqTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 5);
List<VM> vms = Util.newVMs(mo, 5);
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.addSleepingVM(vms.get(2), ns.get(0));
map.addRunningVM(vms.get(3), ns.get(0));
List<VM> l = Arrays.asList(vms.get(0), vms.get(1), vms.get(2), vms.get(3));
Seq c = new Seq(l);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
plan.add(new MigrateVM(vms.get(3), ns.get(0), ns.get(1), 0, 1));
plan.add(new SuspendVM(vms.get(0), ns.get(0), ns.get(0), 2, 3));
plan.add(new BootVM(vms.get(1), ns.get(0), 3, 4));
plan.add(new ResumeVM(vms.get(2), ns.get(0), ns.get(0), 4, 5));
Assert.assertEquals(c.isSatisfied(plan), true);
// Overlap
plan = new DefaultReconfigurationPlan(mo);
plan.add(new BootVM(vms.get(1), ns.get(0), 3, 4));
plan.add(new ResumeVM(vms.get(2), ns.get(0), ns.get(0), 3, 5));
Assert.assertEquals(c.isSatisfied(plan), false);
// Not the right precedence
plan = new DefaultReconfigurationPlan(mo);
plan.add(new BootVM(vms.get(1), ns.get(0), 3, 4));
plan.add(new ResumeVM(vms.get(2), ns.get(0), ns.get(0), 0, 1));
Assert.assertEquals(c.isSatisfied(plan), false);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class SeqTest method testContinuousSatisfied2.
@Test
public void testContinuousSatisfied2() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 5);
List<VM> vms = Util.newVMs(mo, 5);
Mapping map = mo.getMapping();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addReadyVM(vms.get(0));
map.addRunningVM(vms.get(1), ns.get(0));
map.addRunningVM(vms.get(2), ns.get(1));
map.addRunningVM(vms.get(3), ns.get(0));
ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
p.add(new BootVM(vms.get(0), ns.get(0), 0, 1));
p.add(new SuspendVM(vms.get(2), ns.get(1), ns.get(1), 1, 2));
p.add(new ShutdownVM(vms.get(3), ns.get(0), 2, 3));
List<VM> seq = Arrays.asList(vms.get(0), vms.get(1), vms.get(2), vms.get(3));
Seq cstr = new Seq(seq);
Assert.assertEquals(cstr.isSatisfied(p), true);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class SplitAmongTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 5);
List<VM> vms = Util.newVMs(mo, 5);
Collection<VM> vs1 = Arrays.asList(vms.get(0), vms.get(1));
Collection<VM> vs2 = Arrays.asList(vms.get(2), vms.get(3));
Collection<Collection<VM>> vGrps = Arrays.asList(vs1, vs2);
Collection<Node> ps1 = Arrays.asList(ns.get(0), ns.get(1));
Collection<Node> ps2 = Arrays.asList(ns.get(2), ns.get(3));
Collection<Collection<Node>> pGrps = Arrays.asList(ps1, ps2);
Mapping map = mo.getMapping();
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addOnlineNode(ns.get(2));
map.addOnlineNode(ns.get(3));
map.addRunningVM(vms.get(0), ns.get(0));
map.addRunningVM(vms.get(1), ns.get(0));
map.addRunningVM(vms.get(2), ns.get(2));
map.addRunningVM(vms.get(3), ns.get(3));
SplitAmong sp = new SplitAmong(vGrps, pGrps, true);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(sp.isSatisfied(plan), true);
plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 3, 4));
Assert.assertEquals(sp.isSatisfied(plan), true);
map.addRunningVM(vms.get(4), ns.get(3));
Assert.assertEquals(sp.isSatisfied(plan), true);
plan.add(new MigrateVM(vms.get(1), ns.get(0), ns.get(2), 0, 2));
Assert.assertEquals(sp.isSatisfied(plan), false);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class SplitTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
Mapping map = mo.getMapping();
List<Node> ns = Util.newNodes(mo, 3);
List<VM> vms = Util.newVMs(mo, 5);
map.addOnlineNode(ns.get(0));
map.addOnlineNode(ns.get(1));
map.addOnlineNode(ns.get(2));
Collection<VM> s1 = Arrays.asList(vms.get(0), vms.get(1));
Collection<VM> s2 = Arrays.asList(vms.get(2), vms.get(3));
Collection<VM> s3 = Collections.singleton(vms.get(4));
Collection<Collection<VM>> args = Arrays.asList(s1, s2, s3);
map.addRunningVM(vms.get(0), ns.get(0));
map.addRunningVM(vms.get(1), ns.get(0));
map.addRunningVM(vms.get(2), ns.get(1));
map.addRunningVM(vms.get(3), ns.get(1));
Split sp = new Split(args, true);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(sp.isSatisfied(plan), true);
// Violation
map.addRunningVM(vms.get(2), ns.get(0));
Assert.assertEquals(sp.isSatisfied(plan), false);
plan.add(new MigrateVM(vms.get(2), ns.get(0), ns.get(1), 0, 1));
// False cause there is the initial violation
Assert.assertEquals(sp.isSatisfied(plan), false);
sp.setContinuous(false);
Assert.assertEquals(sp.isSatisfied(plan), true);
sp.setContinuous(true);
// Temporary overlap
plan.add(new MigrateVM(vms.get(2), ns.get(1), ns.get(0), 5, 6));
plan.add(new MigrateVM(vms.get(2), ns.get(0), ns.get(1), 6, 7));
Assert.assertEquals(sp.isSatisfied(plan), false);
// Liberate ns.get(0) from vms.get(0) and vms.get(1) before
plan.add(new SuspendVM(vms.get(0), ns.get(0), ns.get(0), 2, 3));
plan.add(new ShutdownVM(vms.get(1), ns.get(0), 2, 3));
sp.setContinuous(false);
Assert.assertEquals(sp.isSatisfied(plan), true);
}
Aggregations