Skip to content

Commit

Permalink
JAVA-2612: Fix ProtocolVersionMixedClusterIT (scylladb#38)
Browse files Browse the repository at this point in the history
The control connection does not reconnect anymore when the protocol version 
is negotiated and downgraded, see JAVA-2473. This test was still expecting a
reconnection, and thus was failing since.
  • Loading branch information
tomekl007 authored and olim7t committed Jan 14, 2020
1 parent a3051b4 commit 6fa234d
Showing 1 changed file with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.datastax.oss.simulacron.server.BoundCluster;
import com.datastax.oss.simulacron.server.BoundNode;
import com.datastax.oss.simulacron.server.BoundTopic;
import java.net.InetSocketAddress;
import java.util.stream.Stream;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -66,19 +65,12 @@ public void should_downgrade_if_peer_does_not_support_negotiated_version() {
.build()) {

InternalDriverContext context = (InternalDriverContext) session.getContext();
// General version should have been downgraded to V3
assertThat(context.getProtocolVersion()).isEqualTo(DefaultProtocolVersion.V3);
// But control connection should still be using protocol V4 since node0 supports V4
assertThat(context.getControlConnection().channel().protocolVersion()).isEqualTo(DefaultProtocolVersion.V4);

// Find out which node became the control node after the reconnection (not necessarily node 0)
InetSocketAddress controlAddress =
(InetSocketAddress) context.getControlConnection().channel().getEndPoint().resolve();
BoundNode currentControlNode = null;
for (BoundNode node : simulacron.getNodes()) {
if (node.inetSocketAddress().equals(controlAddress)) {
currentControlNode = node;
}
}
assertThat(currentControlNode).isNotNull();
assertThat(queries(simulacron)).hasSize(8);
assertThat(queries(simulacron)).hasSize(4);

assertThat(protocolQueries(contactPoint, 4))
.containsExactly(
Expand All @@ -87,13 +79,6 @@ public void should_downgrade_if_peer_does_not_support_negotiated_version() {
"SELECT * FROM system.local",
"SELECT * FROM system.peers_v2",
"SELECT * FROM system.peers");
assertThat(protocolQueries(currentControlNode, 3))
.containsExactly(
// Reconnection with protocol v3
"SELECT cluster_name FROM system.local",
"SELECT * FROM system.local",
"SELECT * FROM system.peers_v2",
"SELECT * FROM system.peers");
}
}

Expand Down

0 comments on commit 6fa234d

Please sign in to comment.