Assert.assertEquals(1, storedTasks.size());
HostRoleCommand task = storedTasks.get(0);
Assert.assertEquals(RoleCommand.ACTIONEXECUTE, task.getRoleCommand());
Assert.assertEquals("a1", task.getRole().name());
Assert.assertEquals("h1", task.getHostName());
ExecutionCommand cmd = task.getExecutionCommandWrapper().getExecutionCommand();
Map<String, String> commandParameters = cmd.getCommandParams();
Assert.assertTrue(commandParameters.containsKey("test"));
Assert.assertEquals("HDFS", cmd.getServiceName());
Assert.assertEquals("DATANODE", cmd.getComponentName());
Assert.assertNotNull(commandParameters.get("jdk_location"));
resourceFilters.clear();
resourceFilter = new RequestResourceFilter("", "", null);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest("c1", null, "a2", resourceFilters, null, params);
response = controller.createAction(actionRequest, requestProperties);
assertEquals(2, response.getTasks().size());
final List<HostRoleCommand> storedTasks2 = actionDB.getRequestTasks(response.getRequestId());
task = storedTasks2.get(1);
Assert.assertEquals(RoleCommand.ACTIONEXECUTE, task.getRoleCommand());
Assert.assertEquals("a2", task.getRole().name());
HashSet<String> expectedHosts = new HashSet<String>() {{
add("h2");
add("h1");
}};
HashSet<String> actualHosts = new HashSet<String>() {{
add(storedTasks2.get(1).getHostName());
add(storedTasks2.get(0).getHostName());
}};
Assert.assertEquals(expectedHosts, actualHosts);
cmd = task.getExecutionCommandWrapper().getExecutionCommand();
commandParameters = cmd.getCommandParams();
Assert.assertTrue(commandParameters.containsKey("test"));
Assert.assertEquals("HDFS", cmd.getServiceName());
Assert.assertEquals("DATANODE", cmd.getComponentName());
hosts = new ArrayList<String>() {{add("h3");}};
resourceFilters.clear();
resourceFilter = new RequestResourceFilter("", "", hosts);
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest("c1", null, "a1", resourceFilters, null, params);
response = controller.createAction(actionRequest, requestProperties);
assertEquals(1, response.getTasks().size());
taskStatus = response.getTasks().get(0);
Assert.assertEquals("h3", taskStatus.getHostName());
Assert.assertTrue(null != cmd.getPassiveInfo());
}