@Test
public void testUpgradeConditions() throws Exception {

  Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.2.0");
  assertTrue(upgrades.containsKey("upgrade_test_conditions"));
  UpgradePack upgrade = upgrades.get("upgrade_test_conditions");
  assertNotNull(upgrade);
  Cluster cluster = makeCluster();
  UpgradeContext context = m_upgradeContextFactory.create(cluster, UpgradeType.ROLLING,
      Direction.UPGRADE, UPGRADE_VERSION, new HashMap<String, Object>());
  context.setResolver(m_masterHostResolver);
  // initially, no conditions should be met
  List<UpgradeGroupHolder> groups = m_upgradeHelper.createSequence(upgrade, context);
  assertEquals(0, groups.size());
  // set the configuration property and try again
  Map<String, String> fooConfigs = new HashMap<>();
  fooConfigs.put("foo-property", "foo-value");
  ConfigurationRequest configurationRequest = new ConfigurationRequest();
  configurationRequest.setClusterName(cluster.getClusterName());
  configurationRequest.setType("foo-site");
  configurationRequest.setVersionTag("version1");
  configurationRequest.setProperties(fooConfigs);
  final ClusterRequest clusterRequest = new ClusterRequest(cluster.getClusterId(),
      cluster.getClusterName(), cluster.getDesiredStackVersion().getStackVersion(), null);
  clusterRequest.setDesiredConfig(Collections.singletonList(configurationRequest));
  m_managementController.updateClusters(Sets.newHashSet(clusterRequest), null);
  // the config condition should now be set
  groups = m_upgradeHelper.createSequence(upgrade, context);
  assertEquals(1, groups.size());
  assertEquals("ZOOKEEPER_CONFIG_CONDITION_TEST", groups.get(0).name);
  // now change the cluster security so the other conditions come back too
  cluster.setSecurityType(SecurityType.KERBEROS);
  groups = m_upgradeHelper.createSequence(upgrade, context);
  assertEquals(3, groups.size());
}