use of org.jclouds.compute.events.StatementOnNode in project whirr by apache.
the class ScriptBasedClusterActionTest method testFilterScriptExecutionByRoleAndInstanceId.
@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());
}
use of org.jclouds.compute.events.StatementOnNode in project whirr by apache.
the class ScriptBasedClusterActionTest method testFilterScriptExecutionByInstanceId.
@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());
}
use of org.jclouds.compute.events.StatementOnNode in project whirr by apache.
the class ScriptBasedClusterActionTest method testNoScriptExecutionsForNoop.
@Test
public void testNoScriptExecutionsForNoop() throws Exception {
T action = newClusterActionInstance(ImmutableSet.of("noop"), EMPTYSET);
DryRun dryRun = getDryRunForAction(action).reset();
action.execute(clusterSpec, cluster);
List<StatementOnNode> executions = dryRun.getTotallyOrderedExecutions();
// empty because noop does not emit any statements
assertThat(executions.size(), is(0));
}
use of org.jclouds.compute.events.StatementOnNode in project whirr by apache.
the class ScriptBasedClusterActionTest method assertNoStatementContains.
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);
}
Aggregations