Search in sources :

Example 6 with SubstitutedVMEvent

use of org.btrplace.plan.event.SubstitutedVMEvent in project scheduler by btrplace.

the class AllowAllConstraintCheckerTest method testMyVMsTracking.

@Test(dependsOnMethods = "testInstantiation")
public void testMyVMsTracking() {
    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);
    // VM1 (one of the involved vms) has to be removed to be substituted by vms.get(0)0
    c.consume(new SubstitutedVMEvent(vms.get(0), vms.get(9)));
    Assert.assertTrue(c.getVMs().contains(vms.get(9)));
    Assert.assertFalse(c.getVMs().contains(vms.get(0)));
    // VM5 is not involved, no removal
    VM v = mo.newVM();
    c.consume(new SubstitutedVMEvent(vms.get(0), v));
    Assert.assertFalse(c.getVMs().contains(vms.get(0)));
    Assert.assertFalse(c.getVMs().contains(v));
}
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) SubstitutedVMEvent(org.btrplace.plan.event.SubstitutedVMEvent) Test(org.testng.annotations.Test)

Example 7 with SubstitutedVMEvent

use of org.btrplace.plan.event.SubstitutedVMEvent in project scheduler by btrplace.

the class DefaultPlanApplierTest method testFireComposedAction.

@Test
public void testFireComposedAction() {
    DefaultPlanApplier app = new MockApplier();
    EventCommittedListener ev = mock(EventCommittedListener.class);
    app.addEventCommittedListener(ev);
    BootVM b = new BootVM(vms.get(0), ns.get(0), 0, 5);
    AllocateEvent pre = new AllocateEvent(vms.get(0), "cpu", 7);
    b.addEvent(Action.Hook.PRE, pre);
    SubstitutedVMEvent post = new SubstitutedVMEvent(vms.get(0), vms.get(3));
    b.addEvent(Action.Hook.POST, post);
    InOrder order = inOrder(ev);
    app.fireAction(b);
    order.verify(ev).committed(pre);
    order.verify(ev).committed(b);
    order.verify(ev).committed(post);
}
Also used : InOrder(org.mockito.InOrder) EventCommittedListener(org.btrplace.plan.event.EventCommittedListener) BootVM(org.btrplace.plan.event.BootVM) SubstitutedVMEvent(org.btrplace.plan.event.SubstitutedVMEvent) AllocateEvent(org.btrplace.plan.event.AllocateEvent) Test(org.testng.annotations.Test)

Aggregations

SubstitutedVMEvent (org.btrplace.plan.event.SubstitutedVMEvent)7 VM (org.btrplace.model.VM)6 BootVM (org.btrplace.plan.event.BootVM)6 MigrateVM (org.btrplace.plan.event.MigrateVM)6 Test (org.testng.annotations.Test)6 DefaultModel (org.btrplace.model.DefaultModel)5 Model (org.btrplace.model.Model)5 Node (org.btrplace.model.Node)5 ResumeVM (org.btrplace.plan.event.ResumeVM)5 ShutdownVM (org.btrplace.plan.event.ShutdownVM)5 SuspendVM (org.btrplace.plan.event.SuspendVM)5 AllocateEvent (org.btrplace.plan.event.AllocateEvent)4 ForgeVM (org.btrplace.plan.event.ForgeVM)4 KillVM (org.btrplace.plan.event.KillVM)4 Allocate (org.btrplace.plan.event.Allocate)3 BootNode (org.btrplace.plan.event.BootNode)3 ShutdownNode (org.btrplace.plan.event.ShutdownNode)3 HashSet (java.util.HashSet)2 Mapping (org.btrplace.model.Mapping)1 DefaultReconfigurationPlan (org.btrplace.plan.DefaultReconfigurationPlan)1