Skip to content

Commit d18546a

Browse files
author
Alexandre Dutra
committed
Fix failing test after JAVA-1035.
1 parent 20c2074 commit d18546a

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

driver-core/src/test/java/com/datastax/driver/core/TokenIntegrationTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,18 @@ private void checkRangesPerHost(String keyspace, int replicationFactor) {
284284
public void should_expose_tokens_per_host() {
285285
for (Host host : cluster.getMetadata().allHosts()) {
286286
assertThat(host.getTokens()).hasSize(numTokens);
287-
288287
// Check against the info in the system tables, which is a bit weak since it's exactly how the metadata is
289288
// constructed in the first place, but there's not much else we can do.
290289
// Note that this relies on all queries going to node 1, which is why we use a WhiteList LBP in setup().
291-
Row row = session.execute("select tokens from system.peers where peer = '" + host.getBroadcastAddress().getHostAddress() + "'").one();
292-
if (row == null)
290+
boolean isControlHost = host.getSocketAddress().equals(cluster.manager.controlConnection.connectionRef.get().address);
291+
Row row;
292+
if (isControlHost) {
293293
row = session.execute("select tokens from system.local").one();
294+
} else {
295+
// non-control hosts are populated from system.peers and their broadcast address should be known
296+
assertThat(host.getBroadcastAddress()).isNotNull();
297+
row = session.execute("select tokens from system.peers where peer = '" + host.getBroadcastAddress().getHostAddress() + "'").one();
298+
}
294299
Set<String> tokenStrings = row.getSet("tokens", String.class);
295300
assertThat(tokenStrings).hasSize(numTokens);
296301
Iterable<Token> tokensFromSystemTable = Iterables.transform(tokenStrings, new Function<String, Token>() {

0 commit comments

Comments
 (0)