kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | e64fa6054060286785a223794421f7981120e4a65541b5aa0673e30e7166e7e5 |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2016-04-26 13:37 -05:00 |
| Committer | Andrew Tolbert <andrew.tolbert@datastax.com> · 2016-04-26 13:37 -05:00 |
| Parents | d76375dddc36 |
1 file changed
modified driver-core/src/test/java/com/datastax/driver/core/HostAssert.java +14 −3
| @@ -20,9 +20,11 @@ | ||
| 20 | 20 | import com.datastax.driver.core.policies.LoadBalancingPolicy; |
| 21 | 21 | import org.assertj.core.api.AbstractAssert; |
| 22 | 22 | |
| 23 | +import java.util.concurrent.Callable; | |
| 23 | 24 | import java.util.concurrent.CountDownLatch; |
| 24 | 25 | import java.util.concurrent.TimeUnit; |
| 25 | 26 | |
| 27 | +import static com.datastax.driver.core.ConditionChecker.check; | |
| 26 | 28 | import static org.assertj.core.api.Assertions.assertThat; |
| 27 | 29 | import static org.assertj.core.api.Assertions.fail; |
| 28 | 30 | |
| @@ -72,9 +74,18 @@ | ||
| 72 | 74 | } |
| 73 | 75 | |
| 74 | 76 | public HostAssert isNotReconnectingFromDown() { |
| 75 | - assertThat(actual.getReconnectionAttemptFuture() != null && !actual.getReconnectionAttemptFuture().isDone()) | |
| 76 | - .isFalse(); | |
| 77 | - return this; | |
| 77 | + // Ensure that host is not attempting a reconnect. Because of JAVA-970 we cannot | |
| 78 | + // be sure that there is a race and another pool is created before the host is marked down so we | |
| 79 | + // check to see it stops after 30 seconds. | |
| 80 | + // TODO: Change this to check only once if JAVA-970 is fixed. | |
| 81 | + check().before(30, TimeUnit.SECONDS).that(new Callable<Boolean>() { | |
| 82 | + @Override | |
| 83 | + public Boolean call() throws Exception { | |
| 84 | + // Whether or not host is down and reconnection attempt is in progress. | |
| 85 | + return actual.getReconnectionAttemptFuture() != null && !actual.getReconnectionAttemptFuture().isDone(); | |
| 86 | + } | |
| 87 | + }).becomesFalse(); | |
| 88 | + return this.isDown(); | |
| 78 | 89 | } |
| 79 | 90 | |
| 80 | 91 | public HostAssert comesUpWithin(long duration, TimeUnit unit) { |