@Override protected ToStringHelper string() { return super.string().add("response", response); } }
@Override public boolean apply(Cluster.Instance input) { return input.getId().equals(node.getNode().getId()); } });
private void assertAnyStatementContains(DryRun dryRun, String... values) { Set<String> toCheck = newHashSet(values); for (StatementOnNode node : dryRun.getTotallyOrderedExecutions()) { String statement = node.getStatement().render(OsFamily.UNIX); for (String term : ImmutableSet.copyOf(toCheck)) { if (statement.contains(term)) { toCheck.remove(term); } } } assertTrue("Unable to find the following terms in any statement: " + toCheck.toString(), toCheck.size() == 0); }
@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()); }
private void assertNoStatementContains(DryRun dryRun, String... values) { Set<String> foundTerms = newHashSet(); for (StatementOnNode node : dryRun.getTotallyOrderedExecutions()) { String statement = node.getStatement().render(OsFamily.UNIX); for (String term : values) { if (statement.contains(term)) { foundTerms.add(term); } } } assertTrue("Some terms are present in statements: " + foundTerms, foundTerms.size() == 0); }
@Override protected ToStringHelper string() { return super.string().add("response", response); } }
@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()); }
String[] parts = getScriptName(script.getStatement()).split("-"); if ((!executedPhases.empty() && !executedPhases.peek().equals(parts[0])) || executedPhases.empty()) { executedPhases.push(parts[0]);
@Override public String toString() { return string().toString(); }
@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()); }
@Override protected ToStringHelper string() { return super.string().add("response", response); } }
@Override protected ToStringHelper string() { return super.string().add("response", response); } }
@Override public String toString() { return string().toString(); }
@Override public String toString() { return string().toString(); }
@Override public String toString() { return string().toString(); }
@Override protected ToStringHelper string() { return super.string().add("cause", cause.getMessage()); } }
@Override protected ToStringHelper string() { return super.string().add("cause", cause.getMessage()); } }
@Override protected ToStringHelper string() { return super.string().add("cause", cause.getMessage()); } }
@Override protected ToStringHelper string() { return super.string().add("cause", cause.getMessage()); } }