@Test
public void testHAClusterInfoURL() throws IOException, InterruptedException {

  TopCLI topcli = new TopCLI();
  // http
  String rm1Address = "host2:8088";
  String rm2Address = "host3:8088";
  Configuration conf = topcli.getConf();
  conf.set(YarnConfiguration.RM_WEBAPP_ADDRESS + "." + RM1_NODE_ID,
      rm1Address);
  topcli.getConf().set(
      YarnConfiguration.RM_WEBAPP_ADDRESS + "." + RM2_NODE_ID, rm2Address);
  topcli.getConf().setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
  topcli.getConf().set(YarnConfiguration.RM_HA_IDS,
      RM1_NODE_ID + "," + RM2_NODE_ID);
  URL clusterUrl = topcli.getHAClusterUrl(conf, RM1_NODE_ID);
  Assert.assertEquals("http", clusterUrl.getProtocol());
  Assert.assertEquals(rm1Address, clusterUrl.getAuthority());
  clusterUrl = topcli.getHAClusterUrl(conf, RM2_NODE_ID);
  Assert.assertEquals("http", clusterUrl.getProtocol());
  Assert.assertEquals(rm2Address, clusterUrl.getAuthority());
  // https
  rm1Address = "host2:9088";
  rm2Address = "host3:9088";
  conf = topcli.getConf();
  conf.set(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS + "." + RM1_NODE_ID,
      rm1Address);
  conf.set(YarnConfiguration.RM_WEBAPP_HTTPS_ADDRESS + "." + RM2_NODE_ID,
      rm2Address);
  conf.setBoolean(YarnConfiguration.RM_HA_ENABLED, true);
  conf.set(YarnConfiguration.RM_HA_IDS, RM1_NODE_ID + "," + RM2_NODE_ID);
  conf.set(YarnConfiguration.YARN_HTTP_POLICY_KEY, "HTTPS_ONLY");
  clusterUrl = topcli.getHAClusterUrl(conf, RM1_NODE_ID);
  Assert.assertEquals("https", clusterUrl.getProtocol());
  Assert.assertEquals(rm1Address, clusterUrl.getAuthority());
}