You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by if...@apache.org on 2020/03/20 16:00:09 UTC
[cassandra-in-jvm-dtest-api] branch CASSANDRA-15539 updated:
[maven-release-plugin] prepare release dtest-api-0.0.2
This is an automated email from the ASF dual-hosted git repository.
ifesdjeen pushed a commit to branch CASSANDRA-15539
in repository https://gitbox.apache.org/repos/asf/cassandra-in-jvm-dtest-api.git
The following commit(s) were added to refs/heads/CASSANDRA-15539 by this push:
new 70a779c [maven-release-plugin] prepare release dtest-api-0.0.2
70a779c is described below
commit 70a779c9f7cd833a9e8f5e9b796b407428c76c5f
Author: Alex Petrov <ol...@gmail.com>
AuthorDate: Fri Mar 20 17:00:06 2020 +0100
[maven-release-plugin] prepare release dtest-api-0.0.2
---
pom.xml | 4 +-
.../cassandra/distributed/test/BootstrapTest.java | 98 ----------
.../distributed/test/GossipSettlesTest.java | 43 -----
.../distributed/test/MessageFiltersTest.java | 132 -------------
.../distributed/test/NativeProtocolTest.java | 81 --------
.../distributed/test/NetworkTopologyTest.java | 98 ----------
.../distributed/test/SimpleReadWriteTest.java | 210 ---------------------
7 files changed, 2 insertions(+), 664 deletions(-)
diff --git a/pom.xml b/pom.xml
index 10bf63d..c22bcdc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.cassandra</groupId>
<artifactId>dtest-api</artifactId>
- <version>0.0.2-SNAPSHOT</version>
+ <version>0.0.2</version>
<name>In JVM Test API</name>
<description>In JVM Test API</description>
@@ -93,7 +93,7 @@
<connection>scm:git:https://gitbox.apache.org/repos/asf/cassandra-in-jvm-dtest-api.git</connection>
<developerConnection>scm:git:https://gitbox.apache.org/repos/asf/cassandra-in-jvm-dtest-api.git</developerConnection>
<url>git@github.com:apache/cassandra-in-jvm-dtests.git</url>
- <tag>HEAD</tag>
+ <tag>dtest-api-0.0.2</tag>
</scm>
</project>
diff --git a/src/test/java/org/apache/cassandra/distributed/test/BootstrapTest.java b/src/test/java/org/apache/cassandra/distributed/test/BootstrapTest.java
deleted file mode 100644
index 79f5191..0000000
--- a/src/test/java/org/apache/cassandra/distributed/test/BootstrapTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cassandra.distributed.test;
-
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import org.apache.cassandra.distributed.api.ConsistencyLevel;
-import org.apache.cassandra.distributed.api.ICluster;
-import org.apache.cassandra.distributed.api.IInstance;
-import org.apache.cassandra.distributed.api.IInstanceConfig;
-import org.apache.cassandra.distributed.api.TokenSupplier;
-import org.apache.cassandra.distributed.api.IInvokableInstance;
-import org.apache.cassandra.distributed.shared.Builder;
-import org.apache.cassandra.distributed.shared.NetworkTopology;
-
-import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
-import static org.apache.cassandra.distributed.api.Feature.NETWORK;
-
-public class BootstrapTest extends TestBaseImpl
-{
- @Test
- public void bootstrapTest() throws Throwable
- {
- int originalNodeCount = 2;
- int expandedNodeCount = originalNodeCount + 1;
- Builder<IInstance, ICluster> builder = builder().withNodes(originalNodeCount)
- .withTokenSupplier(TokenSupplier.evenlyDistributedTokens(expandedNodeCount))
- .withNodeIdTopology(NetworkTopology.singleDcNetworkTopology(originalNodeCount, "dc0", "rack0"))
- .withConfig(config -> config.with(NETWORK, GOSSIP));
-
- Map<Integer, Long> withBootstrap = null;
- Map<Integer, Long> naturally = null;
- try (ICluster<IInvokableInstance> cluster = builder.withNodes(originalNodeCount).start())
- {
- populate(cluster);
-
- IInstanceConfig config = builder.withNodeIdTopology(NetworkTopology.singleDcNetworkTopology(expandedNodeCount, "dc0", "rack0"))
- .newInstanceConfig(cluster);
- config.set("auto_bootstrap", true);
-
- cluster.bootstrap(config).startup();
- withBootstrap = count(cluster);
- }
-
- builder = builder.withNodes(expandedNodeCount)
- .withTokenSupplier(TokenSupplier.evenlyDistributedTokens(expandedNodeCount))
- .withConfig(config -> config.with(NETWORK, GOSSIP));
-
- try (ICluster cluster = builder.start())
- {
- populate(cluster);
- naturally = count(cluster);
- }
-
- for (Map.Entry<Integer, Long> e : withBootstrap.entrySet())
- Assert.assertTrue(e.getValue() >= naturally.get(e.getKey()));
- }
-
- public void populate(ICluster cluster)
- {
- cluster.schemaChange("CREATE KEYSPACE " + KEYSPACE + " WITH replication = {'class': 'SimpleStrategy', 'replication_factor': " + 3 + "};");
- cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
-
- for (int i = 0; i < 1000; i++)
- cluster.coordinator(1).execute("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (?, ?, ?)",
- ConsistencyLevel.QUORUM,
- i, i, i);
- }
-
- public Map<Integer, Long> count(ICluster cluster)
- {
- return IntStream.rangeClosed(1, cluster.size())
- .boxed()
- .collect(Collectors.toMap(nodeId -> nodeId,
- nodeId -> (Long) cluster.get(nodeId).executeInternal("SELECT count(*) FROM " + KEYSPACE + ".tbl")[0][0]));
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/cassandra/distributed/test/GossipSettlesTest.java b/src/test/java/org/apache/cassandra/distributed/test/GossipSettlesTest.java
deleted file mode 100644
index e3d3c68..0000000
--- a/src/test/java/org/apache/cassandra/distributed/test/GossipSettlesTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cassandra.distributed.test;
-
-import org.junit.Test;
-
-import org.apache.cassandra.distributed.api.ICluster;
-
-import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
-import static org.apache.cassandra.distributed.api.Feature.NETWORK;
-
-public class GossipSettlesTest extends TestBaseImpl
-{
-
- @Test
- public void testGossipSettles() throws Throwable
- {
- /* Use withSubnet(1) to prove seed provider is set correctly - without the fix to pass a seed provider, this test fails */
- try (ICluster cluster = builder().withNodes(3)
- .withConfig(config -> config.with(GOSSIP).with(NETWORK))
- .withSubnet(1)
- .start())
- {
- }
- }
-
-}
diff --git a/src/test/java/org/apache/cassandra/distributed/test/MessageFiltersTest.java b/src/test/java/org/apache/cassandra/distributed/test/MessageFiltersTest.java
deleted file mode 100644
index 2241ed4..0000000
--- a/src/test/java/org/apache/cassandra/distributed/test/MessageFiltersTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cassandra.distributed.test;
-
-import org.apache.cassandra.distributed.api.IMessage;
-import org.apache.cassandra.distributed.api.IMessageFilters;
-import org.apache.cassandra.distributed.shared.MessageFilters;
-import org.junit.Assert;
-import org.junit.Test;
-
-import java.net.InetSocketAddress;
-import java.util.Arrays;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class MessageFiltersTest
-{
- @Test
- public void simpleInboundFiltersTest()
- {
- simpleFiltersTest(true);
- }
-
- @Test
- public void simpleOutboundFiltersTest()
- {
- simpleFiltersTest(false);
- }
-
- private interface Permit
- {
- boolean test(int from, int to, IMessage msg);
- }
-
- private void simpleFiltersTest(boolean inbound)
- {
- int VERB1 = 1;
- int VERB2 = 2;
- int VERB3 = 3;
- int i1 = 1;
- int i2 = 2;
- int i3 = 3;
- String MSG1 = "msg1";
- String MSG2 = "msg2";
-
- MessageFilters filters = new MessageFilters();
- Permit permit = inbound ? filters::permitInbound : filters::permitOutbound;
-
- IMessageFilters.Filter filter = filters.allVerbs().inbound(inbound).from(1).drop();
- Assert.assertFalse(permit.test(i1, i2, msg(VERB1, MSG1)));
- Assert.assertFalse(permit.test(i1, i2, msg(VERB2, MSG1)));
- Assert.assertFalse(permit.test(i1, i2, msg(VERB3, MSG1)));
- Assert.assertTrue(permit.test(i2, i1, msg(VERB1, MSG1)));
- filter.off();
- Assert.assertTrue(permit.test(i1, i2, msg(VERB1, MSG1)));
- filters.reset();
-
- filters.verbs(VERB1).inbound(inbound).from(1).to(2).drop();
- Assert.assertFalse(permit.test(i1, i2, msg(VERB1, MSG1)));
- Assert.assertTrue(permit.test(i1, i2, msg(VERB2, MSG1)));
- Assert.assertTrue(permit.test(i2, i1, msg(VERB1, MSG1)));
- Assert.assertTrue(permit.test(i2, i3, msg(VERB2, MSG1)));
-
- filters.reset();
- AtomicInteger counter = new AtomicInteger();
- filters.verbs(VERB1).inbound(inbound).from(1).to(2).messagesMatching((from, to, msg) -> {
- counter.incrementAndGet();
- return Arrays.equals(msg.bytes(), MSG1.getBytes());
- }).drop();
- Assert.assertFalse(permit.test(i1, i2, msg(VERB1, MSG1)));
- Assert.assertEquals(counter.get(), 1);
- Assert.assertTrue(permit.test(i1, i2, msg(VERB1, MSG2)));
- Assert.assertEquals(counter.get(), 2);
-
- // filter chain gets interrupted because a higher level filter returns no match
- Assert.assertTrue(permit.test(i2, i1, msg(VERB1, MSG1)));
- Assert.assertEquals(counter.get(), 2);
- Assert.assertTrue(permit.test(i2, i1, msg(VERB2, MSG1)));
- Assert.assertEquals(counter.get(), 2);
- filters.reset();
-
- filters.allVerbs().inbound(inbound).from(3, 2).to(2, 1).drop();
- Assert.assertFalse(permit.test(i3, i1, msg(VERB1, MSG1)));
- Assert.assertFalse(permit.test(i3, i2, msg(VERB1, MSG1)));
- Assert.assertFalse(permit.test(i2, i1, msg(VERB1, MSG1)));
- Assert.assertTrue(permit.test(i2, i3, msg(VERB1, MSG1)));
- Assert.assertTrue(permit.test(i1, i2, msg(VERB1, MSG1)));
- Assert.assertTrue(permit.test(i1, i3, msg(VERB1, MSG1)));
- filters.reset();
-
- counter.set(0);
- filters.allVerbs().inbound(inbound).from(1).to(2).messagesMatching((from, to, msg) -> {
- counter.incrementAndGet();
- return false;
- }).drop();
- Assert.assertTrue(permit.test(i1, i2, msg(VERB1, MSG1)));
- Assert.assertTrue(permit.test(i1, i3, msg(VERB1, MSG1)));
- Assert.assertTrue(permit.test(i1, i2, msg(VERB1, MSG1)));
- Assert.assertEquals(2, counter.get());
- }
-
- IMessage msg(int verb, String msg)
- {
- return new IMessage()
- {
- public int verb() { return verb; }
- public byte[] bytes() { return msg.getBytes(); }
- public int id() { return 0; }
- public int version() { return 0; }
- public InetSocketAddress from() { return null; }
- public int fromPort()
- {
- return 0;
- }
- };
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/cassandra/distributed/test/NativeProtocolTest.java b/src/test/java/org/apache/cassandra/distributed/test/NativeProtocolTest.java
deleted file mode 100644
index 2bbe2a9..0000000
--- a/src/test/java/org/apache/cassandra/distributed/test/NativeProtocolTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cassandra.distributed.test;
-
-import org.apache.cassandra.distributed.impl.RowUtil;
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.datastax.driver.core.ConsistencyLevel;
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Session;
-import com.datastax.driver.core.SimpleStatement;
-import com.datastax.driver.core.Statement;
-import org.apache.cassandra.distributed.api.ICluster;
-
-import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
-import static org.apache.cassandra.distributed.api.Feature.NATIVE_PROTOCOL;
-import static org.apache.cassandra.distributed.api.Feature.NETWORK;
-
-import static org.apache.cassandra.distributed.shared.AssertUtils.*;
-
-public class NativeProtocolTest extends TestBaseImpl
-{
-
- @Test
- public void withClientRequests() throws Throwable
- {
- try (ICluster ignored = init(builder().withNodes(3)
- .withConfig(config -> config.with(GOSSIP, NETWORK, NATIVE_PROTOCOL))
- .start()))
- {
-
- try (com.datastax.driver.core.Cluster cluster = com.datastax.driver.core.Cluster.builder().addContactPoint("127.0.0.1").build();
- Session session = cluster.connect())
- {
- session.execute("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck));");
- session.execute("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) values (1,1,1);");
- Statement select = new SimpleStatement("select * from " + KEYSPACE + ".tbl;").setConsistencyLevel(ConsistencyLevel.ALL);
- final ResultSet resultSet = session.execute(select);
- assertRows(RowUtil.toObjects(resultSet), row(1, 1, 1));
- Assert.assertEquals(3, cluster.getMetadata().getAllHosts().size());
- }
- }
- }
-
- @Test
- public void withCounters() throws Throwable
- {
- try (ICluster ignored = init(builder().withNodes(3)
- .withConfig(config -> config.with(GOSSIP, NETWORK, NATIVE_PROTOCOL))
- .start()))
- {
- final com.datastax.driver.core.Cluster cluster = com.datastax.driver.core.Cluster.builder().addContactPoint("127.0.0.1").build();
- Session session = cluster.connect();
- session.execute("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck counter, PRIMARY KEY (pk));");
- session.execute("UPDATE " + KEYSPACE + ".tbl set ck = ck + 10 where pk = 1;");
- Statement select = new SimpleStatement("select * from " + KEYSPACE + ".tbl;").setConsistencyLevel(ConsistencyLevel.ALL);
- final ResultSet resultSet = session.execute(select);
- assertRows(RowUtil.toObjects(resultSet), row(1, 10L));
- Assert.assertEquals(3, cluster.getMetadata().getAllHosts().size());
- session.close();
- cluster.close();
- }
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/cassandra/distributed/test/NetworkTopologyTest.java b/src/test/java/org/apache/cassandra/distributed/test/NetworkTopologyTest.java
deleted file mode 100644
index 53154e3..0000000
--- a/src/test/java/org/apache/cassandra/distributed/test/NetworkTopologyTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cassandra.distributed.test;
-
-import java.util.Collections;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import org.apache.cassandra.distributed.api.ICluster;
-import org.apache.cassandra.distributed.api.IInstance;
-import org.apache.cassandra.distributed.api.IInvokableInstance;
-import org.apache.cassandra.distributed.shared.NetworkTopology;
-
-public class NetworkTopologyTest extends TestBaseImpl
-{
- @Test
- public void namedDcTest() throws Throwable
- {
- try (ICluster<IInvokableInstance> cluster = builder()
- .withNodeIdTopology(Collections.singletonMap(1, NetworkTopology.dcAndRack("somewhere", "rack0")))
- .withRack("elsewhere", "firstrack", 1)
- .withRack("elsewhere", "secondrack", 2)
- .withDC("nearthere", 4)
- .start())
- {
- Assert.assertEquals(1, cluster.stream("somewhere").count());
- Assert.assertEquals(1, cluster.stream("elsewhere", "firstrack").count());
- Assert.assertEquals(2, cluster.stream("elsewhere", "secondrack").count());
- Assert.assertEquals(3, cluster.stream("elsewhere").count());
- Assert.assertEquals(4, cluster.stream("nearthere").count());
-
- Set<IInstance> expect = cluster.stream().collect(Collectors.toSet());
- Set<IInstance> result = Stream.concat(Stream.concat(cluster.stream("somewhere"),
- cluster.stream("elsewhere")),
- cluster.stream("nearthere")).collect(Collectors.toSet());
- Assert.assertEquals(expect, result);
- }
- }
-
- @Test
- public void automaticNamedDcTest() throws Throwable
-
- {
- try (ICluster cluster = builder()
- .withRacks(2, 1, 3)
- .start())
- {
- Assert.assertEquals(6, cluster.stream().count());
- Assert.assertEquals(3, cluster.stream("datacenter1").count());
- Assert.assertEquals(3, cluster.stream("datacenter2", "rack1").count());
- }
- }
-
- @Test(expected = IllegalStateException.class)
- public void noCountsAfterNamingDCsTest()
- {
- builder().withDC("nameddc", 1)
- .withDCs(1);
- }
-
- @Test(expected = IllegalStateException.class)
- public void mustProvideNodeCountBeforeWithDCsTest()
- {
- builder().withDCs(1);
- }
-
- @Test(expected = IllegalStateException.class)
- public void noEmptyNodeIdTopologyTest()
- {
- builder().withNodeIdTopology(Collections.emptyMap());
- }
-
- @Test(expected = IllegalStateException.class)
- public void noHolesInNodeIdTopologyTest()
- {
- builder().withNodeIdTopology(Collections.singletonMap(2, NetworkTopology.dcAndRack("doomed", "rack")));
- }
-}
\ No newline at end of file
diff --git a/src/test/java/org/apache/cassandra/distributed/test/SimpleReadWriteTest.java b/src/test/java/org/apache/cassandra/distributed/test/SimpleReadWriteTest.java
deleted file mode 100644
index 4c4ef0f..0000000
--- a/src/test/java/org/apache/cassandra/distributed/test/SimpleReadWriteTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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 org.apache.cassandra.distributed.test;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import org.apache.cassandra.distributed.api.ConsistencyLevel;
-import org.apache.cassandra.distributed.api.ICluster;
-
-import static org.apache.cassandra.distributed.api.Feature.NETWORK;
-import static org.apache.cassandra.distributed.shared.AssertUtils.*;
-
-public class SimpleReadWriteTest extends TestBaseImpl
-{
- @Test
- public void coordinatorReadTest() throws Throwable
- {
- try (ICluster cluster = init(builder().withNodes(3).start()))
- {
- cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
-
- cluster.get(1).executeInternal("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, 1, 1)");
- cluster.get(2).executeInternal("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, 2, 2)");
- cluster.get(3).executeInternal("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, 3, 3)");
-
- assertRows(cluster.coordinator(1).execute("SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = ?",
- ConsistencyLevel.ALL,
- 1),
- row(1, 1, 1),
- row(1, 2, 2),
- row(1, 3, 3));
- }
- }
-
- @Test
- public void coordinatorWriteTest() throws Throwable
- {
- try (ICluster cluster = init(builder().withNodes(3).start()))
- {
- cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
-
- cluster.coordinator(1).execute("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, 1, 1)",
- ConsistencyLevel.QUORUM);
-
- for (int i = 0; i < 3; i++)
- {
- assertRows(cluster.get(1).executeInternal("SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1"),
- row(1, 1, 1));
- }
-
- assertRows(cluster.coordinator(1).execute("SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1",
- ConsistencyLevel.QUORUM),
- row(1, 1, 1));
- }
- }
-
- @Test
- public void readRepairTest() throws Throwable
- {
- try (ICluster cluster = init(builder().withNodes(3).start()))
- {
- cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
-
- cluster.get(1).executeInternal("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, 1, 1)");
- cluster.get(2).executeInternal("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, 1, 1)");
-
- assertRows(cluster.get(3).executeInternal("SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1"));
-
- assertRows(cluster.coordinator(1).execute("SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1",
- ConsistencyLevel.ALL), // ensure node3 in preflist
- row(1, 1, 1));
-
- // Verify that data got repaired to the third node
- assertRows(cluster.get(3).executeInternal("SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1"),
- row(1, 1, 1));
- }
- }
-
- @Test
- public void simplePagedReadsTest() throws Throwable
- {
- try (ICluster cluster = init(builder().withNodes(3).start()))
- {
- cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
-
- int size = 100;
- Object[][] results = new Object[size][];
- for (int i = 0; i < size; i++)
- {
- cluster.coordinator(1).execute("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, ?, ?)",
- ConsistencyLevel.QUORUM,
- i, i);
- results[i] = new Object[] { 1, i, i};
- }
-
- // Make sure paged read returns same results with different page sizes
- for (int pageSize : new int[] { 1, 2, 3, 5, 10, 20, 50})
- {
- assertRows(cluster.coordinator(1).executeWithPaging("SELECT * FROM " + KEYSPACE + ".tbl",
- ConsistencyLevel.QUORUM,
- pageSize),
- results);
- }
- }
- }
-
- @Test
- public void pagingWithRepairTest() throws Throwable
- {
- try (ICluster cluster = init(builder().withNodes(3).start()))
- {
- cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
-
- int size = 100;
- Object[][] results = new Object[size][];
- for (int i = 0; i < size; i++)
- {
- // Make sure that data lands on different nodes and not coordinator
- cluster.get(i % 2 == 0 ? 2 : 3).executeInternal("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, ?, ?)",
- i, i);
-
- results[i] = new Object[] { 1, i, i};
- }
-
- // Make sure paged read returns same results with different page sizes
- for (int pageSize : new int[] { 1, 2, 3, 5, 10, 20, 50})
- {
- assertRows(cluster.coordinator(1).executeWithPaging("SELECT * FROM " + KEYSPACE + ".tbl",
- ConsistencyLevel.ALL,
- pageSize),
- results);
- }
-
- assertRows(cluster.get(1).executeInternal("SELECT * FROM " + KEYSPACE + ".tbl"),
- results);
- }
- }
-
- @Test
- public void pagingTests() throws Throwable
- {
- try (ICluster cluster = init(builder().withNodes(3).start());
- ICluster singleNode = init(builder().withNodes(1).withSubnet(1).start()))
- {
- cluster.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
- singleNode.schemaChange("CREATE TABLE " + KEYSPACE + ".tbl (pk int, ck int, v int, PRIMARY KEY (pk, ck))");
-
- for (int i = 0; i < 10; i++)
- {
- for (int j = 0; j < 10; j++)
- {
- cluster.coordinator(1).execute("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, ?, ?)",
- ConsistencyLevel.QUORUM,
- i, j, i + i);
- singleNode.coordinator(1).execute("INSERT INTO " + KEYSPACE + ".tbl (pk, ck, v) VALUES (1, ?, ?)",
- ConsistencyLevel.QUORUM,
- i, j, i + i);
- }
- }
-
- int[] pageSizes = new int[] { 1, 2, 3, 5, 10, 20, 50};
- String[] statements = new String [] {"SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck > 5",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck >= 5",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck > 5 AND ck <= 10",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck > 5 LIMIT 3",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck >= 5 LIMIT 2",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck > 5 AND ck <= 10 LIMIT 2",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck > 5 ORDER BY ck DESC",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck >= 5 ORDER BY ck DESC",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck > 5 AND ck <= 10 ORDER BY ck DESC",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck > 5 ORDER BY ck DESC LIMIT 3",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck >= 5 ORDER BY ck DESC LIMIT 2",
- "SELECT * FROM " + KEYSPACE + ".tbl WHERE pk = 1 AND ck > 5 AND ck <= 10 ORDER BY ck DESC LIMIT 2",
- "SELECT DISTINCT pk FROM " + KEYSPACE + ".tbl LIMIT 3",
- "SELECT DISTINCT pk FROM " + KEYSPACE + ".tbl WHERE pk IN (3,5,8,10)",
- "SELECT DISTINCT pk FROM " + KEYSPACE + ".tbl WHERE pk IN (3,5,8,10) LIMIT 2"
- };
- for (String statement : statements)
- {
- for (int pageSize : pageSizes)
- {
- assertRows(cluster.coordinator(1)
- .executeWithPaging(statement,
- ConsistencyLevel.QUORUM, pageSize),
- singleNode.coordinator(1)
- .executeWithPaging(statement,
- ConsistencyLevel.QUORUM, Integer.MAX_VALUE));
- }
- }
-
- }
- }
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org