Search in sources :

Example 6 with StatementOnNode

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());
}
Also used : DryRun(org.apache.whirr.service.DryRunModule.DryRun) StatementOnNode(org.jclouds.compute.events.StatementOnNode) Test(org.junit.Test)

Example 7 with StatementOnNode

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());
}
Also used : DryRun(org.apache.whirr.service.DryRunModule.DryRun) StatementOnNode(org.jclouds.compute.events.StatementOnNode) Test(org.junit.Test)

Example 8 with StatementOnNode

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));
}
Also used : DryRun(org.apache.whirr.service.DryRunModule.DryRun) StatementOnNode(org.jclouds.compute.events.StatementOnNode) Test(org.junit.Test)

Example 9 with StatementOnNode

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);
}
Also used : StatementOnNode(org.jclouds.compute.events.StatementOnNode)

Aggregations

StatementOnNode (org.jclouds.compute.events.StatementOnNode)9 DryRun (org.apache.whirr.service.DryRunModule.DryRun)7 Test (org.junit.Test)7 ClusterController (org.apache.whirr.ClusterController)2 ClusterSpec (org.apache.whirr.ClusterSpec)2 Collection (java.util.Collection)1 Stack (java.util.Stack)1 CompositeConfiguration (org.apache.commons.configuration.CompositeConfiguration)1 Cluster (org.apache.whirr.Cluster)1 NodeMetadata (org.jclouds.compute.domain.NodeMetadata)1 Statement (org.jclouds.scriptbuilder.domain.Statement)1