Elffuss BraidHub

kikocis/java-driver public

Merge pull request #659 from datastax/various-test-fixes

Various integration test fixes
Changeset9c9a5537845d690335aec043f9e9c1e7dbe523886b1f450292c198361cdbdcdd
AuthorAlexandre Dutra <adutra@users.noreply.github.com> · 2016-05-02 14:18 +02:00
CommitterAlexandre Dutra <adutra@users.noreply.github.com> · 2016-05-02 14:18 +02:00
Parentsd76375dddc36, 78f817fd23f6

Browse the files at this changeset

3 files changed

modified driver-core/src/test/java/com/datastax/driver/core/CCMCache.java +3 −3
@@ -271,10 +271,10 @@
271271 // CCM nodes are started with -Xms500M -Xmx500M
272272 // and allocate up to 100MB non-heap memory in the general case,
273273 // to be conservative we treat 1 "slot" as 800Mb.
274- // We leave 2 slots out to avoid starving system memory,
274+ // We leave 3 slots out to avoid starving system memory,
275275 // and we pick a value with a minimum of 1 slot and a maximum of 8 slots.
276- // For example, an 8GB VM with ~6.5GB currently available heap will yield 6 slots ((6500/800) - 2 = 6).
277- long slotsAvailable = (freeMemoryMB / ONE_CCM_NODE_MB) - 2;
276+ // For example, an 8GB VM with ~6.5GB currently available heap will yield 5 slots ((6500/800) - 3 = 5).
277+ long slotsAvailable = (freeMemoryMB / ONE_CCM_NODE_MB) - 3;
278278 maximumWeight = Math.min(8, Math.max(1, slotsAvailable));
279279 } else {
280280 maximumWeight = Integer.parseInt(numberOfNodes);
modified driver-core/src/test/java/com/datastax/driver/core/HostAssert.java +14 −3
@@ -20,9 +20,11 @@
2020 import com.datastax.driver.core.policies.LoadBalancingPolicy;
2121 import org.assertj.core.api.AbstractAssert;
2222
23+import java.util.concurrent.Callable;
2324 import java.util.concurrent.CountDownLatch;
2425 import java.util.concurrent.TimeUnit;
2526
27+import static com.datastax.driver.core.ConditionChecker.check;
2628 import static org.assertj.core.api.Assertions.assertThat;
2729 import static org.assertj.core.api.Assertions.fail;
2830
@@ -72,9 +74,18 @@
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) {
modified driver-examples/osgi/pom.xml +15 −0
@@ -220,6 +220,21 @@
220220 </plugins>
221221 </build>
222222 </profile>
223+ <profile>
224+ <id>short</id>
225+ <properties>
226+ <test.groups>unit,short</test.groups>
227+ <test.skip>false</test.skip>
228+ </properties>
229+ </profile>
230+
231+ <profile>
232+ <id>long</id>
233+ <properties>
234+ <test.groups>unit,short,long</test.groups>
235+ <test.skip>false</test.skip>
236+ </properties>
237+ </profile>
223238 </profiles>
224239
225240 <licenses>