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