You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whirr.apache.org by as...@apache.org on 2012/01/25 14:22:36 UTC

svn commit: r1235735 [2/2] - in /whirr/trunk: ./ cli/src/main/java/org/apache/whirr/cli/ cli/src/main/java/org/apache/whirr/cli/command/ cli/src/main/resources/META-INF/services/ cli/src/test/java/org/apache/whirr/cli/ cli/src/test/java/org/apache/whir...

Modified: whirr/trunk/core/src/main/java/org/apache/whirr/service/DryRunModule.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/service/DryRunModule.java?rev=1235735&r1=1235734&r2=1235735&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/service/DryRunModule.java (original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/service/DryRunModule.java Wed Jan 25 13:22:35 2012
@@ -18,28 +18,17 @@
 
 package org.apache.whirr.service;
 
-import static com.google.common.collect.Iterables.concat;
-import static com.google.common.collect.Iterables.contains;
-import static com.google.common.collect.Iterables.find;
-import static com.google.common.collect.Multimaps.synchronizedListMultimap;
-import static com.google.common.io.ByteStreams.newInputStreamSupplier;
-import static com.google.inject.matcher.Matchers.identicalTo;
-import static com.google.inject.matcher.Matchers.returns;
-import static com.google.inject.matcher.Matchers.subclassesOf;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.annotation.Nullable;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
+import com.google.common.base.Function;
+import com.google.common.base.Objects;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.LinkedListMultimap;
+import com.google.common.collect.ListMultimap;
+import com.google.common.collect.MapMaker;
+import com.google.common.collect.Maps;
+import com.google.common.io.InputSupplier;
+import com.google.inject.AbstractModule;
 import org.aopalliance.intercept.MethodInterceptor;
 import org.aopalliance.intercept.MethodInvocation;
 import org.jclouds.compute.callables.RunScriptOnNode;
@@ -56,17 +45,26 @@ import org.jclouds.ssh.SshClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Function;
-import com.google.common.base.Objects;
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableListMultimap;
-import com.google.common.collect.LinkedListMultimap;
-import com.google.common.collect.ListMultimap;
-import com.google.common.collect.MapMaker;
-import com.google.common.collect.Maps;
-import com.google.common.io.InputSupplier;
-import com.google.inject.AbstractModule;
+import javax.annotation.Nullable;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static com.google.common.collect.Iterables.concat;
+import static com.google.common.collect.Iterables.contains;
+import static com.google.common.collect.Iterables.find;
+import static com.google.common.collect.Multimaps.synchronizedListMultimap;
+import static com.google.common.io.ByteStreams.newInputStreamSupplier;
+import static com.google.inject.matcher.Matchers.identicalTo;
+import static com.google.inject.matcher.Matchers.returns;
+import static com.google.inject.matcher.Matchers.subclassesOf;
 
 /**
  * Outputs orchestration jclouds does to INFO logging and saves an ordered list
@@ -105,6 +103,7 @@ public class DryRunModule extends Abstra
 
   public static void resetDryRun() {
     DryRun.INSTANCE.executedScripts.clear();
+    DryRun.INSTANCE.totallyOrderedScripts.clear();
   }
 
   // enum singleton pattern

Added: whirr/trunk/core/src/test/java/org/apache/whirr/actions/CleanupClusterActionTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/actions/CleanupClusterActionTest.java?rev=1235735&view=auto
==============================================================================
--- whirr/trunk/core/src/test/java/org/apache/whirr/actions/CleanupClusterActionTest.java (added)
+++ whirr/trunk/core/src/test/java/org/apache/whirr/actions/CleanupClusterActionTest.java Wed Jan 25 13:22:35 2012
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.actions;
+
+import com.google.common.base.Function;
+import org.apache.whirr.ClusterSpec;
+import org.apache.whirr.service.ClusterActionHandler;
+import org.jclouds.compute.ComputeServiceContext;
+
+import java.util.Map;
+import java.util.Set;
+
+public class CleanupClusterActionTest extends ScriptBasedClusterActionTest<CleanupClusterAction> {
+
+  @Override
+  public String getActionName() {
+    return ClusterActionHandler.CLEANUP_ACTION;
+  }
+  
+  @Override
+  public CleanupClusterAction newClusterActionInstance(
+      Function<ClusterSpec, ComputeServiceContext> getCompute, Map<String, ClusterActionHandler> handlerMap,
+      Set<String> targetRoles, Set<String> targetInstanceIds
+  ) {
+    return new CleanupClusterAction(getCompute, handlerMap, targetRoles, targetInstanceIds);
+  }
+}

Added: whirr/trunk/core/src/test/java/org/apache/whirr/actions/ConfigureServicesActionTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/actions/ConfigureServicesActionTest.java?rev=1235735&view=auto
==============================================================================
--- whirr/trunk/core/src/test/java/org/apache/whirr/actions/ConfigureServicesActionTest.java (added)
+++ whirr/trunk/core/src/test/java/org/apache/whirr/actions/ConfigureServicesActionTest.java Wed Jan 25 13:22:35 2012
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.actions;
+
+import com.google.common.base.Function;
+import org.apache.whirr.ClusterSpec;
+import org.apache.whirr.service.ClusterActionHandler;
+import org.jclouds.compute.ComputeServiceContext;
+
+import java.util.Map;
+import java.util.Set;
+
+public class ConfigureServicesActionTest extends ScriptBasedClusterActionTest<ConfigureServicesAction> {
+
+  @Override
+  public String getActionName() {
+    return ClusterActionHandler.CONFIGURE_ACTION;
+  }
+  
+  @Override
+  public ConfigureServicesAction newClusterActionInstance(
+      Function<ClusterSpec, ComputeServiceContext> getCompute, Map<String, ClusterActionHandler> handlerMap,
+      Set<String> targetRoles, Set<String> targetInstanceIds
+  ) {
+    return new ConfigureServicesAction(getCompute, handlerMap, targetRoles, targetInstanceIds);
+  }
+
+}

Added: whirr/trunk/core/src/test/java/org/apache/whirr/actions/ScriptBasedClusterActionTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/actions/ScriptBasedClusterActionTest.java?rev=1235735&view=auto
==============================================================================
--- whirr/trunk/core/src/test/java/org/apache/whirr/actions/ScriptBasedClusterActionTest.java (added)
+++ whirr/trunk/core/src/test/java/org/apache/whirr/actions/ScriptBasedClusterActionTest.java Wed Jan 25 13:22:35 2012
@@ -0,0 +1,262 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.actions;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+import org.apache.whirr.Cluster;
+import org.apache.whirr.ClusterController;
+import org.apache.whirr.ClusterSpec;
+import org.apache.whirr.HandlerMapFactory;
+import org.apache.whirr.InstanceTemplate;
+import org.apache.whirr.service.ClusterActionEvent;
+import org.apache.whirr.service.ClusterActionHandler;
+import org.apache.whirr.service.ClusterActionHandlerSupport;
+import org.apache.whirr.service.ComputeCache;
+import org.apache.whirr.service.DryRunModule;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.callables.RunScriptOnNode;
+import org.jclouds.scriptbuilder.domain.OsFamily;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static com.google.common.collect.Sets.newHashSet;
+import static org.apache.whirr.service.DryRunModule.DryRun;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.jclouds.scriptbuilder.domain.Statements.exec;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public abstract class ScriptBasedClusterActionTest<T extends ScriptBasedClusterAction> {
+
+  public static class Noop1ClusterActionHandler extends
+      ClusterActionHandlerSupport {
+
+    @Override
+    public String getRole() {
+      return "noop1";
+    }
+
+    @Override
+    public void beforeConfigure(ClusterActionEvent event) {
+      addStatement(event, exec("echo noop1-configure"));
+    }
+
+    @Override
+    public void beforeStart(ClusterActionEvent event) {
+      addStatement(event, exec("echo noop1-start"));
+    }
+
+    @Override
+    public void beforeStop(ClusterActionEvent event) {
+      addStatement(event, exec("echo noop1-stop"));
+    }
+
+    @Override
+    public void beforeCleanup(ClusterActionEvent event) {
+      addStatement(event, exec("echo noop1-cleanup"));
+    }
+
+    @Override
+    public void beforeDestroy(ClusterActionEvent event) {
+      addStatement(event, exec("echo noop1-destroy"));
+    }
+  }
+
+  private final static Map<String, ClusterActionHandler> HANDLERMAP = HandlerMapFactory.create();
+  private final static Set<String> EMPTYSET = ImmutableSet.of();
+
+  private ClusterSpec clusterSpec;
+  private Cluster cluster;
+
+  @Before
+  public void setUp() throws Exception {
+    clusterSpec = ClusterSpec.withTemporaryKeys();
+
+    clusterSpec.setClusterName("test-cluster-for-script-exection");
+    clusterSpec.setProvider("stub");
+    clusterSpec.setIdentity("dummy");
+    clusterSpec.setStateStore("none");
+
+    clusterSpec.setInstanceTemplates(ImmutableList.of(
+        newInstanceTemplate("noop"),
+        newInstanceTemplate("noop", "noop1", "noop2"),
+        newInstanceTemplate("noop1", "noop3")
+    ));
+
+    ClusterController controller = new ClusterController();
+    cluster = controller.launchCluster(clusterSpec);
+
+    DryRunModule.resetDryRun();
+  }
+
+  private InstanceTemplate newInstanceTemplate(String... roles) {
+    return InstanceTemplate.builder().numberOfInstance(1).roles(roles).build();
+  }
+
+  @Test
+  public void testActionIsExecutedOnAllRelevantNodes() throws Exception {
+    T action = newClusterActionInstance(EMPTYSET, EMPTYSET);
+    action.execute(clusterSpec, cluster);
+
+    List<RunScriptOnNode> executions = DryRunModule.getDryRun()
+        .getTotallyOrderedExecutions();
+
+    // only 2 out of 3 because one instance has only noop
+    assertThat(executions.size(), is(2));
+  }
+
+  @Test
+  public void testFilterScriptExecutionByRole() throws Exception {
+    String instanceId = getInstaceForRole(cluster, "noop2").getId();
+    T action = newClusterActionInstance(ImmutableSet.of("noop2"), EMPTYSET);
+    action.execute(clusterSpec, cluster);
+
+    List<RunScriptOnNode> executions = DryRunModule.getDryRun()
+        .getTotallyOrderedExecutions();
+
+    assertThat(executions.size(), is(1));
+    assertHasRole(executions.get(0), cluster, "noop2");
+    assertEquals(executions.get(0).getNode().getId(), instanceId);
+
+    assertAnyStatementContains(DryRun.INSTANCE, "noop2-" + getActionName());
+    assertNoStatementContains(DryRun.INSTANCE, "noop1-" + getActionName(), "noop3-" + getActionName());
+  }
+
+  @Test
+  public void testFilterScriptExecutionByInstanceId() throws Exception {
+    String instanceId = getInstaceForRole(cluster, "noop3").getId();
+    T action = newClusterActionInstance(EMPTYSET, newHashSet(instanceId));
+    action.execute(clusterSpec, cluster);
+
+    List<RunScriptOnNode> executions = DryRunModule.getDryRun()
+        .getTotallyOrderedExecutions();
+
+    assertThat(executions.size(), is(1));
+    assertHasRole(executions.get(0), cluster, "noop3");
+    assertEquals(executions.get(0).getNode().getId(), instanceId);
+
+    assertAnyStatementContains(DryRun.INSTANCE, "noop1-" + getActionName(), "noop3-" + getActionName());
+  }
+
+  @Test
+  public void testFilterScriptExecutionByRoleAndInstanceId() throws Exception {
+    String instanceId = getInstaceForRole(cluster, "noop1").getId();
+    T action = newClusterActionInstance(newHashSet("noop1"), newHashSet(instanceId));
+    action.execute(clusterSpec, cluster);
+
+    List<RunScriptOnNode> executions = DryRunModule.getDryRun()
+        .getTotallyOrderedExecutions();
+
+    assertThat(executions.size(), is(1));
+    assertHasRole(executions.get(0), cluster, "noop1");
+    assertEquals(executions.get(0).getNode().getId(), instanceId);
+
+    assertAnyStatementContains(DryRun.INSTANCE, "noop1-" + getActionName());
+    assertNoStatementContains(DryRun.INSTANCE, "noop2-" + getActionName(), "noop3-" + getActionName());
+  }
+
+  @Test
+  public void testNoScriptExecutionsForNoop() throws Exception {
+    T action = newClusterActionInstance(ImmutableSet.of("noop"), EMPTYSET);
+    action.execute(clusterSpec, cluster);
+
+    List<RunScriptOnNode> executions = DryRunModule.getDryRun()
+        .getTotallyOrderedExecutions();
+
+    // empty because noop does not emit any statements
+    assertThat(executions.size(), is(0));
+  }
+
+  private void assertHasRole(final RunScriptOnNode node, Cluster cluster, String... roles) {
+    Cluster.Instance instance = getInstanceForNode(node, cluster);
+    for (String role : roles) {
+      assertTrue(instance.getRoles().contains(role));
+    }
+  }
+
+  private void assertAnyStatementContains(DryRun dryRun, String... values) {
+    Set<String> toCheck = newHashSet(values);
+    for (RunScriptOnNode 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);
+  }
+
+  private void assertNoStatementContains(DryRun dryRun, String... values) {
+    Set<String> foundTerms = newHashSet();
+    for (RunScriptOnNode 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);
+  }
+
+  private Cluster.Instance getInstaceForRole(Cluster cluster, final String role) {
+    return Iterables.find(cluster.getInstances(),
+        new Predicate<Cluster.Instance>() {
+          @Override
+          public boolean apply(Cluster.Instance instance) {
+            return instance.getRoles().contains(role);
+          }
+        });
+  }
+
+  private Cluster.Instance getInstanceForNode(final RunScriptOnNode node, Cluster cluster) {
+    return Iterables.find(cluster.getInstances(),
+        new Predicate<Cluster.Instance>() {
+          @Override
+          public boolean apply(Cluster.Instance input) {
+            return input.getId().equals(node.getNode().getId());
+          }
+        });
+  }
+
+  private T newClusterActionInstance(Set<String> targetRoles, Set<String> targetInstanceIds) {
+    return newClusterActionInstance(ComputeCache.INSTANCE, HANDLERMAP, targetRoles, targetInstanceIds);
+  }
+
+  public abstract T newClusterActionInstance(
+      Function<ClusterSpec, ComputeServiceContext> getCompute,
+      Map<String, ClusterActionHandler> handlerMap,
+      Set<String> targetRoles,
+      Set<String> targetInstanceIds
+  );
+  
+  public abstract String getActionName();
+}

Added: whirr/trunk/core/src/test/java/org/apache/whirr/actions/StartServicesActionTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/actions/StartServicesActionTest.java?rev=1235735&view=auto
==============================================================================
--- whirr/trunk/core/src/test/java/org/apache/whirr/actions/StartServicesActionTest.java (added)
+++ whirr/trunk/core/src/test/java/org/apache/whirr/actions/StartServicesActionTest.java Wed Jan 25 13:22:35 2012
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.actions;
+
+import com.google.common.base.Function;
+import org.apache.whirr.ClusterSpec;
+import org.apache.whirr.service.ClusterActionHandler;
+import org.jclouds.compute.ComputeServiceContext;
+
+import java.util.Map;
+import java.util.Set;
+
+public class StartServicesActionTest extends ScriptBasedClusterActionTest<StartServicesAction> {
+
+  @Override
+  public String getActionName() {
+    return ClusterActionHandler.START_ACTION;
+  }
+  
+  @Override
+  public StartServicesAction newClusterActionInstance(
+      Function<ClusterSpec, ComputeServiceContext> getCompute, Map<String, ClusterActionHandler> handlerMap,
+      Set<String> targetRoles, Set<String> targetInstanceIds
+  ) {
+    return new StartServicesAction(getCompute, handlerMap, targetRoles, targetInstanceIds);
+  }
+}

Added: whirr/trunk/core/src/test/java/org/apache/whirr/actions/StopServicesActionTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/actions/StopServicesActionTest.java?rev=1235735&view=auto
==============================================================================
--- whirr/trunk/core/src/test/java/org/apache/whirr/actions/StopServicesActionTest.java (added)
+++ whirr/trunk/core/src/test/java/org/apache/whirr/actions/StopServicesActionTest.java Wed Jan 25 13:22:35 2012
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.whirr.actions;
+
+import com.google.common.base.Function;
+import org.apache.whirr.ClusterSpec;
+import org.apache.whirr.service.ClusterActionHandler;
+import org.jclouds.compute.ComputeServiceContext;
+
+import java.util.Map;
+import java.util.Set;
+
+public class StopServicesActionTest extends ScriptBasedClusterActionTest<StopServicesAction> {
+
+  @Override
+  public String getActionName() {
+    return ClusterActionHandler.STOP_ACTION;
+  }
+
+  @Override
+  public StopServicesAction newClusterActionInstance(
+      Function<ClusterSpec, ComputeServiceContext> getCompute, Map<String, ClusterActionHandler> handlerMap,
+      Set<String> targetRoles, Set<String> targetInstanceIds
+  ) {
+    return new StopServicesAction(getCompute, handlerMap, targetRoles, targetInstanceIds);
+  }
+
+}

Modified: whirr/trunk/core/src/test/java/org/apache/whirr/service/DryRunModuleTest.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/test/java/org/apache/whirr/service/DryRunModuleTest.java?rev=1235735&r1=1235734&r2=1235735&view=diff
==============================================================================
--- whirr/trunk/core/src/test/java/org/apache/whirr/service/DryRunModuleTest.java (original)
+++ whirr/trunk/core/src/test/java/org/apache/whirr/service/DryRunModuleTest.java Wed Jan 25 13:22:35 2012
@@ -18,19 +18,10 @@
 
 package org.apache.whirr.service;
 
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertSame;
-import static junit.framework.Assert.assertTrue;
-import static org.jclouds.scriptbuilder.domain.Statements.exec;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Stack;
-
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ListMultimap;
 import com.google.common.collect.Lists;
+import com.jcraft.jsch.JSchException;
 import org.apache.commons.configuration.CompositeConfiguration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.whirr.ClusterController;
@@ -43,8 +34,16 @@ import org.jclouds.scriptbuilder.InitBui
 import org.junit.Before;
 import org.junit.Test;
 
-import com.google.common.collect.ListMultimap;
-import com.jcraft.jsch.JSchException;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map.Entry;
+import java.util.Stack;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertSame;
+import static junit.framework.Assert.assertTrue;
+import static org.jclouds.scriptbuilder.domain.Statements.exec;
 
 public class DryRunModuleTest {
 
@@ -58,17 +57,27 @@ public class DryRunModuleTest {
 
     @Override
     public void beforeConfigure(ClusterActionEvent event) {
-      addStatement(event, exec("echo 1"));
+      addStatement(event, exec("echo noop2-configure"));
     }
 
     @Override
     public void beforeStart(ClusterActionEvent event) {
-      addStatement(event, exec("echo 2"));
+      addStatement(event, exec("echo noop2-start"));
+    }
+
+    @Override
+    public void beforeStop(ClusterActionEvent event) {
+      addStatement(event, exec("echo noop2-stop"));
+    }
+
+    @Override
+    public void beforeCleanup(ClusterActionEvent event) {
+      addStatement(event, exec("echo noop2-cleanup"));
     }
 
     @Override
     public void beforeDestroy(ClusterActionEvent event) {
-      addStatement(event, exec("echo 3"));
+      addStatement(event, exec("echo noop2-destroy"));
     }
   }
 
@@ -82,17 +91,27 @@ public class DryRunModuleTest {
 
     @Override
     public void beforeConfigure(ClusterActionEvent event) {
-      addStatement(event, exec("echo 1"));
+      addStatement(event, exec("echo noop3-configure"));
     }
 
     @Override
     public void beforeStart(ClusterActionEvent event) {
-      addStatement(event, exec("echo 2"));
+      addStatement(event, exec("echo noop3-start"));
+    }
+
+    @Override
+    public void beforeStop(ClusterActionEvent event) {
+      addStatement(event, exec("echo noop3-stop"));
+    }
+
+    @Override
+    public void beforeCleanup(ClusterActionEvent event) {
+      addStatement(event, exec("echo noop3-cleanup"));
     }
 
     @Override
     public void beforeDestroy(ClusterActionEvent event) {
-      addStatement(event, exec("echo 3"));
+      addStatement(event, exec("echo noop3-destroy"));
     }
   }
 

Modified: whirr/trunk/core/src/test/resources/META-INF/services/org.apache.whirr.service.ClusterActionHandler
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/test/resources/META-INF/services/org.apache.whirr.service.ClusterActionHandler?rev=1235735&r1=1235734&r2=1235735&view=diff
==============================================================================
--- whirr/trunk/core/src/test/resources/META-INF/services/org.apache.whirr.service.ClusterActionHandler (original)
+++ whirr/trunk/core/src/test/resources/META-INF/services/org.apache.whirr.service.ClusterActionHandler Wed Jan 25 13:22:35 2012
@@ -10,6 +10,7 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 org.apache.whirr.service.NoopClusterActionHandler
+org.apache.whirr.actions.ScriptBasedClusterActionTest$Noop1ClusterActionHandler
 org.apache.whirr.service.DryRunModuleTest$Noop2ClusterActionHandler
 org.apache.whirr.service.DryRunModuleTest$Noop3ClusterActionHandler
 org.apache.whirr.actions.integration.PhaseExecutionBarrierTest$PhaseBarrierTestActionHandler
\ No newline at end of file