@Test(timeout = 30000)
public void testInitDecommMetricNoRegistration() throws Exception {

  Configuration conf = new Configuration();
  rm = new MockRM(conf);
  rm.start();
  MockNM nm1 = rm.registerNode("host1:1234", 5120);
  MockNM nm2 = rm.registerNode("host2:5678", 10240);
  nm1.nodeHeartbeat(true);
  nm2.nodeHeartbeat(true);
  //host3 will not register or heartbeat
  writeToHostsFile(excludeHostFile, "host3", "host2");
  conf.set(YarnConfiguration.RM_NODES_EXCLUDE_FILE_PATH,
      excludeHostFile.getAbsolutePath());
  writeToHostsFile(hostFile, "host1", "host2");
  conf.set(YarnConfiguration.RM_NODES_INCLUDE_FILE_PATH,
      hostFile.getAbsolutePath());
  rm.getNodesListManager().refreshNodes(conf);
  rm.drainEvents();
  Assert.assertEquals("The decommissioned nodes metric should be 1 ",
      1, ClusterMetrics.getMetrics().getNumDecommisionedNMs());
  rm.stop();
  MockRM rm1 = new MockRM(conf);
  rm1.start();
  rm1.getNodesListManager().refreshNodes(conf);
  rm1.drainEvents();
  Assert.assertEquals("The decommissioned nodes metric should be 2 ",
      2, ClusterMetrics.getMetrics().getNumDecommisionedNMs());
  rm1.stop();
}