use of org.btrplace.model.Model in project scheduler by btrplace.
the class GatherTest method testDiscreteIsSatisfied.
@Test
public void testDiscreteIsSatisfied() {
Model mo = new DefaultModel();
List<Node> ns = Util.newNodes(mo, 10);
List<VM> vms = Util.newVMs(mo, 10);
Set<VM> s = new HashSet<>(Arrays.asList(vms.get(0), vms.get(1)));
Gather g = new Gather(s);
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));
Assert.assertEquals(g.isSatisfied(mo), true);
map.addRunningVM(vms.get(1), ns.get(0));
Assert.assertEquals(g.isSatisfied(mo), true);
map.addRunningVM(vms.get(1), ns.get(1));
Assert.assertEquals(g.isSatisfied(mo), false);
}
use of org.btrplace.model.Model 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.model.Model in project scheduler by btrplace.
the class NoDelayTest method TestInstantiation.
@Test
public void TestInstantiation() {
final Model mo = new DefaultModel();
final VM vm = mo.newVM();
final NoDelay nd = new NoDelay(vm);
Assert.assertEquals(nd.getInvolvedVMs(), Collections.singleton(vm));
Assert.assertTrue(nd.setContinuous(false));
Assert.assertFalse(nd.setContinuous(true));
Assert.assertFalse(nd.isContinuous());
Assert.assertTrue(nd.equals(nd));
Assert.assertTrue(nd.equals(new NoDelay(vm)));
Assert.assertEquals(nd.hashCode(), new NoDelay(vm).hashCode());
final VM vm2 = mo.newVM();
Assert.assertFalse(nd.equals(new NoDelay(vm2)));
}
use of org.btrplace.model.Model in project scheduler by btrplace.
the class SleepingTest method testInstantiation.
@Test
public void testInstantiation() {
Model mo = new DefaultModel();
VM v = mo.newVM();
Sleeping s = new Sleeping(v);
Assert.assertNotNull(s.getChecker());
Assert.assertEquals(Collections.singletonList(v), s.getInvolvedVMs());
Assert.assertTrue(s.getInvolvedNodes().isEmpty());
Assert.assertNotNull(s.toString());
Assert.assertTrue(s.setContinuous(false));
System.out.println(s);
}
use of org.btrplace.model.Model in project scheduler by btrplace.
the class AllowAllConstraintCheckerTest method testInstantiation.
@Test
public void testInstantiation() {
SatConstraint cstr = mock(SatConstraint.class);
Model mo = new DefaultModel();
List<VM> vms = Util.newVMs(mo, 10);
List<Node> ns = Util.newNodes(mo, 10);
when(cstr.getInvolvedNodes()).thenReturn(ns);
when(cstr.getInvolvedVMs()).thenReturn(vms);
AllowAllConstraintChecker<SatConstraint> c = new AllowAllConstraintChecker<>(cstr);
Assert.assertEquals(c.getConstraint(), cstr);
Assert.assertEquals(c.getVMs(), vms);
Assert.assertEquals(c.getNodes(), ns);
}
Aggregations