@Test
  public void testMaintenanceModeChanged() 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);

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

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

    hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setMaintenanceState(MaintenanceState.ON);

    // Only NAMENODE is left
    recoveryConfig = recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), DummyHostname1);
    assertEquals(Lists.newArrayList(
      new RecoveryConfigComponent(NAMENODE, HDFS, State.INIT)
    ), recoveryConfig.getEnabledComponents());
  }
Change the maintenance mode of a service component host and verify that
config is stale.

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