Search in sources :

Example 11 with Model

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);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) MigrateVM(org.btrplace.plan.event.MigrateVM) BootVM(org.btrplace.plan.event.BootVM) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Mapping(org.btrplace.model.Mapping) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 12 with Model

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);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) Node(org.btrplace.model.Node) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) ReconfigurationPlan(org.btrplace.plan.ReconfigurationPlan) Mapping(org.btrplace.model.Mapping) MigrateVM(org.btrplace.plan.event.MigrateVM) DefaultReconfigurationPlan(org.btrplace.plan.DefaultReconfigurationPlan) MigrateVM(org.btrplace.plan.event.MigrateVM) VM(org.btrplace.model.VM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) ShutdownVM(org.btrplace.plan.event.ShutdownVM) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 13 with Model

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)));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) MigrateVM(org.btrplace.plan.event.MigrateVM) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 14 with Model

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);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) VM(org.btrplace.model.VM) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 15 with Model

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);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) MigrateVM(org.btrplace.plan.event.MigrateVM) BootVM(org.btrplace.plan.event.BootVM) VM(org.btrplace.model.VM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) SuspendVM(org.btrplace.plan.event.SuspendVM) ResumeVM(org.btrplace.plan.event.ResumeVM) ForgeVM(org.btrplace.plan.event.ForgeVM) KillVM(org.btrplace.plan.event.KillVM) Node(org.btrplace.model.Node) BootNode(org.btrplace.plan.event.BootNode) ShutdownNode(org.btrplace.plan.event.ShutdownNode) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Aggregations

Model (org.btrplace.model.Model)419 DefaultModel (org.btrplace.model.DefaultModel)406 Test (org.testng.annotations.Test)373 Node (org.btrplace.model.Node)276 VM (org.btrplace.model.VM)271 Mapping (org.btrplace.model.Mapping)181 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)147 HashSet (java.util.HashSet)97 MigrateVM (org.btrplace.plan.event.MigrateVM)90 SatConstraint (org.btrplace.model.constraint.SatConstraint)87 ArrayList (java.util.ArrayList)86 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)84 ShareableResource (org.btrplace.model.view.ShareableResource)75 ChocoScheduler (org.btrplace.scheduler.choco.ChocoScheduler)66 Instance (org.btrplace.model.Instance)50 ShutdownNode (org.btrplace.plan.event.ShutdownNode)47 MinMTTR (org.btrplace.model.constraint.MinMTTR)43 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)43 Parameters (org.btrplace.scheduler.choco.Parameters)39 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)39