diff --git a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java index 86d61cd96c..4eb69cb03f 100755 --- a/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/BaseComputeServiceLiveTest.java @@ -35,8 +35,8 @@ import static org.jclouds.compute.options.TemplateOptions.Builder.blockOnComplet import static org.jclouds.compute.options.TemplateOptions.Builder.overrideCredentialsWith; import static org.jclouds.compute.predicates.NodePredicates.TERMINATED; import static org.jclouds.compute.predicates.NodePredicates.all; -import static org.jclouds.compute.predicates.NodePredicates.runningWithTag; -import static org.jclouds.compute.predicates.NodePredicates.withTag; +import static org.jclouds.compute.predicates.NodePredicates.runningInGroup; +import static org.jclouds.compute.predicates.NodePredicates.inGroup; import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -207,7 +207,7 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, expectedExceptions = NoSuchElementException.class) public void testCorrectExceptionRunningNodesNotFound() throws Exception { - client.runScriptOnNodesMatching(runningWithTag("zebras-are-awesome"), buildScript(new OperatingSystemBuilder() + client.runScriptOnNodesMatching(runningInGroup("zebras-are-awesome"), buildScript(new OperatingSystemBuilder() .family(OsFamily.UBUNTU).description("ffoo").build())); } @@ -215,23 +215,23 @@ public abstract class BaseComputeServiceLiveTest { // starting this one alphabetically before create2nodes.. @Test(enabled = true, dependsOnMethods = { "testCompareSizes" }) public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception { - String tag = this.group + "r"; + String group = this.group + "r"; try { - client.destroyNodesMatching(withTag(tag)); + client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { } TemplateOptions options = client.templateOptions().blockOnPort(22, 120); try { - Set nodes = client.runNodesWithTag(tag, 1, options); + Set nodes = client.createNodesInGroup(group, 1, options); Credentials good = nodes.iterator().next().getCredentials(); assert good.identity != null : nodes; assert good.credential != null : nodes; OperatingSystem os = get(nodes, 0).getOperatingSystem(); try { - Map responses = runScriptWithCreds(tag, os, new Credentials( + Map responses = runScriptWithCreds(group, os, new Credentials( good.identity, "romeo")); assert false : "shouldn't pass with a bad password\n" + responses; } catch (RunScriptOnNodesException e) { @@ -239,17 +239,17 @@ public abstract class BaseComputeServiceLiveTest { } for (Entry response : client.runScriptOnNodesMatching( - runningWithTag(tag), Statements.exec("echo hello"), + runningInGroup(group), Statements.exec("echo hello"), overrideCredentialsWith(good).wrapInInitScript(false).runAsRoot(false)).entrySet()) assert response.getValue().getOutput().trim().equals("hello") : response.getKey() + ": " + response.getValue(); - runScriptWithCreds(tag, os, good); + runScriptWithCreds(group, os, good); - checkNodes(nodes, tag); + checkNodes(nodes, group); } finally { - client.destroyNodesMatching(withTag(tag)); + client.destroyNodesMatching(inGroup(group)); } } @@ -267,13 +267,13 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testCompareSizes") public void testCreateTwoNodesWithRunScript() throws Exception { try { - client.destroyNodesMatching(withTag(group)); + client.destroyNodesMatching(inGroup(group)); } catch (NoSuchElementException e) { } refreshTemplate(); try { - nodes = newTreeSet(client.runNodesWithTag(group, 2, template)); + nodes = newTreeSet(client.createNodesInGroup(group, 2, template)); } catch (RunNodesException e) { nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet())); throw e; @@ -324,7 +324,7 @@ public abstract class BaseComputeServiceLiveTest { public void testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired() throws Exception { initializeContextAndClient(); refreshTemplate(); - TreeSet nodes = newTreeSet(client.runNodesWithTag(group, 1, template)); + TreeSet nodes = newTreeSet(client.createNodesInGroup(group, 1, template)); checkNodes(nodes, group); NodeMetadata node = nodes.first(); this.nodes.add(node); @@ -340,21 +340,21 @@ public abstract class BaseComputeServiceLiveTest { assert (context.getCredentialStore().get("node#" + node.getId()) != null) : "credentials for " + node.getId(); } - protected Map runScriptWithCreds(final String tag, OperatingSystem os, + protected Map runScriptWithCreds(final String group, OperatingSystem os, Credentials creds) throws RunScriptOnNodesException { try { - return client.runScriptOnNodesMatching(runningWithTag(tag), buildScript(os), overrideCredentialsWith(creds) + return client.runScriptOnNodesMatching(runningInGroup(group), buildScript(os), overrideCredentialsWith(creds) .nameTask("runScriptWithCreds")); } catch (SshException e) { throw e; } } - protected void checkNodes(Iterable nodes, String tag) throws IOException { + protected void checkNodes(Iterable nodes, String group) throws IOException { for (NodeMetadata node : nodes) { assertNotNull(node.getProviderId()); - assertNotNull(node.getTag()); - assertEquals(node.getTag(), tag); + assertNotNull(node.getGroup()); + assertEquals(node.getGroup(), group); assertEquals(node.getState(), NodeState.RUNNING); Credentials fromStore = context.getCredentialStore().get("node#" + node.getId()); assertEquals(fromStore, node.getCredentials()); @@ -375,7 +375,7 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testCreateAnotherNodeWithANewContextToEnsureSharedMemIsntRequired") public void testGet() throws Exception { Map metadataMap = newLinkedHashMap(uniqueIndex(filter(client - .listNodesDetailsMatching(all()), and(withTag(group), not(TERMINATED))), + .listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))), new Function() { @Override @@ -388,7 +388,7 @@ public abstract class BaseComputeServiceLiveTest { metadataMap.remove(node.getId()); NodeMetadata metadata = client.getNodeMetadata(node.getId()); assertEquals(metadata.getProviderId(), node.getProviderId()); - assertEquals(metadata.getTag(), node.getTag()); + assertEquals(metadata.getGroup(), node.getGroup()); assertLocationSameOrChild(metadata.getLocation(), template.getLocation()); checkImageIdMatchesTemplate(metadata); checkOsMatchesTemplate(metadata); @@ -407,14 +407,14 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testGet") public void testReboot() throws Exception { - client.rebootNodesMatching(withTag(group));// TODO test + client.rebootNodesMatching(inGroup(group));// TODO test // validation testGet(); } @Test(enabled = true, dependsOnMethods = "testReboot") public void testSuspendResume() throws Exception { - client.suspendNodesMatching(withTag(group)); + client.suspendNodesMatching(inGroup(group)); Set stoppedNodes = refreshNodes(); @@ -430,7 +430,7 @@ public abstract class BaseComputeServiceLiveTest { }) : stoppedNodes; - client.resumeNodesMatching(withTag(group)); + client.resumeNodesMatching(inGroup(group)); testGet(); } @@ -467,24 +467,24 @@ public abstract class BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails" }) public void testDestroyNodes() { int toDestroy = refreshNodes().size(); - Set destroyed = client.destroyNodesMatching(withTag(group)); + Set destroyed = client.destroyNodesMatching(inGroup(group)); assertEquals(toDestroy, destroyed.size()); - for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), withTag(group))) { + for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) { assert node.getState() == NodeState.TERMINATED : node; assertEquals(context.getCredentialStore().get("node#" + node.getId()), null); } } private Set refreshNodes() { - return filter(client.listNodesDetailsMatching(all()), and(withTag(group), not(TERMINATED))); + return filter(client.listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))); } @Test(enabled = true) public void testCreateAndRunAService() throws Exception { - String tag = this.group + "s"; + String group = this.group + "s"; try { - client.destroyNodesMatching(withTag(tag)); + client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { } @@ -497,11 +497,11 @@ public abstract class BaseComputeServiceLiveTest { RunScriptData.createScriptInstallAndStartJBoss(keyPair.get("public"), template.getImage() .getOperatingSystem())); try { - NodeMetadata node = getOnlyElement(client.runNodesWithTag(tag, 1, template)); + NodeMetadata node = getOnlyElement(client.createNodesInGroup(group, 1, template)); checkHttpGet(node); } finally { - client.destroyNodesMatching(withTag(tag)); + client.destroyNodesMatching(inGroup(group)); } } @@ -554,9 +554,9 @@ public abstract class BaseComputeServiceLiveTest { } public void testOptionToNotBlock() throws Exception { - String tag = this.group + "block"; + String group = this.group + "block"; try { - client.destroyNodesMatching(withTag(tag)); + client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { } @@ -564,13 +564,13 @@ public abstract class BaseComputeServiceLiveTest { TemplateOptions options = client.templateOptions().blockUntilRunning(false).inboundPorts(); try { long time = System.currentTimeMillis(); - Set nodes = client.runNodesWithTag(tag, 1, options); + Set nodes = client.createNodesInGroup(group, 1, options); NodeMetadata node = getOnlyElement(nodes); assert node.getState() != NodeState.RUNNING; long duration = System.currentTimeMillis() - time; assert duration < 30 * 1000 : "duration longer than 30 seconds!: " + duration / 1000; } finally { - client.destroyNodesMatching(withTag(tag)); + client.destroyNodesMatching(inGroup(group)); } } diff --git a/core/src/main/java/org/jclouds/util/Utils.java b/core/src/main/java/org/jclouds/util/Utils.java index 23b75726b3..1d4a95d946 100644 --- a/core/src/main/java/org/jclouds/util/Utils.java +++ b/core/src/main/java/org/jclouds/util/Utils.java @@ -67,7 +67,6 @@ public class Utils { * @see Lists2#multiMax */ @Deprecated - @SuppressWarnings("unchecked") public static List multiMax(Comparator ordering, Iterable iterable) { return Lists2. multiMax(ordering, iterable); } @@ -86,7 +85,6 @@ public class Utils { * @see Throwables2#getFirstThrowableOfType(Throwable, Class) */ @Deprecated - @SuppressWarnings("unchecked") public static T getFirstThrowableOfType(Throwable from, Class clazz) { return Throwables2. getFirstThrowableOfType(from, clazz); } @@ -253,7 +251,6 @@ public class Utils { * @see Providers#resolveContextBuilderClass */ @Deprecated - @SuppressWarnings("unchecked") public static Class> resolveContextBuilderClass(String provider, Properties properties) throws ClassNotFoundException, IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { @@ -277,7 +274,6 @@ public class Utils { * @see Providers#resolvePropertiesBuilderClass */ @Deprecated - @SuppressWarnings("unchecked") public static Class resolvePropertiesBuilderClass(String providerName, Properties props) throws ClassNotFoundException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {