Elffuss BraidHub

kikocis/java-driver public

Fix failing test after JAVA-1035.
Changeset542f59d6e0ecdccdb799ec3de77a933669f75a2f130099089ce87e375dcb4ee2
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-16 12:19 +01:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-16 12:19 +01:00
Parentsdfc873429762

Browse the files at this changeset

1 file changed

modified driver-core/src/test/java/com/datastax/driver/core/TokenIntegrationTest.java +8 −3
@@ -284,13 +284,18 @@
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>() {