@Test
public void testNotFullDowngrade() throws Exception {

  Cluster cluster = clusters.getCluster("c1");
  // add additional service for the test
  Service service = cluster.addService("HIVE");
  service.setDesiredStackVersion(cluster.getDesiredStackVersion());
  ServiceComponent component = service.addServiceComponent("HIVE_SERVER");
  ServiceComponentHost sch = component.addServiceComponentHost("h1");
  sch.setVersion("2.1.1.0");
  // create upgrade request
  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_nonrolling_new_stack");
  requestProps.put(UpgradeResourceProvider.UPGRADE_TYPE, "NON_ROLLING");
  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);
  // check that upgrade was created and groups for the tested services are on place
  List<UpgradeEntity> upgrades = upgradeDao.findUpgrades(cluster.getClusterId());
  assertEquals(1, upgrades.size());
  UpgradeEntity upgrade = upgrades.get(0);
  List<UpgradeGroupEntity> groups = upgrade.getUpgradeGroups();
  boolean isHiveGroupFound = false;
  boolean isZKGroupFound = false;
  // look only for testing groups
  for (UpgradeGroupEntity group: groups) {
    if (group.getName().equalsIgnoreCase("hive")) {
      isHiveGroupFound = true;
    } else if (group.getName().equalsIgnoreCase("zookeeper")){
      isZKGroupFound = true;
    }
  }
  assertTrue(isHiveGroupFound);
  assertTrue(isZKGroupFound);
  isHiveGroupFound = false;
  isZKGroupFound = false;
  sch.setVersion("2.2.0.0");
  // now abort the upgrade so another can be created
  abortUpgrade(upgrade.getRequestId());
  // create downgrade with one upgraded service
  StackId stackId = new StackId("HDP", "2.2.0");
  cluster.setDesiredStackVersion(stackId, true);
  requestProps.put(UpgradeResourceProvider.UPGRADE_CLUSTER_NAME, "c1");
  requestProps.put(UpgradeResourceProvider.UPGRADE_VERSION, "2.1.1.0");
  requestProps.put(UpgradeResourceProvider.UPGRADE_PACK, "upgrade_nonrolling_new_stack");
  requestProps.put(UpgradeResourceProvider.UPGRADE_SKIP_PREREQUISITE_CHECKS, "true");
  requestProps.put(UpgradeResourceProvider.UPGRADE_FROM_VERSION, "2.2.0.0");
  requestProps.put(UpgradeResourceProvider.UPGRADE_DIRECTION, Direction.DOWNGRADE.name());
  Map<String, String> requestInfoProperties = new HashMap<>();
  request = PropertyHelper.getCreateRequest(Collections.singleton(requestProps), requestInfoProperties);
  RequestStatus status = upgradeResourceProvider.createResources(request);
  UpgradeEntity upgradeEntity = upgradeDao.findUpgradeByRequestId(getRequestId(status));
  for (UpgradeGroupEntity group: upgradeEntity.getUpgradeGroups()) {
    if (group.getName().equalsIgnoreCase("hive")) {
      isHiveGroupFound = true;
    } else if (group.getName().equalsIgnoreCase("zookeeper")){
      isZKGroupFound = true;
    }
  }
  // as services not updated, nothing to downgrade
  assertTrue(isHiveGroupFound);
  assertFalse(isZKGroupFound);
}