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