File tree Expand file tree Collapse file tree
driver-core/src/test/java/com/datastax/driver/core Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020import com .datastax .driver .core .policies .LoadBalancingPolicy ;
2121import org .assertj .core .api .AbstractAssert ;
2222
23+ import java .util .concurrent .Callable ;
2324import java .util .concurrent .CountDownLatch ;
2425import java .util .concurrent .TimeUnit ;
2526
27+ import static com .datastax .driver .core .ConditionChecker .check ;
2628import static org .assertj .core .api .Assertions .assertThat ;
2729import static org .assertj .core .api .Assertions .fail ;
2830
@@ -72,9 +74,18 @@ public HostAssert isInDatacenter(String datacenter) {
7274 }
7375
7476 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 ();
7889 }
7990
8091 public HostAssert comesUpWithin (long duration , TimeUnit unit ) {
You can’t perform that action at this time.
0 commit comments