Fixes more tests with timing problems

This commit is contained in:
Zack Shoylev 2015-02-18 03:20:50 -06:00
parent 14d4ce635f
commit 07f1fb69a7
3 changed files with 18 additions and 7 deletions

View File

@ -16,10 +16,6 @@
*/
package org.jclouds.openstack.nova.v2_0.predicates;
import com.google.common.base.Predicate;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status;
@ -27,6 +23,11 @@ import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.ACTIVE;
import static org.jclouds.openstack.nova.v2_0.domain.Server.Status.SHUTOFF;
import static org.jclouds.util.Predicates2.retry;
import org.jclouds.openstack.nova.v2_0.domain.Server;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import com.google.common.base.Predicate;
/**
* This class tests to see if a Server or ServerCreated has reached a desired status. This class is most useful when
* paired with a RetryablePredicate as in the code below. Together these classes can be used to block execution until
@ -52,7 +53,7 @@ import static org.jclouds.util.Predicates2.retry;
* </pre>
*/
public class ServerPredicates {
private static final int TEN_MINUTES = 600;
private static final int THIRTY_MINUTES = 600 * 3;
private static final int FIVE_SECONDS = 5;
/**
@ -62,7 +63,7 @@ public class ServerPredicates {
* @return Predicate that will check the status every 5 seconds for a maximum of 10 minutes.
*/
public static Predicate<String> awaitActive(ServerApi serverApi) {
return awaitStatus(serverApi, ACTIVE, TEN_MINUTES, FIVE_SECONDS);
return awaitStatus(serverApi, ACTIVE, THIRTY_MINUTES, FIVE_SECONDS);
}
/**
@ -72,7 +73,7 @@ public class ServerPredicates {
* @return Predicate that will check the status every 5 seconds for a maximum of 10 minutes.
*/
public static Predicate<String> awaitShutoff(ServerApi serverApi) {
return awaitStatus(serverApi, SHUTOFF, TEN_MINUTES, FIVE_SECONDS);
return awaitStatus(serverApi, SHUTOFF, THIRTY_MINUTES, FIVE_SECONDS);
}
/**

View File

@ -24,6 +24,7 @@ import static org.testng.Assert.fail;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.jclouds.blobstore.attr.ConsistencyModel;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.AuthorizationException;
@ -169,6 +170,7 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
String container = getContainerName();
try {
view.getBlobStore().putBlob(container, blob);
awaitConsistency();
assertConsistencyAwareContainerSize(container, 1);
HttpRequest request = view.getSigner().signRemoveBlob(container, name);
assertEquals(request.getFilters().size(), 0);
@ -178,4 +180,10 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
returnContainer(container);
}
}
protected void awaitConsistency() {
if (view.getConsistencyModel() == ConsistencyModel.EVENTUAL) {
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
}
}
}

View File

@ -112,6 +112,7 @@ import com.google.common.net.HostAndPort;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.Uninterruptibles;
import com.google.inject.Key;
import com.google.inject.Module;
import com.google.inject.name.Names;
@ -650,6 +651,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
int toDestroy = refreshNodes().size();
Set<? extends NodeMetadata> destroyed = client.destroyNodesMatching(inGroup(group));
assertEquals(toDestroy, destroyed.size());
Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) {
assert node.getStatus() == Status.TERMINATED : node;
assert view.utils().credentialStore().get("node#" + node.getId()) == null : "credential should have been null for "