private Stage getStageWithServerAction(long requestId, long stageId, Map<String, String> payload,
      String requestContext, int timeout, boolean stageSupportsAutoSkip,
      boolean autoSkipFailedTask) {

    Stage stage = stageFactory.createNew(requestId, "/tmp", "cluster1", 1L, requestContext,
      "{}", "{}");

    stage.setStageId(stageId);
    stage.setSkippable(stageSupportsAutoSkip);
    stage.setAutoSkipFailureSupported(stageSupportsAutoSkip);

    stage.addServerActionCommand(MockServerAction.class.getName(), null,
        Role.AMBARI_SERVER_ACTION,
        RoleCommand.EXECUTE, "cluster1",
        new ServiceComponentHostServerActionEvent(null, System.currentTimeMillis()),
        payload,
        null, null, timeout, false, autoSkipFailedTask);

    // make sure the task ID matches the command ID
    stage.getExecutionCommands(null).get(0).getExecutionCommand().setTaskId(
        stage.getOrderedHostRoleCommands().get(0).getTaskId());

    return stage;
  }
Ensures that the task is timed out and that it will be skipped.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/actionmanager/TestActionScheduler.java