@Test
public void testDoUpdateForClusterWithNameNodeHAEnabledAndActiveNodeSet() throws Exception {

  final String expectedNameService = "mynameservice";
  final String expectedHostName = "server-three";
  final String expectedHostNameTwo = "server-four";
  final String expectedPortNum = "808080";
  final String expectedNodeOne = "nn1";
  final String expectedNodeTwo = "nn2";
  final String expectedHostGroupName = "host_group_1";
  Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>();
  Map<String, String> hdfsSiteProperties = new HashMap<String, String>();
  Map<String, String> hadoopEnvProperties = new HashMap<String, String>();
  properties.put("hdfs-site", hdfsSiteProperties);
  properties.put("hadoop-env", hadoopEnvProperties);
  // setup hdfs HA config for test
  hdfsSiteProperties.put("dfs.nameservices", expectedNameService);
  hdfsSiteProperties.put("dfs.ha.namenodes.mynameservice", expectedNodeOne + ", " + expectedNodeTwo);
  // setup properties that include exported host group information
  hdfsSiteProperties.put("dfs.namenode.https-address." + expectedNameService + "." + expectedNodeOne, createExportedAddress(expectedPortNum, expectedHostGroupName));
  hdfsSiteProperties.put("dfs.namenode.https-address." + expectedNameService + "." + expectedNodeTwo, createExportedAddress(expectedPortNum, expectedHostGroupName));
  hdfsSiteProperties.put("dfs.namenode.http-address." + expectedNameService + "." + expectedNodeOne, createExportedAddress(expectedPortNum, expectedHostGroupName));
  hdfsSiteProperties.put("dfs.namenode.http-address." + expectedNameService + "." + expectedNodeTwo, createExportedAddress(expectedPortNum, expectedHostGroupName));
  hdfsSiteProperties.put("dfs.namenode.rpc-address." + expectedNameService + "." + expectedNodeOne, createExportedAddress(expectedPortNum, expectedHostGroupName));
  hdfsSiteProperties.put("dfs.namenode.rpc-address." + expectedNameService + "." + expectedNodeTwo, createExportedAddress(expectedPortNum, expectedHostGroupName));
  // set hadoop-env properties to explicitly configure the initial
  // active and stanbdy namenodes
  hadoopEnvProperties.put("dfs_ha_initial_namenode_active", expectedHostName);
  hadoopEnvProperties.put("dfs_ha_initial_namenode_standby", expectedHostNameTwo);
  Configuration clusterConfig = new Configuration(properties, Collections.<String, Map<String, Map<String, String>>>emptyMap());
  Collection<String> hgComponents = new HashSet<String>();
  hgComponents.add("NAMENODE");
  Collection<String> hosts = new ArrayList<String>();
  hosts.add(expectedHostName);
  hosts.add(expectedHostNameTwo);
  TestHostGroup group = new TestHostGroup(expectedHostGroupName, hgComponents, hosts);
  Collection<TestHostGroup> hostGroups = new ArrayList<TestHostGroup>();
  hostGroups.add(group);
  ClusterTopology topology = createClusterTopology(bp, clusterConfig, hostGroups);
  BlueprintConfigurationProcessor updater = new BlueprintConfigurationProcessor(topology);
  updater.doUpdateForClusterCreate();
  // verify that the expected hostname was substituted for the host group name in the config.
  // all of these dynamic props will be set to the same host in this case where there is a single host group
  // with multiple hosts.  This may not be correct and a Jira is being filed to track this issue.
  String expectedPropertyValue = hdfsSiteProperties.get("dfs.namenode.https-address." + expectedNameService + "." + expectedNodeOne);
  if (! expectedPropertyValue.equals(expectedHostName + ":" + expectedPortNum) &&
      ! expectedPropertyValue.equals(expectedHostNameTwo + ":" + expectedPortNum)) {
    fail("HTTPS address HA property not properly exported");
  }
  assertEquals("HTTPS address HA property not properly exported", expectedPropertyValue,
      hdfsSiteProperties.get("dfs.namenode.https-address." + expectedNameService + "." + expectedNodeTwo));
  assertEquals("HTTPS address HA property not properly exported", expectedPropertyValue,
      hdfsSiteProperties.get("dfs.namenode.http-address." + expectedNameService + "." + expectedNodeOne));
  assertEquals("HTTPS address HA property not properly exported", expectedPropertyValue,
      hdfsSiteProperties.get("dfs.namenode.http-address." + expectedNameService + "." + expectedNodeTwo));
  assertEquals("HTTPS address HA property not properly exported", expectedPropertyValue,
    hdfsSiteProperties.get("dfs.namenode.rpc-address." + expectedNameService + "." + expectedNodeOne));
  assertEquals("HTTPS address HA property not properly exported", expectedPropertyValue,
    hdfsSiteProperties.get("dfs.namenode.rpc-address." + expectedNameService + "." + expectedNodeTwo));
  // verify that the Blueprint config processor has not overridden
  // the user's configuration to determine the active and
  // standby nodes in this NameNode HA cluster
  assertEquals("Active Namenode hostname was not set correctly",
    expectedHostName, hadoopEnvProperties.get("dfs_ha_initial_namenode_active"));
  assertEquals("Standby Namenode hostname was not set correctly",
    expectedHostNameTwo, hadoopEnvProperties.get("dfs_ha_initial_namenode_standby"));
}