Search in sources :

Example 6 with VM

use of org.btrplace.model.VM 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)

Example 7 with VM

use of org.btrplace.model.VM in project scheduler by btrplace.

the class AllowAllConstraintCheckerTest method testAnyTracking.

@Test(dependsOnMethods = "testInstantiation")
public void testAnyTracking() {
    SatConstraint cstr = mock(SatConstraint.class);
    AllowAllConstraintChecker<SatConstraint> c = new AllowAllConstraintChecker<>(cstr);
    Model mo = new DefaultModel();
    List<VM> vms = Util.newVMs(mo, 10);
    when(cstr.getInvolvedVMs()).thenReturn(vms);
    Set<VM> vs = new HashSet<>(Arrays.asList(vms.get(4), vms.get(6), vms.get(9)));
    c.track(vs);
    // VM1 (one of the involved vms) has to be removed to be substituted by vms.get(0)0
    c.consume(new SubstitutedVMEvent(vms.get(6), vms.get(9)));
    Assert.assertTrue(vs.contains(vms.get(9)));
    Assert.assertFalse(vs.contains(vms.get(6)));
    // VM5 is not involved, no removal
    c.consume(new SubstitutedVMEvent(vms.get(6), vms.get(0)));
    Assert.assertFalse(vs.contains(vms.get(6)));
    Assert.assertFalse(vs.contains(vms.get(0)));
}
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) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) SubstitutedVMEvent(org.btrplace.plan.event.SubstitutedVMEvent) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 8 with VM

use of org.btrplace.model.VM in project scheduler by btrplace.

the class NamingServiceTest method testResolution.

@Test(dependsOnMethods = { "testRegisterAndGets" })
public void testResolution() {
    NamingService<VM> ns = NamingService.newVMNS();
    Assert.assertEquals(ns.getElementIdentifier(), VM.TYPE);
    Model mo = new DefaultModel();
    VM v = mo.newVM();
    ns.register(v, "vm0");
    Assert.assertEquals(ns.resolve(v), "vm0");
    Assert.assertEquals(ns.resolve("vm0"), v);
    Assert.assertNull(ns.resolve("vm1"));
}
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 9 with VM

use of org.btrplace.model.VM in project scheduler by btrplace.

the class NamingServiceTest method testSubstitution.

@Test(dependsOnMethods = { "testRegisterAndGets" })
public void testSubstitution() {
    NamingService<VM> ns = NamingService.newVMNS();
    Model mo = new DefaultModel();
    VM v = mo.newVM();
    ns.register(v, "vm0");
    VM v2 = mo.newVM();
    ns.substituteVM(v, v2);
    Assert.assertNull(ns.resolve(v));
    Assert.assertEquals(ns.resolve(v2), "vm0");
    Assert.assertEquals(ns.resolve("vm0"), v2);
    NamingService<Node> ns2 = NamingService.newNodeNS();
    ns2.register(mo.newNode(), "n0");
    Assert.assertTrue(ns2.substituteVM(mo.newVM(), mo.newVM()));
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Example 10 with VM

use of org.btrplace.model.VM in project scheduler by btrplace.

the class NamingServiceTest method testGetViews.

@Test
public void testGetViews() {
    Model mo = new DefaultModel();
    Assert.assertNull(NamingService.getVMNames(mo));
    Assert.assertNull(NamingService.getNodeNames(mo));
    NamingService<VM> vmNs = NamingService.newVMNS();
    NamingService<Node> nodeNs = NamingService.newNodeNS();
    mo.attach(vmNs);
    mo.attach(nodeNs);
    Assert.assertEquals(NamingService.getNodeNames(mo), nodeNs);
    Assert.assertEquals(NamingService.getVMNames(mo), vmNs);
}
Also used : DefaultModel(org.btrplace.model.DefaultModel) VM(org.btrplace.model.VM) Node(org.btrplace.model.Node) Model(org.btrplace.model.Model) DefaultModel(org.btrplace.model.DefaultModel) Test(org.testng.annotations.Test)

Aggregations

VM (org.btrplace.model.VM)192 Node (org.btrplace.model.Node)110 Model (org.btrplace.model.Model)92 DefaultModel (org.btrplace.model.DefaultModel)91 Test (org.testng.annotations.Test)91 Mapping (org.btrplace.model.Mapping)64 HashSet (java.util.HashSet)58 ArrayList (java.util.ArrayList)43 SatConstraint (org.btrplace.model.constraint.SatConstraint)40 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)39 VMTransition (org.btrplace.scheduler.choco.transition.VMTransition)35 IntVar (org.chocosolver.solver.variables.IntVar)35 ShareableResource (org.btrplace.model.view.ShareableResource)32 RelocatableVM (org.btrplace.scheduler.choco.transition.RelocatableVM)27 MigrateVM (org.btrplace.plan.event.MigrateVM)25 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)17 StayAwayVM (org.btrplace.scheduler.choco.transition.StayAwayVM)17 Slice (org.btrplace.scheduler.choco.Slice)16 BootVM (org.btrplace.scheduler.choco.transition.BootVM)16 BootableNode (org.btrplace.scheduler.choco.transition.BootableNode)16