use of org.btrplace.model.Node in project scheduler by btrplace.
the class MaxOnlineTest method testInstantiation.
@Test
public void testInstantiation() {
Model mo = new DefaultModel();
Set<Node> s = new HashSet<>(Arrays.asList(mo.newNode(), mo.newNode()));
MaxOnline o = new MaxOnline(s, 3);
Assert.assertNotNull(o.getChecker());
Assert.assertEquals(o.getInvolvedNodes(), s);
Assert.assertTrue(o.getInvolvedVMs().isEmpty());
Assert.assertNotNull(o.toString());
Assert.assertFalse(o.isContinuous());
Assert.assertTrue(o.setContinuous(true));
Assert.assertTrue(o.isContinuous());
Assert.assertTrue(o.setContinuous(false));
Assert.assertTrue(o.equals(new MaxOnline(s, 3)));
Assert.assertEquals(o.hashCode(), new MaxOnline(s, 3, false).hashCode());
Assert.assertFalse(o.equals(new MaxOnline(s, 4)));
Assert.assertFalse(o.equals(new MaxOnline(Collections.singleton(mo.newNode()), 3)));
Assert.assertFalse(o.equals(new MaxOnline(s, 3, true)));
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class OverbookTest method testEquals.
@Test
public void testEquals() {
Model mo = new DefaultModel();
Node n = mo.newNode();
Overbook s = new Overbook(n, "foo", 3);
Assert.assertTrue(s.equals(s));
Overbook o2 = new Overbook(n, "foo", 3);
Assert.assertTrue(o2.equals(s));
Assert.assertEquals(o2.hashCode(), s.hashCode());
Assert.assertFalse(new Overbook(n, "bar", 3).equals(s));
Assert.assertFalse(new Overbook(n, "foo", 2).equals(s));
Assert.assertFalse(new Overbook(mo.newNode(), "foo", 3).equals(s));
Assert.assertNotEquals(new Overbook(mo.newNode(), "foo", 3, true), new Overbook(mo.newNode(), "foo", 3, false));
Assert.assertNotEquals(new Overbook(mo.newNode(), "foo", 3, true).hashCode(), new Overbook(mo.newNode(), "foo", 3, false).hashCode());
}
use of org.btrplace.model.Node 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.model.Node in project scheduler by btrplace.
the class QuarantineTest method testQuarantines.
@Test
public void testQuarantines() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 5);
List<Quarantine> qs = Quarantine.newQuarantine(ns);
Assert.assertEquals(qs.size(), ns.size());
qs.stream().forEach((q) -> {
Assert.assertTrue(ns.containsAll(q.getInvolvedNodes()));
Assert.assertTrue(q.isContinuous());
});
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class QuarantineTest method testEqualsHashCode.
@Test
public void testEqualsHashCode() {
Model mo = new DefaultModel();
Node n = mo.newNode();
Quarantine q = new Quarantine(n);
Assert.assertTrue(q.equals(q));
Assert.assertTrue(q.equals(new Quarantine(n)));
Assert.assertEquals(q.hashCode(), new Quarantine(n).hashCode());
Assert.assertFalse(q.equals(new Quarantine(mo.newNode())));
}
Aggregations