Search in sources :

Example 6 with Plan

use of com.mesosphere.sdk.scheduler.plan.Plan in project dcos-commons by mesosphere.

the class Expect method stepStatus.

/**
 * Verifies that the indicated plan.phase.step has the expected status.
 */
public static Expect stepStatus(String planName, String phaseName, String stepName, Status expectedStatus) {
    return new Expect() {

        @Override
        public void expect(ClusterState state, SchedulerDriver mockDriver) {
            Plan recoveryPlan = state.getPlans().stream().filter(plan -> plan.getName().equals(planName)).findAny().get();
            Phase phase = recoveryPlan.getChildren().stream().filter(p -> p.getName().equals(phaseName)).findAny().get();
            Step step = phase.getChildren().stream().filter(s -> s.getName().equals(stepName)).findAny().get();
            Assert.assertEquals(expectedStatus, step.getStatus());
        }

        @Override
        public String getDescription() {
            return String.format("For Phase: %s, Step: %s, Status is %s", phaseName, stepName, expectedStatus);
        }
    };
}
Also used : Phase(com.mesosphere.sdk.scheduler.plan.Phase) Step(com.mesosphere.sdk.scheduler.plan.Step) Plan(com.mesosphere.sdk.scheduler.plan.Plan) SchedulerDriver(org.apache.mesos.SchedulerDriver)

Example 7 with Plan

use of com.mesosphere.sdk.scheduler.plan.Plan in project dcos-commons by mesosphere.

the class Expect method planStatus.

public static Expect planStatus(String planName, Status status) {
    return new Expect() {

        @Override
        public void expect(ClusterState state, SchedulerDriver mockDriver) throws AssertionError {
            Plan plan = state.getPlans().stream().filter(p -> p.getName().equals(planName)).findFirst().get();
            Assert.assertEquals(status, plan.getStatus());
        }

        @Override
        public String getDescription() {
            return String.format("Plan %s has status %s", planName, status);
        }
    };
}
Also used : Plan(com.mesosphere.sdk.scheduler.plan.Plan) SchedulerDriver(org.apache.mesos.SchedulerDriver)

Example 8 with Plan

use of com.mesosphere.sdk.scheduler.plan.Plan in project dcos-commons by mesosphere.

the class DecommissionPlanFactoryTest method testBigPlanConstruction.

@Test
public void testBigPlanConstruction() {
    when(mockStateStore.fetchTasks()).thenReturn(tasks);
    DecommissionPlanFactory factory = new DecommissionPlanFactory(mockServiceSpec, mockStateStore);
    // any tasks with existing decommission bits but which are not to be decommissioned have had their decommission bits cleared (see list above):
    for (String taskToClear : Arrays.asList("podA-0-taskA", "podB-0-taskB")) {
        verify(mockStateStore, times(1)).storeGoalOverrideStatus(taskToClear, GoalStateOverride.Status.INACTIVE);
    }
    // any tasks to decommission that were paused or no-override are assigned with a pending decommission bit:
    for (String taskToClear : Arrays.asList("podA-2-taskA", "podB-1-taskB", "podE-0-taskA")) {
        verify(mockStateStore, times(1)).storeGoalOverrideStatus(taskToClear, GoalStateOverride.DECOMMISSIONED.newStatus(GoalStateOverride.Progress.PENDING));
    }
    Assert.assertEquals(14, factory.getResourceSteps().size());
    Assert.assertTrue(factory.getPlan().isPresent());
    Plan plan = factory.getPlan().get();
    Assert.assertEquals(6, plan.getChildren().size());
    Assert.assertEquals(Status.PENDING, plan.getStatus());
    Phase phase = plan.getChildren().get(0);
    Assert.assertEquals("podD-1", phase.getName());
    Assert.assertEquals(3, phase.getChildren().size());
    Assert.assertEquals("kill-podD-1-taskA", phase.getChildren().get(0).getName());
    Assert.assertEquals("unreserve-podD-1-taskA-resource0", phase.getChildren().get(1).getName());
    Assert.assertEquals("erase-podD-1-taskA", phase.getChildren().get(2).getName());
    phase = plan.getChildren().get(1);
    Assert.assertEquals("podD-0", phase.getName());
    Assert.assertEquals(5, phase.getChildren().size());
    Assert.assertEquals("kill-podD-0-taskA", phase.getChildren().get(0).getName());
    Assert.assertEquals("unreserve-podD-0-taskA-resource0", phase.getChildren().get(1).getName());
    Assert.assertEquals("unreserve-podD-0-taskA-resource1", phase.getChildren().get(2).getName());
    Assert.assertEquals("unreserve-podD-0-taskA-resource2", phase.getChildren().get(3).getName());
    Assert.assertEquals("erase-podD-0-taskA", phase.getChildren().get(4).getName());
    phase = plan.getChildren().get(2);
    Assert.assertEquals("podE-0", phase.getName());
    Assert.assertEquals(4, phase.getChildren().size());
    Assert.assertEquals("kill-podE-0-taskA", phase.getChildren().get(0).getName());
    Assert.assertEquals("unreserve-podE-0-taskA-resource0", phase.getChildren().get(1).getName());
    Assert.assertEquals("unreserve-podE-0-taskA-resource1", phase.getChildren().get(2).getName());
    Assert.assertEquals("erase-podE-0-taskA", phase.getChildren().get(3).getName());
    phase = plan.getChildren().get(3);
    Assert.assertEquals("podB-1", phase.getName());
    Assert.assertEquals(7, phase.getChildren().size());
    Assert.assertEquals("kill-podB-1-taskA", phase.getChildren().get(0).getName());
    Assert.assertEquals("kill-podB-1-taskB", phase.getChildren().get(1).getName());
    Assert.assertEquals("unreserve-podB-1-taskA-resource0", phase.getChildren().get(2).getName());
    Assert.assertEquals("unreserve-podB-1-taskB-resource0", phase.getChildren().get(3).getName());
    Assert.assertEquals("unreserve-podB-1-taskB-resource1", phase.getChildren().get(4).getName());
    Assert.assertEquals("erase-podB-1-taskA", phase.getChildren().get(5).getName());
    Assert.assertEquals("erase-podB-1-taskB", phase.getChildren().get(6).getName());
    phase = plan.getChildren().get(4);
    Assert.assertEquals("podA-2", phase.getName());
    Assert.assertEquals(5, phase.getChildren().size());
    Assert.assertEquals("kill-podA-2-taskA", phase.getChildren().get(0).getName());
    Assert.assertEquals("unreserve-podA-2-taskA-resource0", phase.getChildren().get(1).getName());
    Assert.assertEquals("unreserve-podA-2-taskA-resource1", phase.getChildren().get(2).getName());
    Assert.assertEquals("unreserve-podA-2-taskA-resource2", phase.getChildren().get(3).getName());
    Assert.assertEquals("erase-podA-2-taskA", phase.getChildren().get(4).getName());
    phase = plan.getChildren().get(5);
    Assert.assertEquals("podA-1", phase.getName());
    Assert.assertEquals(4, phase.getChildren().size());
    Assert.assertEquals("kill-podA-1-taskA", phase.getChildren().get(0).getName());
    Assert.assertEquals("unreserve-podA-1-taskA-resource0", phase.getChildren().get(1).getName());
    Assert.assertEquals("unreserve-podA-1-taskA-resource1", phase.getChildren().get(2).getName());
    Assert.assertEquals("erase-podA-1-taskA", phase.getChildren().get(3).getName());
}
Also used : Phase(com.mesosphere.sdk.scheduler.plan.Phase) Plan(com.mesosphere.sdk.scheduler.plan.Plan) Test(org.junit.Test)

Example 9 with Plan

use of com.mesosphere.sdk.scheduler.plan.Plan in project dcos-commons by mesosphere.

the class SchedulerBuilderTest method getDeployUpdatePlans.

// Deploy plan has 2 phases, update plan has 1 for distinguishing which was chosen.
private static Collection<Plan> getDeployUpdatePlans() {
    Phase phase = mock(Phase.class);
    Plan deployPlan = new DefaultPlan(Constants.DEPLOY_PLAN_NAME, Arrays.asList(phase, phase));
    Assert.assertEquals(2, deployPlan.getChildren().size());
    Plan updatePlan = new DefaultPlan(Constants.UPDATE_PLAN_NAME, Arrays.asList(phase));
    Assert.assertEquals(1, updatePlan.getChildren().size());
    return Arrays.asList(deployPlan, updatePlan);
}
Also used : Phase(com.mesosphere.sdk.scheduler.plan.Phase) DefaultPlan(com.mesosphere.sdk.scheduler.plan.DefaultPlan) Plan(com.mesosphere.sdk.scheduler.plan.Plan) DefaultPlan(com.mesosphere.sdk.scheduler.plan.DefaultPlan)

Aggregations

Plan (com.mesosphere.sdk.scheduler.plan.Plan)9 Phase (com.mesosphere.sdk.scheduler.plan.Phase)6 Persister (com.mesosphere.sdk.storage.Persister)4 DefaultPlan (com.mesosphere.sdk.scheduler.plan.DefaultPlan)3 MemPersister (com.mesosphere.sdk.storage.MemPersister)3 Test (org.junit.Test)3 RawServiceSpec (com.mesosphere.sdk.specification.yaml.RawServiceSpec)2 SchedulerDriver (org.apache.mesos.SchedulerDriver)2 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)1 ApiServer (com.mesosphere.sdk.framework.ApiServer)1 FrameworkRunner (com.mesosphere.sdk.framework.FrameworkRunner)1 HealthResource (com.mesosphere.sdk.http.endpoints.HealthResource)1 PlansResource (com.mesosphere.sdk.http.endpoints.PlansResource)1 Status (com.mesosphere.sdk.scheduler.plan.Status)1 Step (com.mesosphere.sdk.scheduler.plan.Step)1 SerialStrategy (com.mesosphere.sdk.scheduler.plan.strategy.SerialStrategy)1 DefaultServiceSpec (com.mesosphere.sdk.specification.DefaultServiceSpec)1 ServiceSpec (com.mesosphere.sdk.specification.ServiceSpec)1 RawPlan (com.mesosphere.sdk.specification.yaml.RawPlan)1 FrameworkStore (com.mesosphere.sdk.state.FrameworkStore)1