Search in sources :

Example 1 with Action

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

the class ActionTest method testEvents.

@Test
public void testEvents() {
    Action a1 = new MockAction(new VM(1), 1, 3);
    Event e = mock(Event.class);
    a1.addEvent(Action.Hook.PRE, e);
    Assert.assertEquals(1, a1.getEvents(Action.Hook.PRE).size());
    a1.addEvent(Action.Hook.POST, e);
    Assert.assertEquals(1, a1.getEvents(Action.Hook.POST).size());
}
Also used : Action(org.btrplace.plan.event.Action) VM(org.btrplace.model.VM) Event(org.btrplace.plan.event.Event) Test(org.testng.annotations.Test)

Example 2 with Action

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

the class ContinuousViolationExceptionTest method test.

@Test
public void test() {
    SatConstraint c = Mockito.mock(SatConstraint.class);
    Action a = Mockito.mock(Action.class);
    ContinuousViolationException ex = new ContinuousViolationException(c, a);
    Assert.assertEquals(ex.getAction(), a);
    Assert.assertEquals(ex.getConstraint(), c);
    Assert.assertFalse(ex.toString().contains("null"));
}
Also used : Action(org.btrplace.plan.event.Action) SatConstraint(org.btrplace.model.constraint.SatConstraint) Test(org.testng.annotations.Test)

Example 3 with Action

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

the class DefaultReconfigurationPlanTest method testAddDurationAndSize.

@Test(dependsOnMethods = { "testInstantiate" })
public void testAddDurationAndSize() {
    Model m = new DefaultModel();
    List<VM> vms = Util.newVMs(m, 10);
    DefaultReconfigurationPlan p = new DefaultReconfigurationPlan(m);
    Action a1 = new MockAction(vms.get(0), 1, 3);
    Action a2 = new MockAction(vms.get(1), 2, 4);
    Action a3 = new MockAction(vms.get(2), 2, 4);
    Action a4 = new MockAction(vms.get(3), 1, 3);
    Assert.assertTrue(p.add(a1));
    Assert.assertEquals(3, p.getDuration());
    Assert.assertTrue(p.add(a4));
    Assert.assertTrue(p.add(a3));
    Assert.assertTrue(p.add(a2));
    Assert.assertEquals(4, p.getDuration());
    int last = -1;
    System.out.println(p);
    for (Action a : p) {
        Assert.assertTrue(a.getStart() >= last);
        last = a.getStart();
    }
    Assert.assertFalse(p.add(a2));
    Assert.assertEquals(4, p.getSize());
    Assert.assertFalse(p.toString().contains("null"));
}
Also used : Action(org.btrplace.plan.event.Action) MigrateVM(org.btrplace.plan.event.MigrateVM) SuspendVM(org.btrplace.plan.event.SuspendVM) Test(org.testng.annotations.Test)

Example 4 with Action

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

the class TimedBasedActionComparatorTest method testEqualityWithSimultaneousDisallowed.

@Test
public void testEqualityWithSimultaneousDisallowed() {
    VM vm2 = mo.newVM();
    Action a = new MockAction(vm, 0, 4);
    Action b = new MockAction(vm2, 0, 4);
    Assert.assertNotEquals(new TimedBasedActionComparator(false, true).compare(a, b), 0);
    Assert.assertNotEquals(new TimedBasedActionComparator(true, true).compare(a, b), 0);
}
Also used : Action(org.btrplace.plan.event.Action) VM(org.btrplace.model.VM) Test(org.testng.annotations.Test)

Example 5 with Action

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

the class TimedBasedActionComparatorTest method testEquality.

@Test
public void testEquality() {
    Action a = new MockAction(vm, 0, 4);
    Action b = new MockAction(vm, 0, 4);
    Assert.assertEquals(startCmp.compare(a, b), 0);
    Assert.assertEquals(stopCmp.compare(a, b), 0);
}
Also used : Action(org.btrplace.plan.event.Action) Test(org.testng.annotations.Test)

Aggregations

Action (org.btrplace.plan.event.Action)40 Test (org.testng.annotations.Test)25 ReconfigurationPlan (org.btrplace.plan.ReconfigurationPlan)18 MigrateVM (org.btrplace.plan.event.MigrateVM)10 DurationEvaluators (org.btrplace.scheduler.choco.duration.DurationEvaluators)10 HashSet (java.util.HashSet)9 Parameters (org.btrplace.scheduler.choco.Parameters)9 ReconfigurationProblem (org.btrplace.scheduler.choco.ReconfigurationProblem)9 VM (org.btrplace.model.VM)8 DefaultParameters (org.btrplace.scheduler.choco.DefaultParameters)8 DefaultReconfigurationProblemBuilder (org.btrplace.scheduler.choco.DefaultReconfigurationProblemBuilder)8 Model (org.btrplace.model.Model)7 CMinMTTR (org.btrplace.scheduler.choco.constraint.mttr.CMinMTTR)7 ArrayList (java.util.ArrayList)6 SatConstraint (org.btrplace.model.constraint.SatConstraint)6 Node (org.btrplace.model.Node)5 ShareableResource (org.btrplace.model.view.ShareableResource)5 DefaultChocoScheduler (org.btrplace.scheduler.choco.DefaultChocoScheduler)5 BootVM (org.btrplace.plan.event.BootVM)4 ShutdownNode (org.btrplace.plan.event.ShutdownNode)4