@Test
public void testCreateCrossStackUpgrade() throws Exception {

  Cluster cluster = clusters.getCluster("c1");
  StackId oldStack = cluster.getDesiredStackVersion();
  for (Service s : cluster.getServices().values()) {
    assertEquals(oldStack, s.getDesiredStackVersion());
    for (ServiceComponent sc : s.getServiceComponents().values()) {
      assertEquals(oldStack, sc.getDesiredStackVersion());
      for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
        assertEquals(oldStack, sch.getDesiredStackVersion());
      }
    }
  }
  Config config = configFactory.createNew(cluster, "zoo.cfg", "abcdefg", Collections.singletonMap("a", "b"), null);
  cluster.addDesiredConfig("admin", Collections.singleton(config));
  Map<String, Object> requestProps = new HashMap<>();
  requestProps.put(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME, "c1");
  requestProps.put(UpgradeResourceProvider.UPGRADE_VERSION, "2.2.0.0");
  requestProps.put(UpgradeResourceProvider.UPGRADE_PACK, "upgrade_test");
  requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_PREREQUISITE_CHECKS, "true");
  requestProps.put(UpgradeResourceProvider.UPGRADE_DIRECTION, Direction.UPGRADE.name());
  ResourceProvider upgradeResourceProvider = createProvider(amc);
  Request request = PropertyHelper.getCreateRequest(Collections.singleton(requestProps), null);
  upgradeResourceProvider.createResources(request);
  List<UpgradeEntity> upgrades = upgradeDao.findUpgrades(cluster.getClusterId());
  assertEquals(1, upgrades.size());
  UpgradeEntity upgrade = upgrades.get(0);
  assertEquals(3, upgrade.getUpgradeGroups().size());
  UpgradeGroupEntity group = upgrade.getUpgradeGroups().get(2);
  assertEquals(2, group.getItems().size());
  group = upgrade.getUpgradeGroups().get(0);
  assertEquals(2, group.getItems().size());
  assertTrue(cluster.getDesiredConfigs().containsKey("zoo.cfg"));
  StackId newStack = cluster.getDesiredStackVersion();
  assertFalse(oldStack.equals(newStack));
  for (Service s : cluster.getServices().values()) {
    assertEquals(newStack, s.getDesiredStackVersion());
    for (ServiceComponent sc : s.getServiceComponents().values()) {
      assertEquals(newStack, sc.getDesiredStackVersion());
      for (ServiceComponentHost sch : sc.getServiceComponentHosts().values()) {
        assertEquals(newStack, sch.getDesiredStackVersion());
      }
    }
  }
}