Search in sources :

Example 61 with ServiceSpec

use of com.mesosphere.sdk.specification.ServiceSpec 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

ServiceSpec (com.mesosphere.sdk.specification.ServiceSpec)61 DefaultServiceSpec (com.mesosphere.sdk.specification.DefaultServiceSpec)55 Test (org.junit.Test)51 MemPersister (com.mesosphere.sdk.storage.MemPersister)7 PodSpec (com.mesosphere.sdk.specification.PodSpec)6 Collectors (java.util.stream.Collectors)5 ConfigStoreException (com.mesosphere.sdk.state.ConfigStoreException)3 java.util (java.util)3 Protos (org.apache.mesos.Protos)3 Capabilities (com.mesosphere.sdk.dcos.Capabilities)2 TaskException (com.mesosphere.sdk.offer.TaskException)2 PlacementRule (com.mesosphere.sdk.offer.evaluate.placement.PlacementRule)2 TaskLabelWriter (com.mesosphere.sdk.offer.taskdata.TaskLabelWriter)2 DefaultPodSpec (com.mesosphere.sdk.specification.DefaultPodSpec)2 Persister (com.mesosphere.sdk.storage.Persister)2 PersisterException (com.mesosphere.sdk.storage.PersisterException)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 Optional (java.util.Optional)2