@Test
  public void testServiceUpdateInvalidRequest() throws Exception, AuthorizationException {
    // multiple clusters
    // dup services
    // multiple diff end states

    String cluster1 = getUniqueName();
    createCluster(cluster1);
    String cluster2 = getUniqueName();
    createCluster(cluster2);
    String serviceName1 = "HDFS";

    createService(cluster1, serviceName1, null);
    String serviceName2 = "HBASE";
    String serviceName3 = "HBASE";

    Map<String, String> mapRequestProps = new HashMap<>();
    mapRequestProps.put("context", "Called from a test");

    try {
      createService(cluster2, serviceName3, repositoryVersion01, null);
      fail("Expected fail for invalid service for stack 0.1");
    } catch (Exception e) {
      // Expected
    }

    clusters.getCluster(cluster1).setDesiredStackVersion(
        new StackId("HDP-0.2"));
    clusters.getCluster(cluster2).setDesiredStackVersion(
        new StackId("HDP-0.2"));
    createService(cluster1, serviceName2, null);
    createService(cluster2, serviceName3, null);

    Set<ServiceRequest> reqs = new HashSet<>();
    ServiceRequest req1, req2;
    try {
      reqs.clear();
      req1 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
          State.INSTALLED.toString(), null);
      req2 = new ServiceRequest(cluster2, serviceName2, repositoryVersion02.getId(),
          State.INSTALLED.toString(), null);
      reqs.add(req1);
      reqs.add(req2);
      ServiceResourceProviderTest.updateServices(controller, reqs, mapRequestProps, true, false);
      fail("Expected failure for multi cluster update");
    } catch (Exception e) {
      // Expected
    }

    try {
      reqs.clear();
      req1 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
          State.INSTALLED.toString(), null);
      req2 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
          State.INSTALLED.toString(), null);
      reqs.add(req1);
      reqs.add(req2);
      ServiceResourceProviderTest.updateServices(controller, reqs, mapRequestProps, true, false);
      fail("Expected failure for dups services");
    } catch (Exception e) {
      // Expected
    }

    clusters.getCluster(cluster1).getService(serviceName2)
        .setDesiredState(State.INSTALLED);

    try {
      reqs.clear();
      req1 = new ServiceRequest(cluster1, serviceName1, repositoryVersion02.getId(),
          State.INSTALLED.toString(), null);
      req2 = new ServiceRequest(cluster1, serviceName2, repositoryVersion02.getId(),
          State.STARTED.toString(), null);
      reqs.add(req1);
      reqs.add(req2);
      ServiceResourceProviderTest.updateServices(controller, reqs, mapRequestProps, true, false);
      fail("Expected failure for different states");
    } catch (Exception e) {
      // Expected
    }

  }
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