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