Search in sources :

Example 1 with EventCommittedListener

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

the class DefaultPlanApplierTest method testEventCommittedListeners.

@Test
public void testEventCommittedListeners() {
    DefaultPlanApplier app = new MockApplier();
    EventCommittedListener ev = mock(EventCommittedListener.class);
    app.addEventCommittedListener(ev);
    Assert.assertTrue(app.removeEventCommittedListener(ev));
}
Also used : EventCommittedListener(org.btrplace.plan.event.EventCommittedListener) Test(org.testng.annotations.Test)

Example 2 with EventCommittedListener

use of org.btrplace.plan.event.EventCommittedListener 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)

Example 3 with EventCommittedListener

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

the class DefaultPlanApplierTest method testFireSimpleAction.

@Test(dependsOnMethods = { "testEventCommittedListeners" })
public void testFireSimpleAction() {
    DefaultPlanApplier app = new MockApplier();
    EventCommittedListener ev = mock(EventCommittedListener.class);
    app.addEventCommittedListener(ev);
    BootVM b = new BootVM(vms.get(0), ns.get(0), 0, 5);
    app.fireAction(b);
    verify(ev, times(1)).committed(b);
    ShutdownVM svm = new ShutdownVM(vms.get(0), ns.get(0), 0, 5);
    app.fireAction(svm);
    verify(ev, times(1)).committed(svm);
    BootNode bn = new BootNode(ns.get(0), 0, 5);
    app.fireAction(bn);
    verify(ev, times(1)).committed(bn);
    ShutdownNode sn = new ShutdownNode(ns.get(0), 0, 5);
    app.fireAction(sn);
    verify(ev, times(1)).committed(sn);
    SuspendVM susVM = new SuspendVM(vms.get(0), ns.get(0), ns.get(1), 0, 5);
    app.fireAction(susVM);
    verify(ev, times(1)).committed(susVM);
    ResumeVM resVM = new ResumeVM(vms.get(0), ns.get(0), ns.get(1), 0, 5);
    app.fireAction(resVM);
    verify(ev, times(1)).committed(resVM);
    MigrateVM miVM = new MigrateVM(vms.get(0), ns.get(0), ns.get(1), 0, 5);
    app.fireAction(miVM);
    verify(ev, times(1)).committed(miVM);
    KillVM kvm = new KillVM(vms.get(0), ns.get(0), 0, 5);
    app.fireAction(kvm);
    verify(ev, times(1)).committed(kvm);
    ForgeVM fvm = new ForgeVM(vms.get(0), 0, 5);
    app.fireAction(fvm);
    verify(ev, times(1)).committed(fvm);
}
Also used : KillVM(org.btrplace.plan.event.KillVM) ResumeVM(org.btrplace.plan.event.ResumeVM) SuspendVM(org.btrplace.plan.event.SuspendVM) BootNode(org.btrplace.plan.event.BootNode) EventCommittedListener(org.btrplace.plan.event.EventCommittedListener) BootVM(org.btrplace.plan.event.BootVM) ShutdownNode(org.btrplace.plan.event.ShutdownNode) MigrateVM(org.btrplace.plan.event.MigrateVM) ForgeVM(org.btrplace.plan.event.ForgeVM) ShutdownVM(org.btrplace.plan.event.ShutdownVM) Test(org.testng.annotations.Test)

Aggregations

EventCommittedListener (org.btrplace.plan.event.EventCommittedListener)3 Test (org.testng.annotations.Test)3 BootVM (org.btrplace.plan.event.BootVM)2 AllocateEvent (org.btrplace.plan.event.AllocateEvent)1 BootNode (org.btrplace.plan.event.BootNode)1 ForgeVM (org.btrplace.plan.event.ForgeVM)1 KillVM (org.btrplace.plan.event.KillVM)1 MigrateVM (org.btrplace.plan.event.MigrateVM)1 ResumeVM (org.btrplace.plan.event.ResumeVM)1 ShutdownNode (org.btrplace.plan.event.ShutdownNode)1 ShutdownVM (org.btrplace.plan.event.ShutdownVM)1 SubstitutedVMEvent (org.btrplace.plan.event.SubstitutedVMEvent)1 SuspendVM (org.btrplace.plan.event.SuspendVM)1 InOrder (org.mockito.InOrder)1