@Test
  public void testServiceComponentInstalled() throws Exception {
    Cluster cluster = heartbeatTestHelper.getDummyCluster();

    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(cluster);
    Service hdfs = cluster.addService(HDFS, repositoryVersion);

    hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);

    // Get the recovery configuration
    RecoveryConfig recoveryConfig = recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), DummyHostname1);
    assertEquals(Lists.newArrayList(
       new RecoveryConfigComponent(DATANODE, HDFS, State.INIT)
      ), recoveryConfig.getEnabledComponents());

    // Install HDFS::NAMENODE to trigger a component installed event
    hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);

    // Verify the new config
    recoveryConfig = recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), DummyHostname1);
    assertEquals(Lists.newArrayList(
      new RecoveryConfigComponent(DATANODE, HDFS, State.INIT),
      new RecoveryConfigComponent(NAMENODE, HDFS, State.INIT)
      ), recoveryConfig.getEnabledComponents());
  }
Install a component with auto start enabled. Verify that the old config was
invalidated.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java