Assert.assertNotNull(stage);
Assert.assertEquals(-1L, stage.getClusterId());
List<HostRoleCommand> storedTasks = actionDB.getRequestTasks(response.getRequestId());
Assert.assertEquals(1, storedTasks.size());
HostRoleCommand task = storedTasks.get(0);
Assert.assertEquals(RoleCommand.ACTIONEXECUTE, task.getRoleCommand());
Assert.assertEquals("a1", task.getRole().name());
Assert.assertEquals(hostname1, task.getHostName());
ExecutionCommand cmd = task.getExecutionCommandWrapper().getExecutionCommand();
Assert.assertTrue(cmd.getCommandParams().containsKey("some_custom_param"));
Assert.assertEquals(null, cmd.getServiceName());
Assert.assertEquals(null, cmd.getComponentName());
// !!! target two hosts
hosts = Arrays.asList(hostname1, hostname2);
resourceFilter = new RequestResourceFilter(null, null, hosts);
resourceFilters = new ArrayList<RequestResourceFilter>();
resourceFilters.add(resourceFilter);
actionRequest = new ExecuteActionRequest(null, null,
"a1", resourceFilters, null, requestParams);
response = controller.createAction(actionRequest, requestProperties);
assertEquals(2, response.getTasks().size());
boolean host1Found = false;
boolean host2Found = false;
for (ShortTaskStatus sts : response.getTasks()) {
if (sts.getHostName().equals(hostname1))
host1Found = true;
else if (sts.getHostName().equals(hostname2))
host2Found = true;
}
Assert.assertTrue(host1Found);
Assert.assertTrue(host2Found);
stage = actionDB.getAllStages(response.getRequestId()).get(0);
Assert.assertNotNull(stage);
Assert.assertEquals(-1L, stage.getClusterId());
storedTasks = actionDB.getRequestTasks(response.getRequestId());
Assert.assertEquals(2, storedTasks.size());
task = storedTasks.get(0);
Assert.assertEquals(RoleCommand.ACTIONEXECUTE, task.getRoleCommand());
Assert.assertEquals("a1", task.getRole().name());
Assert.assertEquals(hostname1, task.getHostName());
cmd = task.getExecutionCommandWrapper().getExecutionCommand();
Assert.assertTrue(cmd.getCommandParams().containsKey("some_custom_param"));
Assert.assertEquals(null, cmd.getServiceName());
Assert.assertEquals(null, cmd.getComponentName());
}