@Test
public void testYarnHighAvailabilityConfigClusterUpdateSpecifyingHostNamesDirectly() throws Exception {

  final String expectedHostName = "c6401.apache.ambari.org";
  final String expectedPortNum = "808080";
  final String expectedHostGroupName = "host_group_1";
  final String expectedHostGroupNameTwo = "host_group_2";
  Map<String, Map<String, String>> configProperties = new HashMap<String, Map<String, String>>();
  Map<String, String> yarnSiteProperties = new HashMap<String, String>();
  configProperties.put("yarn-site", yarnSiteProperties);
  // setup properties that include host information
  yarnSiteProperties.put("yarn.log.server.url", "http://" + expectedHostName +":19888/jobhistory/logs");
  yarnSiteProperties.put("yarn.resourcemanager.hostname", expectedHostName);
  yarnSiteProperties.put("yarn.resourcemanager.resource-tracker.address", expectedHostName + ":" + expectedPortNum);
  yarnSiteProperties.put("yarn.resourcemanager.webapp.address", expectedHostName + ":" + expectedPortNum);
  yarnSiteProperties.put("yarn.resourcemanager.scheduler.address", expectedHostName + ":" + expectedPortNum);
  yarnSiteProperties.put("yarn.resourcemanager.address", expectedHostName + ":" + expectedPortNum);
  yarnSiteProperties.put("yarn.resourcemanager.admin.address", expectedHostName + ":" + expectedPortNum);
  yarnSiteProperties.put("yarn.timeline-service.address", expectedHostName + ":" + expectedPortNum);
  yarnSiteProperties.put("yarn.timeline-service.webapp.address", expectedHostName + ":" + expectedPortNum);
  yarnSiteProperties.put("yarn.timeline-service.webapp.https.address", expectedHostName + ":" + expectedPortNum);
  yarnSiteProperties.put("yarn.resourcemanager.ha.enabled", "true");
  yarnSiteProperties.put("yarn.resourcemanager.ha.rm-ids", "rm1, rm2");
  Configuration clusterConfig = new Configuration(configProperties, Collections.<String, Map<String, Map<String, String>>>emptyMap());
  Collection<String> hgComponents = new HashSet<String>();
  hgComponents.add("RESOURCEMANAGER");
  hgComponents.add("APP_TIMELINE_SERVER");
  hgComponents.add("HISTORYSERVER");
  TestHostGroup group1 = new TestHostGroup(expectedHostGroupName, hgComponents, Collections.singleton(expectedHostName));
  Collection<String> hgComponents2 = new HashSet<String>();
  hgComponents2.add("RESOURCEMANAGER");
  TestHostGroup group2 = new TestHostGroup(expectedHostGroupNameTwo, hgComponents2, Collections.singleton("host2"));
  Collection<TestHostGroup> hostGroups = new HashSet<TestHostGroup>();
  hostGroups.add(group1);
  hostGroups.add(group2);
  expect(stack.getCardinality("RESOURCEMANAGER")).andReturn(new Cardinality("1-2")).anyTimes();
  ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups);
  BlueprintConfigurationProcessor updater = new BlueprintConfigurationProcessor(topology);
  updater.doUpdateForClusterCreate();
  // verify that the properties with hostname information was correctly preserved
  assertEquals("Yarn Log Server URL was incorrectly updated",
    "http://" + expectedHostName + ":19888/jobhistory/logs", yarnSiteProperties.get("yarn.log.server.url"));
  assertEquals("Yarn ResourceManager hostname was incorrectly exported",
    expectedHostName, yarnSiteProperties.get("yarn.resourcemanager.hostname"));
  assertEquals("Yarn ResourceManager tracker address was incorrectly updated",
      createHostAddress(expectedHostName, expectedPortNum), yarnSiteProperties.get("yarn.resourcemanager.resource-tracker.address"));
  assertEquals("Yarn ResourceManager webapp address was incorrectly updated",
    createHostAddress(expectedHostName, expectedPortNum), yarnSiteProperties.get("yarn.resourcemanager.webapp.address"));
  assertEquals("Yarn ResourceManager scheduler address was incorrectly updated",
      createHostAddress(expectedHostName, expectedPortNum), yarnSiteProperties.get("yarn.resourcemanager.scheduler.address"));
  assertEquals("Yarn ResourceManager address was incorrectly updated",
      createHostAddress(expectedHostName, expectedPortNum), yarnSiteProperties.get("yarn.resourcemanager.address"));
  assertEquals("Yarn ResourceManager admin address was incorrectly updated",
      createHostAddress(expectedHostName, expectedPortNum), yarnSiteProperties.get("yarn.resourcemanager.admin.address"));
  assertEquals("Yarn ResourceManager timeline-service address was incorrectly updated",
      createHostAddress(expectedHostName, expectedPortNum), yarnSiteProperties.get("yarn.timeline-service.address"));
  assertEquals("Yarn ResourceManager timeline webapp address was incorrectly updated",
      createHostAddress(expectedHostName, expectedPortNum), yarnSiteProperties.get("yarn.timeline-service.webapp.address"));
  assertEquals("Yarn ResourceManager timeline webapp HTTPS address was incorrectly updated",
      createHostAddress(expectedHostName, expectedPortNum), yarnSiteProperties.get("yarn.timeline-service.webapp.https.address"));
}