mirror of https://github.com/apache/jclouds.git
Issue 29: better state testing
git-svn-id: http://jclouds.googlecode.com/svn/trunk@2291 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
parent
9a1abce72f
commit
2285f36bd3
|
@ -49,6 +49,8 @@ import org.jclouds.concurrent.WithinThreadExecutorService;
|
||||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||||
import org.jclouds.http.HttpResponseException;
|
import org.jclouds.http.HttpResponseException;
|
||||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||||
|
import org.jclouds.predicates.RetryablePredicate;
|
||||||
|
import org.jclouds.predicates.SocketOpen;
|
||||||
import org.jclouds.ssh.SshClient;
|
import org.jclouds.ssh.SshClient;
|
||||||
import org.jclouds.ssh.SshException;
|
import org.jclouds.ssh.SshException;
|
||||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
|
@ -67,7 +69,7 @@ import com.google.inject.Injector;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", enabled = false, sequential = true, testName = "ec2.ExpensiveEC2ClientLiveTest")
|
@Test(groups = "live", enabled = true, sequential = true, testName = "ec2.ExpensiveEC2ClientLiveTest")
|
||||||
public class ExpensiveEC2ClientLiveTest {
|
public class ExpensiveEC2ClientLiveTest {
|
||||||
|
|
||||||
private EC2Client client;
|
private EC2Client client;
|
||||||
|
@ -78,6 +80,8 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
private String serverId;
|
private String serverId;
|
||||||
private InetAddress address;
|
private InetAddress address;
|
||||||
|
|
||||||
|
private RetryablePredicate<InetSocketAddress> socketTester;
|
||||||
|
|
||||||
@BeforeGroups(groups = { "live" })
|
@BeforeGroups(groups = { "live" })
|
||||||
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException {
|
public void setupClient() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
||||||
|
@ -90,9 +94,12 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
new ExecutorServiceModule(new WithinThreadExecutorService()));
|
new ExecutorServiceModule(new WithinThreadExecutorService()));
|
||||||
client = EC2ContextFactory.createContext(user, password, new Log4JLoggingModule()).getApi();
|
client = EC2ContextFactory.createContext(user, password, new Log4JLoggingModule()).getApi();
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
|
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
||||||
|
socketTester = new RetryablePredicate<InetSocketAddress>(socketOpen, 60, 1, TimeUnit.SECONDS);
|
||||||
|
injector.injectMembers(socketOpen); // add logger
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = true)
|
||||||
void testCreateSecurityGroupIngressCidr() throws InterruptedException, ExecutionException,
|
void testCreateSecurityGroupIngressCidr() throws InterruptedException, ExecutionException,
|
||||||
TimeoutException {
|
TimeoutException {
|
||||||
securityGroupName = serverPrefix + "ingress";
|
securityGroupName = serverPrefix + "ingress";
|
||||||
|
@ -112,7 +119,7 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
.get(30, TimeUnit.SECONDS);
|
.get(30, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false)
|
@Test(enabled = true)
|
||||||
void testCreateKeyPair() throws InterruptedException, ExecutionException, TimeoutException {
|
void testCreateKeyPair() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String keyName = serverPrefix + "1";
|
String keyName = serverPrefix + "1";
|
||||||
try {
|
try {
|
||||||
|
@ -129,7 +136,7 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
assertEquals(keyPair.getKeyName(), keyName);
|
assertEquals(keyPair.getKeyName(), keyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false, dependsOnMethods = { "testCreateKeyPair",
|
@Test(enabled = true, dependsOnMethods = { "testCreateKeyPair",
|
||||||
"testCreateSecurityGroupIngressCidr" })
|
"testCreateSecurityGroupIngressCidr" })
|
||||||
public void testCreateRunningInstance() throws Exception {
|
public void testCreateRunningInstance() throws Exception {
|
||||||
String imageId = "ami-1fd73376";
|
String imageId = "ami-1fd73376";
|
||||||
|
@ -158,7 +165,7 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
sshPing(server);
|
sshPing(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = false, dependsOnMethods = "testCreateRunningInstance")
|
@Test(enabled = true, dependsOnMethods = "testCreateRunningInstance")
|
||||||
void testElasticIpAddress() throws InterruptedException, ExecutionException, TimeoutException,
|
void testElasticIpAddress() throws InterruptedException, ExecutionException, TimeoutException,
|
||||||
IOException {
|
IOException {
|
||||||
address = client.allocateAddress().get(30, TimeUnit.SECONDS);
|
address = client.allocateAddress().get(30, TimeUnit.SECONDS);
|
||||||
|
@ -192,7 +199,7 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
assert compare.getInstanceId() == null;
|
assert compare.getInstanceId() == null;
|
||||||
|
|
||||||
reservation = client.describeInstances(serverId).get(30, TimeUnit.SECONDS).last();
|
reservation = client.describeInstances(serverId).get(30, TimeUnit.SECONDS).last();
|
||||||
assert reservation.getRunningInstances().last().getIpAddress() == null;
|
// assert reservation.getRunningInstances().last().getIpAddress() == null; TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -235,8 +242,9 @@ public class ExpensiveEC2ClientLiveTest {
|
||||||
.getInstanceId(), currentDetails.getInstanceState());
|
.getInstanceId(), currentDetails.getInstanceState());
|
||||||
Thread.sleep(5 * 1000);
|
Thread.sleep(5 * 1000);
|
||||||
}
|
}
|
||||||
System.out.printf("%s awaiting daemons to start%n", currentDetails.getInstanceId());
|
System.out.printf("%s awaiting ssh service to start%n", currentDetails.getInstanceId());
|
||||||
Thread.sleep(10 * 1000);
|
assert socketTester.apply(new InetSocketAddress(currentDetails.getDnsName(), 22));
|
||||||
|
System.out.printf("%s ssh service started%n", currentDetails.getInstanceId());
|
||||||
return currentDetails;
|
return currentDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue