From 07f1fb69a71c10767b9150b36d657d94f9f90263 Mon Sep 17 00:00:00 2001 From: Zack Shoylev Date: Wed, 18 Feb 2015 03:20:50 -0600 Subject: [PATCH] Fixes more tests with timing problems --- .../nova/v2_0/predicates/ServerPredicates.java | 15 ++++++++------- .../internal/BaseBlobSignerLiveTest.java | 8 ++++++++ .../internal/BaseComputeServiceLiveTest.java | 2 ++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java index d29f0819d8..21c5936a23 100644 --- a/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java +++ b/apis/openstack-nova/src/main/java/org/jclouds/openstack/nova/v2_0/predicates/ServerPredicates.java @@ -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; * */ 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 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 awaitShutoff(ServerApi serverApi) { - return awaitStatus(serverApi, SHUTOFF, TEN_MINUTES, FIVE_SECONDS); + return awaitStatus(serverApi, SHUTOFF, THIRTY_MINUTES, FIVE_SECONDS); } /** diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java index c1a0d051eb..2bee444012 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java @@ -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); + } + } } diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index bcf6107726..a0da138914 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -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 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 "