waiting for node startup in live tests, timeout is increased for some tests

This commit is contained in:
Dmitri Babaev 2011-07-31 01:31:27 +04:00
parent e8dcfa5f52
commit 12aabec2a6
2 changed files with 12 additions and 10 deletions

View File

@ -38,6 +38,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import com.google.common.collect.Iterables;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
@ -135,13 +136,14 @@ public class ComputeBase {
computeService = context.getComputeService();
}
protected String awaitForPublicAddressAssigned(String nodeId) throws InterruptedException {
protected String awaitForStartup(String nodeId) throws InterruptedException {
while (true) {
Set<String> addresses = computeService.getNodeMetadata(nodeId).getPublicAddresses();
NodeMetadata metadata = computeService.getNodeMetadata(nodeId);
Set<String> addresses = metadata.getPublicAddresses();
System.out.println(addresses);
System.out.println(computeService.getNodeMetadata(nodeId).getState());
if (addresses != null)
if (!addresses.isEmpty()) return addresses.iterator().next();
System.out.println(metadata.getState());
if (metadata.getState() == NodeState.RUNNING && addresses != null && !addresses.isEmpty())
return addresses.iterator().next();
Thread.sleep(1000);
}
}

View File

@ -150,10 +150,10 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
.family(OsFamily.UBUNTU).description("ffoo").build()));
}
@Test(expectedExceptions = AuthorizationException.class, expectedExceptionsMessageRegExp = "Auth fail", timeOut = 120000)
@Test(expectedExceptions = AuthorizationException.class, expectedExceptionsMessageRegExp = "Auth fail", timeOut = 240000)
void testScriptExecutionWithWrongCredentials() throws Throwable, RunScriptOnNodesException, URISyntaxException, InterruptedException {
NodeMetadata node = getDefaultNodeImmediately(group);
String address = awaitForPublicAddressAssigned(node.getId());
String address = awaitForStartup(node.getId());
awaitForSshPort(address, new Credentials("root", keyPair.get("private")));
OperatingSystem os = node.getOperatingSystem();
try {
@ -165,11 +165,11 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
}
}
@Test(timeOut = 120000)
@Test(timeOut = 240000)
public void testScriptExecutionAfterBootWithBasicTemplate() throws InterruptedException, RunNodesException, RunScriptOnNodesException, URISyntaxException, IOException {
NodeMetadata node = getDefaultNodeImmediately(group);
String address = awaitForPublicAddressAssigned(node.getId());
String address = awaitForStartup(node.getId());
awaitForSshPort(address, new Credentials("root", keyPair.get("private")));
for (Map.Entry<? extends NodeMetadata, ExecResponse> response : computeService.runScriptOnNodesMatching(
runningInGroup(group), Statements.exec("echo hello"),
@ -267,7 +267,6 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
@Test(timeOut = 120000)
public void testGetNodeMetadata() throws Exception {
Set<NodeMetadata> nodes = Sets.newHashSet(getDefaultNodeImmediately(group));
awaitForPublicAddressAssigned(nodes.iterator().next().getId());
Map<String, ? extends NodeMetadata> metadataMap = newLinkedHashMap(uniqueIndex(filter(computeService
.listNodesDetailsMatching(all()), and(inGroup(group), not(TERMINATED))),
new Function<NodeMetadata, String>() {
@ -279,6 +278,7 @@ public class NovaComputeServiceLiveTest extends ComputeBase {
}));
for (NodeMetadata node : nodes) {
awaitForStartup(node.getId());
metadataMap.remove(node.getId());
NodeMetadata nodeMetadata = computeService.getNodeMetadata(node.getId());
assertEquals(parseGroupFromName(nodeMetadata.getName()), group);