@Before
  public void setup() throws Exception {
    injector = Guice.createInjector(Modules.override(
        new InMemoryDefaultTestModule()).with(new MockModule()));

    injector.getInstance(GuiceJpaInitializer.class);
    injector.injectMembers(this);

    OrmTestHelper helper = injector.getInstance(OrmTestHelper.class);
    helper.createStack(stackId);

    clusters.addCluster("c1", stackId);
    cluster = clusters.getCluster("c1");
    m_repositoryVersion = helper.getOrCreateRepositoryVersion(stackId, REPO_VERSION);

    Config config1 = configFactory.createNew(cluster, "test-type1", null, new HashMap<>(), new HashMap<>());

    Config config2 = configFactory.createNew(cluster, "test-type2", null, new HashMap<>(), new HashMap<>());

    cluster.addDesiredConfig("test user", new HashSet<>(Arrays.asList(config1, config2)));

    String hostName = "c6401";
    clusters.addHost(hostName);
    setOsFamily(clusters.getHost(hostName), "redhat", "6.4");
    clusters.mapHostToCluster(hostName, "c1");

    Service service = installService("HDFS");
    addServiceComponent(service, "NAMENODE");
  }
Creates 1 host and add it to the cluster.

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