kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | d49ddcef7ef272d74bfd143ec2e890bdcb0594e42bce5cf58d2d3dbd6f9143c6 |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2015-11-04 21:16 -06:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-11-05 18:37 +01:00 |
| Parents | 8b3f03416ef1 |
1 file changed
modified driver-core/src/test/java/com/datastax/driver/core/ClusterInitTest.java +9 −0
| @@ -27,6 +27,7 @@ | ||
| 27 | 27 | import com.google.common.collect.ImmutableMap; |
| 28 | 28 | import com.google.common.collect.ImmutableSet; |
| 29 | 29 | import com.google.common.collect.Lists; |
| 30 | +import com.google.common.util.concurrent.Uninterruptibles; | |
| 30 | 31 | import org.scassandra.Scassandra; |
| 31 | 32 | import org.scassandra.http.client.PrimingClient; |
| 32 | 33 | import org.scassandra.http.client.PrimingRequest; |
| @@ -132,6 +133,14 @@ | ||
| 132 | 133 | // called and submit a task that marks the host down. |
| 133 | 134 | for (FakeHost failingHost : failingHosts) { |
| 134 | 135 | assertThat(cluster).host(failingHost.address).goesDownWithin(10, TimeUnit.SECONDS); |
| 136 | + Host host = TestUtils.findHost(cluster, failingHost.address); | |
| 137 | + // There is a possible race here in that the host is marked down in a separate Executor in onDown | |
| 138 | + // and then starts a periodic reconnection attempt shortly after. Since setDown is called before | |
| 139 | + // startPeriodicReconnectionAttempt, we add a slight delay here if the future isn't set yet. | |
| 140 | + if(host.getReconnectionAttemptFuture() == null || host.getReconnectionAttemptFuture().isDone()) { | |
| 141 | + logger.warn("Periodic Reconnection Attempt hasn't started yet for {}, waiting 1 second and then checking.", host); | |
| 142 | + Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); | |
| 143 | + } | |
| 135 | 144 | assertThat(cluster).host(failingHost.address).isReconnectingFromDown(); |
| 136 | 145 | } |
| 137 | 146 | assertThat(cluster).host(missingHostAddress).isNull(); |