Elffuss BraidHub

kikocis/java-driver public

Make ClusterInitTest more resilient by waiting for hosts to go down.

ClusterInitTest#should_handle_failing_or_missing_contact_points
previously checked to see if hosts were marked down, but its not
guaranteed that all expected hosts are marked down at this time as
onDown is submitted in an executor and may not have been
processed/finished.
Changeset3981e916b2aac273ea2a454fa879a405006a8c6285a4e0c997c76f21115d68f8
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-10-26 13:34 -05:00
CommitterAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-11-04 15:03 -06:00
Parents659a94ae9fce

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/ClusterInitTest.java +7 −7
@@ -41,12 +41,10 @@
4141
4242 import com.datastax.driver.core.exceptions.NoHostAvailableException;
4343 import com.datastax.driver.core.policies.ConstantReconnectionPolicy;
44-import com.datastax.driver.core.utils.CassandraVersion;
4544
46-import static com.datastax.driver.core.Assertions.*;
45+import static com.datastax.driver.core.Assertions.assertThat;
46+import static com.datastax.driver.core.Assertions.fail;
4747 import static com.datastax.driver.core.FakeHost.Behavior.THROWING_CONNECT_TIMEOUTS;
48-import static com.datastax.driver.core.Host.State.DOWN;
49-import static com.datastax.driver.core.Host.State.UP;
5048 import static com.datastax.driver.core.HostDistance.LOCAL;
5149 import static com.datastax.driver.core.TestUtils.nonDebouncingQueryOptions;
5250
@@ -58,7 +56,6 @@
5856 * causing timeouts, we want to ensure that the driver does not wait multiple times on the same host.
5957 */
6058 @Test(groups = "short")
61- @CassandraVersion(major=2.0, description = "Scassandra currently broken with protocol version 1.")
6259 public void should_handle_failing_or_missing_contact_points() throws UnknownHostException {
6360 Cluster cluster = null;
6461 Scassandra scassandra = null;
@@ -128,9 +125,12 @@
128125 verify(socketOptions, atLeast(6)).getKeepAlive();
129126 verify(socketOptions, atMost(7)).getKeepAlive();
130127
131- assertThat(cluster).host(realHostAddress).isNotNull().hasState(UP);
128+ assertThat(cluster).host(realHostAddress).isNotNull().isUp();
129+ // It is likely but not guaranteed that a host is marked down at this point.
130+ // It should eventually be marked down as Cluster.Manager.triggerOnDown should be
131+ // called and submit a task that marks the host down.
132132 for (FakeHost failingHost : failingHosts) {
133- assertThat(cluster).host(failingHost.address).hasState(DOWN);
133+ assertThat(cluster).host(failingHost.address).goesDownWithin(10, TimeUnit.SECONDS);
134134 assertThat(cluster).host(failingHost.address).isReconnectingFromDown();
135135 }
136136 assertThat(cluster).host(missingHostAddress).isNull();