Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JAVA-2654: Make AdminRequestHandler handle integer serialization
- Loading branch information
1 parent
2ac7f83
commit 2027e27
Showing
6 changed files
with
110 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
integration-tests/src/test/java/com/datastax/oss/driver/core/PeersV2NodeRefreshIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright DataStax, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.datastax.oss.driver.core; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.datastax.oss.driver.api.core.CqlSession; | ||
import com.datastax.oss.driver.api.core.metadata.EndPoint; | ||
import com.datastax.oss.driver.api.core.metadata.Node; | ||
import com.datastax.oss.driver.categories.ParallelizableTests; | ||
import com.datastax.oss.driver.internal.core.context.InternalDriverContext; | ||
import com.datastax.oss.protocol.internal.request.Query; | ||
import com.datastax.oss.simulacron.common.cluster.ClusterSpec; | ||
import com.datastax.oss.simulacron.common.cluster.QueryLog; | ||
import com.datastax.oss.simulacron.server.BoundCluster; | ||
import com.datastax.oss.simulacron.server.Server; | ||
import java.util.concurrent.ExecutionException; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.junit.experimental.categories.Category; | ||
|
||
/** Test for JAVA-2654. */ | ||
@Category(ParallelizableTests.class) | ||
public class PeersV2NodeRefreshIT { | ||
|
||
private static Server peersV2Server; | ||
private static BoundCluster cluster; | ||
|
||
@BeforeClass | ||
public static void setup() { | ||
peersV2Server = Server.builder().withMultipleNodesPerIp(true).build(); | ||
cluster = peersV2Server.register(ClusterSpec.builder().withNodes(2)); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDown() { | ||
cluster.stop(); | ||
peersV2Server.close(); | ||
} | ||
|
||
@Test | ||
public void should_successfully_send_peers_v2_node_refresh_query() | ||
throws InterruptedException, ExecutionException { | ||
CqlSession session = | ||
CqlSession.builder().addContactPoint(cluster.node(1).inetSocketAddress()).build(); | ||
Node node = findNonControlNode(session); | ||
((InternalDriverContext) session.getContext()) | ||
.getMetadataManager() | ||
.refreshNode(node) | ||
.toCompletableFuture() | ||
.get(); | ||
assertThat(hasNodeRefreshQuery()) | ||
.describedAs("Expecting peers_v2 node refresh query to be present but it wasn't") | ||
.isTrue(); | ||
} | ||
|
||
private Node findNonControlNode(CqlSession session) { | ||
EndPoint controlNode = | ||
((InternalDriverContext) session.getContext()) | ||
.getControlConnection() | ||
.channel() | ||
.getEndPoint(); | ||
return session.getMetadata().getNodes().values().stream() | ||
.filter(node -> !node.getEndPoint().equals(controlNode)) | ||
.findAny() | ||
.orElseThrow(() -> new IllegalStateException("Expecting at least one non-control node")); | ||
} | ||
|
||
private boolean hasNodeRefreshQuery() { | ||
for (QueryLog log : cluster.getLogs().getQueryLogs()) { | ||
if (log.getFrame().message instanceof Query) { | ||
if (((Query) log.getFrame().message) | ||
.query.contains( | ||
"SELECT * FROM system.peers_v2 WHERE peer = :address and peer_port = :port")) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters