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));
}
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);
}
Aggregations