use of org.btrplace.model.Node in project scheduler by btrplace.
the class BanTest method testEquals.
@Test
public void testEquals() {
Model m = new DefaultModel();
VM v = m.newVM();
List<Node> ns = Util.newNodes(m, 10);
Set<Node> nodes = new HashSet<>(Arrays.asList(ns.get(0), ns.get(1)));
Ban b = new Ban(v, nodes);
Assert.assertTrue(b.equals(b));
Assert.assertTrue(new Ban(v, nodes).equals(b));
Assert.assertEquals(new Ban(v, nodes).hashCode(), b.hashCode());
Assert.assertNotEquals(new Ban(m.newVM(), nodes), b);
}
use of org.btrplace.model.Node 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.model.Node in project scheduler by btrplace.
the class FenceTest method testIsSatisfied.
@Test
public void testIsSatisfied() {
Model m = new DefaultModel();
List<Node> ns = Util.newNodes(m, 10);
List<VM> vms = Util.newVMs(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(1));
Set<Node> nodes = new HashSet<>(Arrays.asList(ns.get(0), ns.get(1)));
Fence f = new Fence(vms.get(2), nodes);
Assert.assertEquals(true, f.isSatisfied(m));
map.addRunningVM(vms.get(0), ns.get(2));
Assert.assertEquals(false, new Fence(vms.get(0), nodes).isSatisfied(m));
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class FenceTest method testInstantiation.
@Test
public void testInstantiation() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 10);
List<VM> vms = Util.newVMs(mo, 10);
Set<Node> nodes = new HashSet<>(Collections.singletonList(ns.get(0)));
Fence f = new Fence(vms.get(0), nodes);
Assert.assertNotNull(f.getChecker());
Assert.assertEquals(vms.get(0), f.getInvolvedVMs().iterator().next());
Assert.assertEquals(nodes, f.getInvolvedNodes());
Assert.assertFalse(f.toString().contains("null"));
Assert.assertFalse(f.isContinuous());
Assert.assertTrue(f.setContinuous(true));
System.out.println(f);
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class FenceTest method testFences.
@Test
public void testFences() {
Model mo = new DefaultModel();
List<VM> vms = Util.newVMs(mo, 5);
List<Node> ns = Util.newNodes(mo, 5);
List<Fence> c = Fence.newFence(vms, ns);
Assert.assertEquals(vms.size(), c.size());
c.stream().forEach((q) -> {
Assert.assertTrue(vms.containsAll(q.getInvolvedVMs()));
Assert.assertEquals(ns, q.getInvolvedNodes());
Assert.assertFalse(q.isContinuous());
});
}
Aggregations