kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | cb00b576ba31cd3ec699446df6d24c7efff6f6cc17a478eeef695fe09c8d2a55 |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2015-08-24 14:16 -05:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-08-28 11:24 +02:00 |
| Parents | ab7df558141e |
1 file changed
modified driver-core/src/test/java/com/datastax/driver/core/TimeoutStressTest.java +13 −6
| @@ -16,6 +16,7 @@ | ||
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | 18 | import com.datastax.driver.core.exceptions.NoHostAvailableException; |
| 19 | +import com.datastax.driver.core.policies.ConstantReconnectionPolicy; | |
| 19 | 20 | import com.datastax.driver.core.utils.SocketChannelMonitor; |
| 20 | 21 | import com.google.common.collect.Lists; |
| 21 | 22 | import com.google.common.util.concurrent.FutureCallback; |
| @@ -36,7 +37,7 @@ | ||
| 36 | 37 | import java.util.concurrent.atomic.AtomicBoolean; |
| 37 | 38 | import java.util.concurrent.atomic.AtomicInteger; |
| 38 | 39 | |
| 39 | -import static org.assertj.core.api.Assertions.assertThat; | |
| 40 | +import static com.datastax.driver.core.Assertions.assertThat; | |
| 40 | 41 | |
| 41 | 42 | public class TimeoutStressTest { |
| 42 | 43 | |
| @@ -73,9 +74,9 @@ | ||
| 73 | 74 | ccmBridge = CCMBridge.builder("test").withNodes(3).build(); |
| 74 | 75 | channelMonitor = new SocketChannelMonitor(); |
| 75 | 76 | nodes = Lists.newArrayList( |
| 76 | - new InetSocketAddress(CCMBridge.IP_PREFIX + '1', 9042), | |
| 77 | - new InetSocketAddress(CCMBridge.IP_PREFIX + '2', 9042), | |
| 78 | - new InetSocketAddress(CCMBridge.IP_PREFIX + '3', 9042) | |
| 77 | + new InetSocketAddress(CCMBridge.IP_PREFIX + '1', 9042), | |
| 78 | + new InetSocketAddress(CCMBridge.IP_PREFIX + '2', 9042), | |
| 79 | + new InetSocketAddress(CCMBridge.IP_PREFIX + '3', 9042) | |
| 79 | 80 | ); |
| 80 | 81 | |
| 81 | 82 | PoolingOptions poolingOptions = new PoolingOptions().setCoreConnectionsPerHost(HostDistance.LOCAL, 8); |
| @@ -84,6 +85,7 @@ | ||
| 84 | 85 | .addContactPointsWithPorts(nodes) |
| 85 | 86 | .withPoolingOptions(poolingOptions) |
| 86 | 87 | .withNettyOptions(channelMonitor.nettyOptions()) |
| 88 | + .withReconnectionPolicy(new ConstantReconnectionPolicy(1000)) | |
| 87 | 89 | .build(); |
| 88 | 90 | } |
| 89 | 91 | |
| @@ -178,13 +180,18 @@ | ||
| 178 | 180 | .setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS); |
| 179 | 181 | |
| 180 | 182 | logger.debug("Sleeping 20 seconds to allow connection reaper to clean up connections " + |
| 181 | - "and for the pools to recover."); | |
| 183 | + "and for the pools to recover."); | |
| 182 | 184 | Uninterruptibles.sleepUninterruptibly(20, TimeUnit.SECONDS); |
| 183 | 185 | |
| 184 | 186 | Collection<SocketChannel> openChannels = channelMonitor.openChannels(nodes); |
| 185 | 187 | assertThat(openChannels.size()) |
| 186 | 188 | .as("Number of open connections does not meet expected: %s", openChannels) |
| 187 | - .isEqualTo(maxConnections); | |
| 189 | + .isLessThanOrEqualTo(maxConnections); | |
| 190 | + | |
| 191 | + // Each host should be in an up state. | |
| 192 | + assertThat(cluster).host(1).comesUpWithin(0, TimeUnit.SECONDS); | |
| 193 | + assertThat(cluster).host(2).comesUpWithin(0, TimeUnit.SECONDS); | |
| 194 | + assertThat(cluster).host(3).comesUpWithin(0, TimeUnit.SECONDS); | |
| 188 | 195 | |
| 189 | 196 | session.close(); |
| 190 | 197 |