@Test
  public void testTransitionNonReportableHost() throws Exception {
    StackId stackId = new StackId("HDP-2.0.5");

    String clusterName = "c1";
    clusters.addCluster(clusterName, stackId);
    Cluster c1 = clusters.getCluster(clusterName);
    Assert.assertEquals(clusterName, c1.getClusterName());

    clusters.addHost("h-1");
    clusters.addHost("h-2");
    clusters.addHost("h-3");

    for (String hostName : new String[] { "h-1", "h-2", "h-3" }) {
      Host h = clusters.getHost(hostName);
      h.setIPv4("ipv4");
      h.setIPv6("ipv6");

      Map<String, String> hostAttributes = new HashMap<>();
      hostAttributes.put("os_family", "redhat");
      hostAttributes.put("os_release_version", "5.9");
      h.setHostAttributes(hostAttributes);

    }

    String v1 = "2.0.5-1";
    String v2 = "2.0.5-2";
    c1.setDesiredStackVersion(stackId);
    helper.getOrCreateRepositoryVersion(stackId, v1);
    helper.getOrCreateRepositoryVersion(stackId, v2);

    c1.setCurrentStackVersion(stackId);

    clusters.mapHostToCluster("h-1", clusterName);
    clusters.mapHostToCluster("h-2", clusterName);
    clusters.mapHostToCluster("h-3", clusterName);

    RepositoryVersionEntity repositoryVersion = helper.getOrCreateRepositoryVersion(c1);

    Service service = c1.addService("ZOOKEEPER", repositoryVersion);
    ServiceComponent sc = service.addServiceComponent("ZOOKEEPER_SERVER");
    sc.addServiceComponentHost("h-1");
    sc.addServiceComponentHost("h-2");

    service = c1.addService("SQOOP", repositoryVersion);
    sc = service.addServiceComponent("SQOOP");
    sc.addServiceComponentHost("h-3");

    HostEntity hostEntity = hostDAO.findByName("h-3");
    assertNotNull(hostEntity);

    List<HostVersionEntity> entities = hostVersionDAO.findByClusterAndHost(clusterName, "h-3");
    assertTrue("Expected no host versions", null == entities || 0 == entities.size());

    List<ServiceComponentHost> componentsOnHost3 = c1.getServiceComponentHosts("h-3");
    componentsOnHost3.iterator().next().recalculateHostVersionState();

    entities = hostVersionDAO.findByClusterAndHost(clusterName, "h-3");
    assertEquals(1, entities.size());
  }
Comprehensive test for host versions. It creates a cluster with 3 hosts and
3 services, one of which does not advertise a version. It then verifies
that all 3 hosts have a version of CURRENT, and so does the cluster. It
then adds one more host with a component, so its HostVersion will
initialize in CURRENT. Next, it distributes a repo so that it is INSTALLED
on the 4 hosts. It then adds one more host, whose HostVersion will be
OUT_OF_SYNC for the new repo. After redistributing bits again, it simulates
an RU. Finally, some of the hosts will end up with a HostVersion in
UPGRADED, and others still in INSTALLED.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/state/cluster/ClusterTest.java