@Test
  public void testUpgradeOrchestrationWithRackError() throws Exception {
    Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("foo", "bar");
    assertTrue(upgrades.isEmpty());
    upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1");
    ServiceInfo serviceInfo = ambariMetaInfo.getService("HDP", "2.2.0", "ZOOKEEPER");
    serviceInfo.setDisplayName("Zk");
    ComponentInfo componentInfo = serviceInfo.getComponentByName("ZOOKEEPER_SERVER");
    componentInfo.setDisplayName("ZooKeeper1 Server2");
    assertTrue(upgrades.containsKey("upgrade_test"));
    UpgradePack upgrade = upgrades.get("upgrade_test");
    assertNotNull(upgrade);
    File file = tmpFolder.newFile("rack_config.yaml");
    FileUtils.writeStringToFile(file, "racks:\n" +
            "  racka-1:\n" +
            "    hostGroups:\n" +
            "    - hosts:\n" +
            "      - h4\n" +
            "    - hosts:\n" +
            "      - h5\n", Charset.defaultCharset(), false);
    Cluster cluster = makeCluster(true, new HashSet<>(), file.getAbsolutePath());
    UpgradeContext context = getMockUpgradeContext(cluster, Direction.UPGRADE, UpgradeType.ROLLING);
    try {
      m_upgradeHelper.createSequence(upgrade, context);
    } catch (RuntimeException e) {
      assertTrue(e.getCause().getMessage().contains("Rack mapping is not present for host name"));
    }
  }
Tests that the {@link SecurityCondition} element correctly restricts the groups in
an upgrade.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/stack/upgrade/orchestrate/UpgradeHelperTest.java