Search in sources :

Example 11 with PodInstanceRequirement

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);
}
Also used : MesosResourcePool(com.mesosphere.sdk.offer.MesosResourcePool) Protos(org.apache.mesos.Protos) PodInstanceRequirement(com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement) Test(org.junit.Test)

Example 12 with PodInstanceRequirement

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());
}
Also used : PodInstanceRequirement(com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement) Test(org.junit.Test)

Example 13 with PodInstanceRequirement

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());
}
Also used : PodInstanceRequirement(com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement) Test(org.junit.Test)

Example 14 with PodInstanceRequirement

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());
}
Also used : Phase(com.mesosphere.sdk.scheduler.plan.Phase) PodInstanceRequirement(com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement) Test(org.junit.Test)

Example 15 with PodInstanceRequirement

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());
}
Also used : Phase(com.mesosphere.sdk.scheduler.plan.Phase) PodInstanceRequirement(com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement) Test(org.junit.Test)

Aggregations

PodInstanceRequirement (com.mesosphere.sdk.scheduler.plan.PodInstanceRequirement)51 Test (org.junit.Test)47 Protos (org.apache.mesos.Protos)38 OfferRecommendation (com.mesosphere.sdk.offer.OfferRecommendation)21 Resource (org.apache.mesos.Protos.Resource)17 DefaultPodInstance (com.mesosphere.sdk.scheduler.plan.DefaultPodInstance)16 Operation (org.apache.mesos.Protos.Offer.Operation)15 Collectors (java.util.stream.Collectors)10 com.mesosphere.sdk.specification (com.mesosphere.sdk.specification)8 java.util (java.util)8 Assert (org.junit.Assert)8 ArtifactResource (com.mesosphere.sdk.http.endpoints.ArtifactResource)7 MesosResourcePool (com.mesosphere.sdk.offer.MesosResourcePool)7 SchedulerConfig (com.mesosphere.sdk.scheduler.SchedulerConfig)7 com.mesosphere.sdk.offer (com.mesosphere.sdk.offer)6 PlacementRule (com.mesosphere.sdk.offer.evaluate.placement.PlacementRule)6 TaskLabelWriter (com.mesosphere.sdk.offer.taskdata.TaskLabelWriter)6 DefaultPodSpec (com.mesosphere.sdk.specification.DefaultPodSpec)6 PodInstance (com.mesosphere.sdk.specification.PodInstance)6 PodSpec (com.mesosphere.sdk.specification.PodSpec)6