use of com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement in project dcos-commons by mesosphere.
the class ExecutorEvaluationStageTest method testAcceptOfferWithExpectedExecutorId.
@Test
public void testAcceptOfferWithExpectedExecutorId() throws Exception {
PodInstanceRequirement podInstanceRequirement = PodInstanceRequirementTestUtils.getCpuRequirement(1.0);
// Record launch and RUNNING status
String resourceId = getFirstResourceId(recordLaunchWithCompleteOfferedResources(podInstanceRequirement, ResourceTestUtils.getUnreservedCpus(1.1), ResourceTestUtils.getUnreservedMem(256), ResourceTestUtils.getUnreservedDisk(512)));
String taskName = stateStore.fetchTaskNames().stream().findFirst().get();
Protos.TaskInfo taskInfo = stateStore.fetchTask(taskName).get();
stateStore.storeStatus(taskInfo.getName(), Protos.TaskStatus.newBuilder().setState(Protos.TaskState.TASK_RUNNING).setTaskId(taskInfo.getTaskId()).build());
Protos.Resource expectedTaskCpu = ResourceTestUtils.getReservedCpus(1.0, resourceId);
Protos.Offer offer = OfferTestUtils.getCompleteOffer(Arrays.asList(expectedTaskCpu)).toBuilder().addExecutorIds(taskInfo.getExecutor().getExecutorId()).build();
MesosResourcePool resources = new MesosResourcePool(offer, Optional.of(Constants.ANY_ROLE));
ExecutorEvaluationStage executorEvaluationStage = new ExecutorEvaluationStage(TestConstants.SERVICE_NAME, Optional.of(taskInfo.getExecutor().getExecutorId()));
PodInfoBuilder podInfoBuilder = new PodInfoBuilder(podInstanceRequirement, TestConstants.SERVICE_NAME, UUID.randomUUID(), ArtifactResource.getUrlFactory(TestConstants.SERVICE_NAME), SchedulerConfigTestUtils.getTestSchedulerConfig(), stateStore.fetchTasks(), frameworkStore.fetchFrameworkId().get(), true, Collections.emptyMap());
EvaluationOutcome outcome = executorEvaluationStage.evaluate(resources, podInfoBuilder);
Assert.assertTrue(outcome.isPassing());
Protos.ExecutorID launchExecutorId = podInfoBuilder.getExecutorBuilder().get().getExecutorId();
Assert.assertEquals(taskInfo.getExecutor().getExecutorId(), launchExecutorId);
}
use of com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement in project dcos-commons by mesosphere.
the class TaskUtilsTest method testRelaunchFailedEssentialTaskInMixedPod.
@Test
public void testRelaunchFailedEssentialTaskInMixedPod() throws ConfigStoreException {
// layout: 3 'server' pod instances, each with 2 essential + 2 nonessential tasks
// failed: server-0-essential0, server-0-essential1, server-1-essential1
List<PodInstanceRequirement> reqs = TaskUtils.getPodRequirements(TWO_ESSENTIAL_TWO_NONESSENTIAL, filterTasksByName(TWO_ESSENTIAL_TWO_NONESSENTIAL_TASKS, "server-0-essential0", "server-0-essential1", "server-1-essential1"), TWO_ESSENTIAL_TWO_NONESSENTIAL_TASKS);
Assert.assertEquals(2, reqs.size());
PodInstanceRequirement req = reqs.get(0);
Assert.assertEquals("server-0:[essential0, essential1, nonessential0, nonessential1]", req.getName());
Assert.assertEquals(Arrays.asList("essential0", "essential1", "nonessential0", "nonessential1"), req.getTasksToLaunch());
req = reqs.get(1);
Assert.assertEquals("server-1:[essential0, essential1, nonessential0, nonessential1]", req.getName());
Assert.assertEquals(Arrays.asList("essential0", "essential1", "nonessential0", "nonessential1"), req.getTasksToLaunch());
}
use of com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement in project dcos-commons by mesosphere.
the class TaskUtilsTest method testRelaunchFailedNonessentialTasksInNonessentialPod.
@Test
public void testRelaunchFailedNonessentialTasksInNonessentialPod() throws ConfigStoreException {
// layout: 3 'server' pod instances, each with 2 nonessential tasks (only)
// failed: server-0-nonessential0, server-0-nonessential1, server-1-nonessential1
List<PodInstanceRequirement> reqs = TaskUtils.getPodRequirements(TWO_NONESSENTIAL, filterTasksByName(TWO_NONESSENTIAL_TASKS, "server-0-nonessential0", "server-0-nonessential1", "server-1-nonessential1"), TWO_NONESSENTIAL_TASKS);
Assert.assertEquals(reqs.toString(), 2, reqs.size());
PodInstanceRequirement req = reqs.get(0);
Assert.assertEquals("server-0:[nonessential0, nonessential1]", req.getName());
Assert.assertEquals(Arrays.asList("nonessential0", "nonessential1"), req.getTasksToLaunch());
req = reqs.get(1);
Assert.assertEquals("server-1:[nonessential1]", req.getName());
Assert.assertEquals(Arrays.asList("nonessential1"), req.getTasksToLaunch());
}
use of com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement in project dcos-commons by mesosphere.
the class CassandraRecoveryPlanOverriderTest method replaceNonSeed.
@Test
public void replaceNonSeed() throws Exception {
int nonSeedIndex = 2;
String taskName = "node-" + nonSeedIndex + "-server";
StateStoreUtils.storeTaskStatusAsProperty(stateStore, taskName, getFailedTaskStatus(taskName));
PodInstanceRequirement podInstanceRequirement = getReplacePodInstanceRequirement(nonSeedIndex);
Optional<Phase> phase = planOverrider.override(podInstanceRequirement);
Assert.assertTrue(phase.isPresent());
Assert.assertEquals(1, phase.get().getChildren().size());
Assert.assertEquals(RecoveryType.PERMANENT, phase.get().getChildren().get(0).getPodInstanceRequirement().get().getRecoveryType());
}
use of com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement in project dcos-commons by mesosphere.
the class CassandraRecoveryPlanOverriderTest method ovverrideNoOp.
@Test
public void ovverrideNoOp() throws Exception {
PodInstanceRequirement podInstanceRequirement = getRestartPodInstanceRequirement(0);
Optional<Phase> phase = planOverrider.override(podInstanceRequirement);
Assert.assertFalse(phase.isPresent());
}
Aggregations