Elffuss BraidHub

kikocis/java-driver public

Update TimeoutStressTest to accomodate non-fully connected Pools.
Changesetcb00b576ba31cd3ec699446df6d24c7efff6f6cc17a478eeef695fe09c8d2a55
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2015-08-24 14:16 -05:00
Committerolim7t <omichallat+github@gmail.com> · 2015-08-28 11:24 +02:00
Parentsab7df558141e

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/TimeoutStressTest.java +13 −6
@@ -16,6 +16,7 @@
1616 package com.datastax.driver.core;
1717
1818 import com.datastax.driver.core.exceptions.NoHostAvailableException;
19+import com.datastax.driver.core.policies.ConstantReconnectionPolicy;
1920 import com.datastax.driver.core.utils.SocketChannelMonitor;
2021 import com.google.common.collect.Lists;
2122 import com.google.common.util.concurrent.FutureCallback;
@@ -36,7 +37,7 @@
3637 import java.util.concurrent.atomic.AtomicBoolean;
3738 import java.util.concurrent.atomic.AtomicInteger;
3839
39-import static org.assertj.core.api.Assertions.assertThat;
40+import static com.datastax.driver.core.Assertions.assertThat;
4041
4142 public class TimeoutStressTest {
4243
@@ -73,9 +74,9 @@
7374 ccmBridge = CCMBridge.builder("test").withNodes(3).build();
7475 channelMonitor = new SocketChannelMonitor();
7576 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)
7980 );
8081
8182 PoolingOptions poolingOptions = new PoolingOptions().setCoreConnectionsPerHost(HostDistance.LOCAL, 8);
@@ -84,6 +85,7 @@
8485 .addContactPointsWithPorts(nodes)
8586 .withPoolingOptions(poolingOptions)
8687 .withNettyOptions(channelMonitor.nettyOptions())
88+ .withReconnectionPolicy(new ConstantReconnectionPolicy(1000))
8789 .build();
8890 }
8991
@@ -178,13 +180,18 @@
178180 .setReadTimeoutMillis(SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS);
179181
180182 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.");
182184 Uninterruptibles.sleepUninterruptibly(20, TimeUnit.SECONDS);
183185
184186 Collection<SocketChannel> openChannels = channelMonitor.openChannels(nodes);
185187 assertThat(openChannels.size())
186188 .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);
188195
189196 session.close();
190197