Search in sources :

Example 21 with TaskLabelWriter

use of com.mesosphere.sdk.offer.taskdata.TaskLabelWriter in project dcos-commons by mesosphere.

the class StateStoreUtilsTest method testPermanentlyFailedTaskNeedsRecovery.

@Test
public void testPermanentlyFailedTaskNeedsRecovery() throws Exception {
    ConfigStore<ServiceSpec> configStore = newConfigStore(persister);
    // Create task info
    Protos.TaskInfo taskInfo = newTaskInfo("name-0-node", configStore);
    // Add a task to the state store
    stateStore.storeTasks(ImmutableList.of(taskInfo));
    // Set status as RUNNING
    Protos.TaskStatus taskStatus = newTaskStatus(taskInfo, Protos.TaskState.TASK_RUNNING);
    stateStore.storeStatus(taskInfo.getName(), taskStatus);
    // Mark task as permanently failed
    taskInfo = taskInfo.toBuilder().setLabels(new TaskLabelWriter(taskInfo).setPermanentlyFailed().toProto()).build();
    stateStore.storeTasks(Arrays.asList(taskInfo));
    // Even though the TaskStatus is RUNNING, it can now be recovered since it has been marked as
    // permanently failed.
    assertThat(StateStoreUtils.fetchTasksNeedingRecovery(stateStore, configStore), is(ImmutableList.of(taskInfo)));
}
Also used : Protos(org.apache.mesos.Protos) TaskLabelWriter(com.mesosphere.sdk.offer.taskdata.TaskLabelWriter) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec) ServiceSpec(com.mesosphere.sdk.specification.ServiceSpec) Test(org.junit.Test)

Aggregations

TaskLabelWriter (com.mesosphere.sdk.offer.taskdata.TaskLabelWriter)21 Protos (org.apache.mesos.Protos)11 Test (org.junit.Test)9 UUID (java.util.UUID)7 StateStore (com.mesosphere.sdk.state.StateStore)6 MemPersister (com.mesosphere.sdk.storage.MemPersister)6 Persister (com.mesosphere.sdk.storage.Persister)6 TaskInfo (org.apache.mesos.Protos.TaskInfo)6 ImmutableList (com.google.common.collect.ImmutableList)5 Capabilities (com.mesosphere.sdk.dcos.Capabilities)5 CommonIdUtils (com.mesosphere.sdk.offer.CommonIdUtils)5 SchedulerConfig (com.mesosphere.sdk.scheduler.SchedulerConfig)5 com.mesosphere.sdk.specification (com.mesosphere.sdk.specification)5 ConfigStore (com.mesosphere.sdk.state.ConfigStore)5 SchedulerConfigTestUtils (com.mesosphere.sdk.testutils.SchedulerConfigTestUtils)5 TestConstants (com.mesosphere.sdk.testutils.TestConstants)5 TestPodFactory (com.mesosphere.sdk.testutils.TestPodFactory)5 Arrays (java.util.Arrays)5 List (java.util.List)5 Collectors (java.util.stream.Collectors)5