@Test
public void testPartialUpgradeOrchestration() throws Exception {

  Map<String, UpgradePack> upgrades = ambariMetaInfo.getUpgradePacks("foo", "bar");
  assertTrue(upgrades.isEmpty());
  upgrades = ambariMetaInfo.getUpgradePacks("HDP", "2.1.1");
  ServiceInfo si = ambariMetaInfo.getService("HDP", "2.1.1", "ZOOKEEPER");
  si.setDisplayName("Zk");
  ComponentInfo ci = si.getComponentByName("ZOOKEEPER_SERVER");
  ci.setDisplayName("ZooKeeper1 Server2");
  assertTrue(upgrades.containsKey("upgrade_test_partial"));
  UpgradePack upgrade = upgrades.get("upgrade_test_partial");
  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);
  context.setSupportedServices(Collections.singleton("ZOOKEEPER"));
  context.setScope(UpgradeScope.PARTIAL);
  List<Grouping> groupings = upgrade.getGroups(Direction.UPGRADE);
  assertEquals(8, groupings.size());
  assertEquals(UpgradeScope.COMPLETE, groupings.get(6).scope);
  List<UpgradeGroupHolder> groups = m_upgradeHelper.createSequence(upgrade, context);
  assertEquals(3, groups.size());
  assertEquals("PRE_CLUSTER", groups.get(0).name);
  assertEquals("ZOOKEEPER", groups.get(1).name);
  assertEquals("POST_CLUSTER", groups.get(2).name);
  UpgradeGroupHolder group = groups.get(1);
  // check that the display name is being used
  assertTrue(group.items.get(1).getText().contains("ZooKeeper1 Server2"));
  assertEquals("Service Check Zk", group.items.get(6).getText());
  UpgradeGroupHolder postGroup = groups.get(2);
  assertEquals("POST_CLUSTER", postGroup.name);
  assertEquals("Finalize Upgrade", postGroup.title);
  assertEquals(2, postGroup.items.size());
  assertEquals("Confirm Finalize", postGroup.items.get(0).getText());
  assertEquals("Save Cluster State", postGroup.items.get(1).getText());
  assertEquals(StageWrapper.Type.SERVER_SIDE_ACTION, postGroup.items.get(1).getType());
  assertEquals(3, groups.get(0).items.size());
  assertEquals(7, groups.get(1).items.size());
  assertEquals(2, groups.get(2).items.size());
  // Do stacks cleanup
  stackManagerMock.invalidateCurrentPaths();
  ambariMetaInfo.init();
}