use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class AmongTest method testContinuousIsSatisfied.
@Test(dependsOnMethods = { "testInstantiation" })
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 10);
List<VM> vms = Util.newVMs(mo, 10);
Collection<Node> s1 = new HashSet<>(Arrays.asList(ns.get(0), ns.get(1)));
Collection<Node> s2 = new HashSet<>(Collections.singletonList(ns.get(2)));
Collection<Collection<Node>> pGrps = Arrays.asList(s1, s2);
Set<VM> vs = new HashSet<>(Arrays.asList(vms.get(0), vms.get(1), vms.get(2)));
Among a = new Among(vs, pGrps, true);
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.addRunningVM(vms.get(2), ns.get(1));
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(a.isSatisfied(plan), true);
plan.add(new MigrateVM(vms.get(2), ns.get(1), ns.get(2), 0, 1));
plan.add(new MigrateVM(vms.get(2), ns.get(2), ns.get(1), 1, 2));
// At moment 1, the constraint will be violated
Assert.assertEquals(a.isSatisfied(plan), false);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class BanTest method testIsSatisfied.
@Test
public void testIsSatisfied() {
Model m = new DefaultModel();
List<VM> vms = Util.newVMs(m, 10);
List<Node> ns = Util.newNodes(m, 10);
Mapping map = m.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.addRunningVM(vms.get(2), ns.get(2));
Set<Node> nodes = new HashSet<>(Collections.singletonList(ns.get(0)));
Ban b = new Ban(vms.get(2), nodes);
Assert.assertEquals(b.isSatisfied(m), true);
map.addRunningVM(vms.get(2), ns.get(0));
Assert.assertEquals(new Ban(vms.get(2), nodes).isSatisfied(m), false);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(m);
plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 0, 3));
plan.add(new MigrateVM(vms.get(0), ns.get(1), ns.get(0), 3, 6));
plan.add(new MigrateVM(vms.get(1), ns.get(1), ns.get(2), 3, 6));
Assert.assertEquals(b.isSatisfied(plan), false);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class LonelyTest method testContinuousIsSatisfied.
@Test(dependsOnMethods = { "testInstantiation" })
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
List<VM> vms = Util.newVMs(mo, 10);
List<Node> ns = Util.newNodes(mo, 10);
Set<VM> s = new HashSet<>(Arrays.asList(vms.get(0), vms.get(1)));
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(0));
map.addRunningVM(vms.get(2), ns.get(1));
map.addRunningVM(vms.get(3), ns.get(1));
Lonely l = new Lonely(s, true);
ReconfigurationPlan p = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(l.isSatisfied(p), true);
p.add(new MigrateVM(vms.get(1), ns.get(0), ns.get(1), 2, 4));
Assert.assertEquals(l.isSatisfied(p), false);
p.add(new ShutdownVM(vms.get(2), ns.get(1), 0, 1));
Assert.assertEquals(l.isSatisfied(p), false);
p.add(new MigrateVM(vms.get(3), ns.get(1), ns.get(2), 1, 2));
Assert.assertEquals(l.isSatisfied(p), true);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class OverbookTest method testContinuousIsSatisfied.
@Test
public void testContinuousIsSatisfied() {
Model mo = new DefaultModel();
List<VM> vms = Util.newVMs(mo, 10);
Node n0 = mo.newNode();
Node n1 = mo.newNode();
Model i = new DefaultModel();
Mapping cfg = i.getMapping();
cfg.addOnlineNode(n0);
cfg.addOnlineNode(n1);
ShareableResource rc = new ShareableResource("cpu");
rc.setCapacity(n0, 1);
rc.setCapacity(n1, 4);
rc.setConsumption(vms.get(0), 2);
rc.setConsumption(vms.get(1), 2);
rc.setConsumption(vms.get(2), 4);
cfg.addRunningVM(vms.get(0), n0);
cfg.addRunningVM(vms.get(1), n1);
cfg.addRunningVM(vms.get(2), n1);
cfg.addRunningVM(vms.get(3), n1);
i.attach(rc);
Overbook o = new Overbook(n1, "cpu", 2);
o.setContinuous(true);
ReconfigurationPlan p = new DefaultReconfigurationPlan(i);
Assert.assertEquals(o.isSatisfied(p), true);
p.add(new Allocate(vms.get(0), n0, "cpu", 1, 2, 5));
Assert.assertEquals(o.isSatisfied(p), true);
p.add(new Allocate(vms.get(1), n1, "cpu", 5, 2, 5));
Assert.assertEquals(o.isSatisfied(p), false);
p.add(new Allocate(vms.get(2), n1, "cpu", 2, 0, 1));
Assert.assertEquals(o.isSatisfied(p), true);
p.add(new Allocate(vms.get(3), n1, "cpu", 3, 4, 6));
Assert.assertEquals(o.isSatisfied(p), false);
p.add(new ShutdownVM(vms.get(2), n1, 2, 3));
Assert.assertEquals(o.isSatisfied(p), true);
}
use of org.btrplace.plan.DefaultReconfigurationPlan in project scheduler by btrplace.
the class ResourceCapacityTest 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));
map.addOnlineNode(ns.get(2));
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(2));
map.addReadyVM(vms.get(4));
ShareableResource rc = new ShareableResource("foo", 1, 1);
mo.attach(rc);
Set<Node> nodes = new HashSet<>(Arrays.asList(ns.get(0), ns.get(1)));
ResourceCapacity cc = new ResourceCapacity(nodes, "foo", 4, true);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(mo);
Assert.assertEquals(cc.isSatisfied(plan), true);
// 3/4
MigrateVM m = new MigrateVM(vms.get(3), ns.get(2), ns.get(1), 0, 1);
m.addEvent(Action.Hook.POST, new AllocateEvent(vms.get(3), "foo", 2));
plan.add(m);
// 5/4
plan.add(new ShutdownVM(vms.get(2), ns.get(1), 1, 2));
// 4/4
plan.add(new BootVM(vms.get(4), ns.get(2), 2, 3));
// 4/4
plan.add(new Allocate(vms.get(1), ns.get(0), "foo", 2, 2, 3));
// 5/4
plan.add(new MigrateVM(vms.get(0), ns.get(0), ns.get(2), 3, 4));
System.out.println(plan);
Assert.assertEquals(cc.isSatisfied(plan), true);
}
Aggregations