@Test
  public void testReInstallForInstallFailedClient() throws Exception, AuthorizationException {
    String cluster1 = getUniqueName();
    createCluster(cluster1);
    clusters.getCluster(cluster1)
      .setDesiredStackVersion(new StackId("HDP-0.1"));
    String serviceName = "HDFS";
    createService(cluster1, serviceName, null);
    String componentName1 = "NAMENODE";
    String componentName2 = "DATANODE";
    String componentName3 = "HDFS_CLIENT";

    createServiceComponent(cluster1, serviceName, componentName1,
      State.INIT);
    createServiceComponent(cluster1, serviceName, componentName2,
      State.INIT);
    createServiceComponent(cluster1, serviceName, componentName3,
      State.INIT);

    String host1 = getUniqueName();
    String host2 = getUniqueName();
    String host3 = getUniqueName();

    addHostToCluster(host1, cluster1);
    addHostToCluster(host2, cluster1);
    addHostToCluster(host3, cluster1);

    createServiceComponentHost(cluster1, serviceName, componentName1,
      host1, null);
    createServiceComponentHost(cluster1, serviceName, componentName2,
      host1, null);
    createServiceComponentHost(cluster1, serviceName, componentName3,
      host2, null);
    createServiceComponentHost(cluster1, serviceName, componentName3,
      host3, null);

    // Install
    installService(cluster1, serviceName, false, false);

    // Mark client as install failed.
    Cluster cluster = clusters.getCluster(cluster1);
    Service s = cluster.getService(serviceName);
    ServiceComponent sc3 = s.getServiceComponent(componentName3);
    for(ServiceComponentHost sch : sc3.getServiceComponentHosts().values()) {
      if (sch.getHostName().equals(host3)) {
        sch.setState(State.INSTALL_FAILED);
      }
    }

    // Start
    long requestId = startService(cluster1, serviceName, false, true);
    List<Stage> stages = actionDB.getAllStages(requestId);
    HostRoleCommand clientReinstallCmd = null;
    for (Stage stage : stages) {
      for (HostRoleCommand hrc : stage.getOrderedHostRoleCommands()) {
        if (hrc.getHostName().equals(host3) && hrc.getRole().toString()
          .equals("HDFS_CLIENT")) {
          clientReinstallCmd = hrc;
          break;
        }
      }
    }
    Assert.assertNotNull(clientReinstallCmd);
  }
Create a cluster with a service, and verify that the request tasks have the correct output log and error log paths.
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java