use of org.btrplace.model.Node in project scheduler by btrplace.
the class MaxOnlineTest method isSatisfiedModel.
@Test
public void isSatisfiedModel() {
Model model = new DefaultModel();
Mapping map = model.getMapping();
Node n1 = model.newNode();
Node n2 = model.newNode();
Node n3 = model.newNode();
map.addOnlineNode(n1);
map.addOnlineNode(n2);
map.addOfflineNode(n3);
Set<Node> s = new HashSet<>(Arrays.asList(n1, n2, n3));
MaxOnline mo = new MaxOnline(s, 2);
Assert.assertTrue(mo.isSatisfied(model));
model.getMapping().addOnlineNode(n3);
Assert.assertFalse(mo.isSatisfied(model));
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class MaxOnlineTest method isSatisfiedReconfigurationPlan.
@Test
public void isSatisfiedReconfigurationPlan() {
Model model = new DefaultModel();
Mapping map = model.getMapping();
Node n1 = model.newNode();
Node n2 = model.newNode();
Node n3 = model.newNode();
map.addOnlineNode(n1);
map.addOnlineNode(n2);
map.addOfflineNode(n3);
Set<Node> s = new HashSet<>(Arrays.asList(n1, n2, n3));
MaxOnline mo = new MaxOnline(s, 2);
ReconfigurationPlan plan = new DefaultReconfigurationPlan(model);
Assert.assertTrue(mo.isSatisfied(plan));
plan.add(new BootNode(n3, 3, 9));
Assert.assertFalse(mo.isSatisfied(plan));
plan.add(new ShutdownNode(n2, 0, 5));
Assert.assertTrue(mo.isSatisfied(plan));
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class MaxOnlineTest method testEquals.
public void testEquals() {
Model m = new DefaultModel();
Set<Node> s = new HashSet<>(Arrays.asList(m.newNode(), m.newNode()));
MaxOnline mo = new MaxOnline(s, 3);
Assert.assertEquals(mo, new MaxOnline(s, 3));
Assert.assertNotEquals(mo, new MaxOnline(s, 1));
Assert.assertNotEquals(mo, new MaxOnline(new HashSet<>(), 3));
Assert.assertNotEquals(new MaxOnline(s, 3, true), new MaxOnline(s, 3, false));
Assert.assertEquals(mo, new MaxOnline(s, 3));
Assert.assertNotEquals(new MaxOnline(s, 3, true).hashCode(), new MaxOnline(s, 3, false).hashCode());
Assert.assertEquals(new MaxOnline(s, 3, true), new MaxOnline(s, 3, false));
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class NetworkTest method defaultTest.
/**
* Test the instantiation and the creation of the objects using the default routing implementation.
*/
@Test
public void defaultTest() {
Model mo = new DefaultModel();
Network net = new Network();
Switch s = net.newSwitch(1000);
Node n1 = mo.newNode();
Node n2 = mo.newNode();
net.connect(2000, s, n1, n2);
Assert.assertNull(Network.get(mo));
mo.attach(net);
Assert.assertEquals(Network.get(mo), net);
Assert.assertTrue(net.getSwitches().size() == 1);
Assert.assertEquals(net.getSwitches().get(0), s);
Assert.assertTrue(s.getCapacity() == 1000);
Assert.assertTrue(net.getLinks().size() == 2);
Assert.assertTrue(net.getLinks().size() == 2);
for (Link l : net.getLinks()) {
Assert.assertTrue(l.getCapacity() == 2000);
Assert.assertTrue(l.getSwitch().equals(s) || l.getElement() instanceof Switch);
}
Assert.assertTrue(net.getRouting().getPath(n1, n2).size() == 2);
Assert.assertTrue(net.getRouting().getPath(n1, n2).containsAll(net.getLinks()));
}
use of org.btrplace.model.Node in project scheduler by btrplace.
the class NetworkTest method staticRoutingTest.
/**
* Test the static routing implementation.
*/
@Test
public void staticRoutingTest() {
Model mo = new DefaultModel();
Network net = new Network(new StaticRouting());
Switch s = net.newSwitch(1000);
Node n1 = mo.newNode();
Node n2 = mo.newNode();
net.connect(2000, s, n1, n2);
Map<Link, Boolean> route = new LinkedHashMap<>();
route.put(net.getConnectedLinks(n1).get(0), true);
route.put(net.getConnectedLinks(n2).get(0), false);
((StaticRouting) net.getRouting()).setStaticRoute(new StaticRouting.NodesMap(n1, n2), route);
mo.attach(net);
Assert.assertTrue(net.getRouting().getPath(n1, n2).size() == 2);
Assert.assertTrue(net.getRouting().getPath(n1, n2).containsAll(net.getLinks()));
}
Aggregations