@Override public boolean apply(Cluster.Instance input) { return input.getId().equals(node.getNode().getId()); } });
@Test public void testFilterScriptExecutionByInstanceId() throws Exception { String instanceId = getInstaceForRole(cluster, "noop3").getId(); T action = newClusterActionInstance(EMPTYSET, newHashSet(instanceId)); DryRun dryRun = getDryRunForAction(action).reset(); action.execute(clusterSpec, cluster); List<StatementOnNode> executions = dryRun.getTotallyOrderedExecutions(); assertThat(executions.size(), is(1)); assertHasRole(executions.get(0), cluster, "noop3"); assertEquals(executions.get(0).getNode().getId(), instanceId); assertAnyStatementContains(dryRun, "noop1-" + getActionName(), "noop3-" + getActionName()); }
@Test public void testFilterScriptExecutionByRoleAndInstanceId() throws Exception { String instanceId = getInstaceForRole(cluster, "noop1").getId(); T action = newClusterActionInstance(newHashSet("noop1"), newHashSet(instanceId)); DryRun dryRun = getDryRunForAction(action).reset(); action.execute(clusterSpec, cluster); List<StatementOnNode> executions = dryRun.getTotallyOrderedExecutions(); assertThat(executions.size(), is(1)); assertHasRole(executions.get(0), cluster, "noop1"); assertEquals(executions.get(0).getNode().getId(), instanceId); assertAnyStatementContains(dryRun, "noop1-" + getActionName()); assertNoStatementContains(dryRun, "noop2-" + getActionName(), "noop3-" + getActionName()); }
@Test public void testFilterScriptExecutionByRole() throws Exception { String instanceId = getInstaceForRole(cluster, "noop2").getId(); T action = newClusterActionInstance(ImmutableSet.of("noop2"), EMPTYSET); DryRun dryRun = getDryRunForAction(action).reset(); action.execute(clusterSpec, cluster); List<StatementOnNode> executions = dryRun.getTotallyOrderedExecutions(); assertThat(executions.size(), is(1)); assertHasRole(executions.get(0), cluster, "noop2"); assertEquals(executions.get(0).getNode().getId(), instanceId); assertAnyStatementContains(dryRun, "noop2-" + getActionName()); assertNoStatementContains(dryRun, "noop1-" + getActionName(), "noop3-" + getActionName()); }