@Test
  public void testScheduleSmokeTest() throws Exception {

    final String HOST1 = getUniqueName();
    final String OS_TYPE = "centos5";
    final String STACK_ID = "HDP-2.0.1";
    final String CLUSTER_NAME = getUniqueName();
    final String HDFS_SERVICE_CHECK_ROLE = "HDFS_SERVICE_CHECK";
    final String MAPREDUCE2_SERVICE_CHECK_ROLE = "MAPREDUCE2_SERVICE_CHECK";
    final String YARN_SERVICE_CHECK_ROLE = "YARN_SERVICE_CHECK";

    Map<String,String> mapRequestProps = Collections.emptyMap();


    AmbariManagementController amc = injector.getInstance(AmbariManagementController.class);
    Clusters clusters = injector.getInstance(Clusters.class);

    clusters.addHost(HOST1);
    Host host = clusters.getHost(HOST1);
    setOsFamily(host, "redhat", "5.9");
    clusters.getHost(HOST1).setState(HostState.HEALTHY);
    clusters.updateHostMappings(host);

    ClusterRequest clusterRequest = new ClusterRequest(null, CLUSTER_NAME, STACK_ID, null);
    amc.createCluster(clusterRequest);

    Set<ServiceRequest> serviceRequests = new HashSet<>();
    serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", repositoryVersion201.getId(), null));
    serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", repositoryVersion201.getId(), null));
    serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", repositoryVersion201.getId(), null));

    ServiceResourceProviderTest.createServices(amc, repositoryVersionDAO, serviceRequests);

    Set<ServiceComponentRequest> serviceComponentRequests = new HashSet<>();
    serviceComponentRequests.add(new ServiceComponentRequest(CLUSTER_NAME, "HDFS", "NAMENODE", null));
    serviceComponentRequests.add(new ServiceComponentRequest(CLUSTER_NAME, "HDFS", "SECONDARY_NAMENODE", null));
    serviceComponentRequests.add(new ServiceComponentRequest(CLUSTER_NAME, "HDFS", "DATANODE", null));
    serviceComponentRequests.add(new ServiceComponentRequest(CLUSTER_NAME, "MAPREDUCE2", "HISTORYSERVER", null));
    serviceComponentRequests.add(new ServiceComponentRequest(CLUSTER_NAME, "YARN", "RESOURCEMANAGER", null));
    serviceComponentRequests.add(new ServiceComponentRequest(CLUSTER_NAME, "YARN", "NODEMANAGER", null));

    ComponentResourceProviderTest.createComponents(amc, serviceComponentRequests);

    Set<HostRequest> hostRequests = new HashSet<>();
    hostRequests.add(new HostRequest(HOST1, CLUSTER_NAME));

    HostResourceProviderTest.createHosts(amc, hostRequests);

    for (Host clusterHost : clusters.getHosts()) {
      clusters.updateHostMappings(clusterHost);
    }

    Set<ServiceComponentHostRequest> componentHostRequests = new HashSet<>();
    componentHostRequests.add(new ServiceComponentHostRequest(CLUSTER_NAME, null, "DATANODE", HOST1, null));
    componentHostRequests.add(new ServiceComponentHostRequest(CLUSTER_NAME, null, "NAMENODE", HOST1, null));
    componentHostRequests.add(new ServiceComponentHostRequest(CLUSTER_NAME, null, "SECONDARY_NAMENODE", HOST1, null));
    componentHostRequests.add(new ServiceComponentHostRequest(CLUSTER_NAME, null, "HISTORYSERVER", HOST1, null));
    componentHostRequests.add(new ServiceComponentHostRequest(CLUSTER_NAME, null, "RESOURCEMANAGER", HOST1, null));
    componentHostRequests.add(new ServiceComponentHostRequest(CLUSTER_NAME, null, "NODEMANAGER", HOST1, null));

    amc.createHostComponents(componentHostRequests);

    //Install services
    serviceRequests.clear();
    serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", repositoryVersion201.getId(), State.INSTALLED.name()));
    serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", repositoryVersion201.getId(), State.INSTALLED.name()));
    serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", repositoryVersion201.getId(), State.INSTALLED.name()));

    ServiceResourceProviderTest.updateServices(amc, serviceRequests, mapRequestProps, true, false);

    Cluster cluster = clusters.getCluster(CLUSTER_NAME);

    for (String serviceName : cluster.getServices().keySet() ) {

      for(String componentName: cluster.getService(serviceName).getServiceComponents().keySet()) {

        Map<String, ServiceComponentHost> serviceComponentHosts = cluster.getService(serviceName).getServiceComponent(componentName).getServiceComponentHosts();

        for (Map.Entry<String, ServiceComponentHost> entry : serviceComponentHosts.entrySet()) {
          ServiceComponentHost cHost = entry.getValue();
          cHost.handleEvent(new ServiceComponentHostInstallEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis(), STACK_ID));
          cHost.handleEvent(new ServiceComponentHostOpSucceededEvent(cHost.getServiceComponentName(), cHost.getHostName(), System.currentTimeMillis()));
        }
      }
    }

    //Start services
    serviceRequests.clear();
    serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "HDFS", repositoryVersion201.getId(), State.STARTED.name()));
    serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "MAPREDUCE2", repositoryVersion201.getId(), State.STARTED.name()));
    serviceRequests.add(new ServiceRequest(CLUSTER_NAME, "YARN", repositoryVersion201.getId(), State.STARTED.name()));

    RequestStatusResponse response = ServiceResourceProviderTest.updateServices(amc, serviceRequests,
        mapRequestProps, true, false);

    Collection<?> hdfsSmokeTasks = CollectionUtils.select(response.getTasks(), new RolePredicate(HDFS_SERVICE_CHECK_ROLE));
    //Ensure that smoke test task was created for HDFS
    org.junit.Assert.assertEquals(1, hdfsSmokeTasks.size());

    Collection<?> mapreduce2SmokeTasks = CollectionUtils.select(response.getTasks(), new RolePredicate(MAPREDUCE2_SERVICE_CHECK_ROLE));
    //Ensure that smoke test task was created for MAPREDUCE2
    org.junit.Assert.assertEquals(1, mapreduce2SmokeTasks.size());

    Collection<?> yarnSmokeTasks = CollectionUtils.select(response.getTasks(), new RolePredicate(YARN_SERVICE_CHECK_ROLE));
    //Ensure that smoke test task was created for YARN
    org.junit.Assert.assertEquals(1, yarnSmokeTasks.size());
  }
Create a cluster with a service, and verify that the request tasks have the correct output log and error log paths.
ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java