@Test
  public void testConfigGroupOverridesWithDecommissionDatanode() throws Exception, AuthorizationException {
    String cluster1 = getUniqueName();
    createCluster(cluster1);
    Cluster cluster = clusters.getCluster(cluster1);
    cluster.setDesiredStackVersion(new StackId("HDP-2.0.7"));
    String serviceName = "HDFS";
    createService(cluster1, serviceName, null);
    String componentName1 = "NAMENODE";
    String componentName2 = "DATANODE";
    String componentName3 = "HDFS_CLIENT";

    createServiceComponent(cluster1, serviceName, componentName1,
        State.INIT);
    createServiceComponent(cluster1, serviceName, componentName2,
        State.INIT);
    createServiceComponent(cluster1, serviceName, componentName3,
        State.INIT);

    final String host1 = getUniqueName();
    final String host2 = getUniqueName();

    addHostToCluster(host1, cluster1);
    addHostToCluster(host2, cluster1);

    createServiceComponentHost(cluster1, serviceName, componentName1,
        host1, null);
    createServiceComponentHost(cluster1, serviceName, componentName2,
        host1, null);
    createServiceComponentHost(cluster1, serviceName, componentName2,
        host2, null);
    createServiceComponentHost(cluster1, serviceName, componentName3,
        host1, null);
    createServiceComponentHost(cluster1, serviceName, componentName3,
        host2, null);

    // Install
    installService(cluster1, serviceName, false, false);

    // Create and attach config
    Map<String, String> configs = new HashMap<>();
    configs.put("a", "b");

    ConfigurationRequest cr1, cr2;
    cr1 = new ConfigurationRequest(cluster1, "hdfs-site", "version1",
        configs, null);
    ClusterRequest crReq = new ClusterRequest(cluster.getClusterId(), cluster1, null, null);
    crReq.setDesiredConfig(Collections.singletonList(cr1));
    controller.updateClusters(Collections.singleton(crReq), null);

    // Start
    startService(cluster1, serviceName, false, false);

    // Create Config group for hdfs-site
    configs = new HashMap<>();
    configs.put("a", "c");

    String group1 = getUniqueName();
    String tag1 = getUniqueName();

    ConfigFactory configFactory = injector.getInstance(ConfigFactory.class);
    final Config config = configFactory.createReadOnly("hdfs-site", "version122", configs, null);
    Long groupId = createConfigGroup(clusters.getCluster(cluster1), serviceName, group1, tag1,
        new ArrayList<String>() {{
          add(host1);
          add(host2);
        }},
        new ArrayList<Config>() {{
          add(config);
        }}
    );

    Assert.assertNotNull(groupId);

    cluster = clusters.getCluster(cluster1);
    Service s = cluster.getService(serviceName);
    Assert.assertEquals(State.STARTED, s.getDesiredState());

    Map<String, String> params = new HashMap<String, String>() {{
      put("test", "test");
      put("excluded_hosts", host1);
    }};
    RequestResourceFilter resourceFilter = new RequestResourceFilter("HDFS", "NAMENODE", null);
    ExecuteActionRequest request = new ExecuteActionRequest(cluster1, "DECOMMISSION", params, false);
    request.getResourceFilters().add(resourceFilter);

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

    RequestStatusResponse response = controller.createAction(request,
        requestProperties);

    List<HostRoleCommand> storedTasks = actionDB.getRequestTasks(response.getRequestId());
    ExecutionCommand execCmd = storedTasks.get(0).getExecutionCommandWrapper
        ().getExecutionCommand();
    Assert.assertNotNull(storedTasks);
    Assert.assertEquals(1, storedTasks.size());
    HostRoleCommand command =  storedTasks.get(0);
    Assert.assertEquals(Role.NAMENODE, command.getRole());
    Assert.assertEquals(RoleCommand.CUSTOM_COMMAND, command.getRoleCommand());
    Assert.assertEquals("DECOMMISSION", execCmd.getCommandParams().get("custom_command"));
    Assert.assertEquals(host1, execCmd.getCommandParams().get("all_decommissioned_hosts"));
    Assert.assertEquals(requestProperties.get(REQUEST_CONTEXT_PROPERTY), response.getRequestContext());
  }
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