Updated Branches: refs/heads/branch-0.8 9f3ce7b89 -> 265d98ea5
WHIRR-660. Provide useful error message/exception if empty instance templates Project: http://git-wip-us.apache.org/repos/asf/whirr/repo Commit: http://git-wip-us.apache.org/repos/asf/whirr/commit/ff134d26 Tree: http://git-wip-us.apache.org/repos/asf/whirr/tree/ff134d26 Diff: http://git-wip-us.apache.org/repos/asf/whirr/diff/ff134d26 Branch: refs/heads/branch-0.8 Commit: ff134d2695af58bd6569347e0126d5a749a43587 Parents: 9f3ce7b Author: Andrew Bayer <[email protected]> Authored: Mon Mar 11 10:48:03 2013 -0700 Committer: Andrew Bayer <[email protected]> Committed: Mon Mar 25 09:12:08 2013 -0700 ---------------------------------------------------------------------- CHANGES.txt | 3 ++ .../whirr/actions/ScriptBasedClusterAction.java | 4 +++ .../actions/ScriptBasedClusterActionTest.java | 21 +++++++++++++++ 3 files changed, 28 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/whirr/blob/ff134d26/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 65dab4d..28c28fd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,9 @@ Release 0.8.2 (unreleased changes) IMPROVEMENTS + WHIRR-660. Provide useful message if whirr.instance-templates is + empty or not provided. (abayer) + WHIRR-672. Allow eager caching of instance hostname based on pre-provision instance metadata. (Graham Gear via tomwhite) http://git-wip-us.apache.org/repos/asf/whirr/blob/ff134d26/core/src/main/java/org/apache/whirr/actions/ScriptBasedClusterAction.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/whirr/actions/ScriptBasedClusterAction.java b/core/src/main/java/org/apache/whirr/actions/ScriptBasedClusterAction.java index 865b5cc..b2a522f 100644 --- a/core/src/main/java/org/apache/whirr/actions/ScriptBasedClusterAction.java +++ b/core/src/main/java/org/apache/whirr/actions/ScriptBasedClusterAction.java @@ -95,6 +95,10 @@ public abstract class ScriptBasedClusterAction extends ClusterAction { public Cluster execute(ClusterSpec clusterSpec, Cluster cluster) throws IOException, InterruptedException { + if (clusterSpec.getInstanceTemplates().size() == 0) { + throw new IllegalArgumentException("No instance templates specified."); + } + Map<InstanceTemplate, ClusterActionEvent> eventMap = Maps.newHashMap(); Cluster newCluster = cluster; for (InstanceTemplate instanceTemplate : clusterSpec.getInstanceTemplates()) { http://git-wip-us.apache.org/repos/asf/whirr/blob/ff134d26/core/src/test/java/org/apache/whirr/actions/ScriptBasedClusterActionTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/whirr/actions/ScriptBasedClusterActionTest.java b/core/src/test/java/org/apache/whirr/actions/ScriptBasedClusterActionTest.java index f992dec..dc3ab79 100644 --- a/core/src/test/java/org/apache/whirr/actions/ScriptBasedClusterActionTest.java +++ b/core/src/test/java/org/apache/whirr/actions/ScriptBasedClusterActionTest.java @@ -117,6 +117,27 @@ public abstract class ScriptBasedClusterActionTest<T extends ScriptBasedClusterA return InstanceTemplate.builder().numberOfInstance(1).roles(roles).build(); } + @Test(expected = IllegalArgumentException.class) + public void testEmptyInstanceTemplates() throws Exception { + T action = newClusterActionInstance(EMPTYSET, EMPTYSET); + DryRun dryRun = getDryRunForAction(action).reset(); + + ClusterSpec tempSpec = ClusterSpec.withTemporaryKeys(); + + tempSpec.setClusterName("test-cluster-for-script-exection"); + tempSpec.setProvider("stub"); + tempSpec.setIdentity("dummy"); + tempSpec.setStateStore("none"); + + ClusterController controller = new ClusterController(); + Cluster tempCluster = controller.launchCluster(tempSpec); + + + action.execute(tempSpec, tempCluster); + + List<StatementOnNode> executions = dryRun.getTotallyOrderedExecutions(); + } + @Test public void testActionIsExecutedOnAllRelevantNodes() throws Exception { T action = newClusterActionInstance(EMPTYSET, EMPTYSET);
