This is an automated email from the ASF dual-hosted git repository. bereng pushed a commit to branch cassandra-4.0 in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-4.0 by this push: new 3e153c8 Split ViewComplexTest to avoid timeouts after being moved away from 'long' junits new 558d4ed Merge branch 'cassandra-4.0.0' into cassandra-4.0 3e153c8 is described below commit 3e153c88547de4227f2758d15abeadc82a7138fe Author: Bereng <berenguerbl...@gmail.com> AuthorDate: Fri Jun 4 06:53:47 2021 +0200 Split ViewComplexTest to avoid timeouts after being moved away from 'long' junits patch by Berenguer Blas; reviewed by Ekaterina Dimitrova for CASSANDRA-16711 --- .../cassandra/cql3/ViewComplexDeletionsTest.java | 3 +- .../cassandra/cql3/ViewComplexLivenessTest.java | 258 ++++++++++++++++ .../apache/cassandra/cql3/ViewComplexTTLTest.java | 3 +- .../org/apache/cassandra/cql3/ViewComplexTest.java | 180 +---------- .../cassandra/cql3/ViewComplexUpdatesTest.java | 3 +- ...Test.java => ViewFilteringClustering1Test.java} | 245 +-------------- .../cql3/ViewFilteringClustering2Test.java | 329 +++++++++++++++++++++ .../apache/cassandra/cql3/ViewFilteringPKTest.java | 5 +- .../apache/cassandra/cql3/ViewFilteringTest.java | 5 +- test/unit/org/apache/cassandra/cql3/ViewTest.java | 1 + .../InsertUpdateIfConditionCollectionsTest.java | 2 +- .../InsertUpdateIfConditionStaticsTest.java | 2 +- .../operations/InsertUpdateIfConditionTest.java | 2 +- 13 files changed, 609 insertions(+), 429 deletions(-) diff --git a/test/unit/org/apache/cassandra/cql3/ViewComplexDeletionsTest.java b/test/unit/org/apache/cassandra/cql3/ViewComplexDeletionsTest.java index e6662f2..e130378 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewComplexDeletionsTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewComplexDeletionsTest.java @@ -44,12 +44,13 @@ import static org.apache.cassandra.cql3.ViewComplexTest.updateView; import static org.apache.cassandra.cql3.ViewComplexTest.updateViewWithFlush; import static org.junit.Assert.assertEquals; -/* This class been split into multiple ones bc of timeout issues CASSANDRA-16670 +/* ViewComplexTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) * Any changes here check if they apply to the other classes: * - ViewComplexUpdatesTest * - ViewComplexDeletionsTest * - ViewComplexTTLTest * - ViewComplexTest + * - ViewComplexLivenessTest */ @RunWith(Parameterized.class) public class ViewComplexDeletionsTest extends CQLTester diff --git a/test/unit/org/apache/cassandra/cql3/ViewComplexLivenessTest.java b/test/unit/org/apache/cassandra/cql3/ViewComplexLivenessTest.java new file mode 100644 index 0000000..6999bef --- /dev/null +++ b/test/unit/org/apache/cassandra/cql3/ViewComplexLivenessTest.java @@ -0,0 +1,258 @@ +/* + * 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.cql3; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import org.apache.cassandra.db.ColumnFamilyStore; +import org.apache.cassandra.db.Keyspace; +import org.apache.cassandra.transport.ProtocolVersion; +import org.apache.cassandra.utils.FBUtilities; + +import static org.apache.cassandra.cql3.ViewComplexTest.createView; +import static org.apache.cassandra.cql3.ViewComplexTest.updateView; +import static org.apache.cassandra.cql3.ViewComplexTest.updateViewWithFlush; +import static org.junit.Assert.assertEquals; + +/* ViewComplexTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) + * Any changes here check if they apply to the other classes: + * - ViewComplexUpdatesTest + * - ViewComplexDeletionsTest + * - ViewComplexTTLTest + * - ViewComplexTest + * - ViewComplexLivenessTest + */ +@RunWith(Parameterized.class) +public class ViewComplexLivenessTest extends CQLTester +{ + @Parameterized.Parameter + public ProtocolVersion version; + + @Parameterized.Parameters() + public static Collection<Object[]> versions() + { + return ViewComplexTest.versions(); + } + + private final List<String> views = new ArrayList<>(); + + @BeforeClass + public static void startup() + { + ViewComplexTest.startup(); + } + + @Before + public void begin() + { + ViewComplexTest.beginSetup(views); + } + + @After + public void end() throws Throwable + { + ViewComplexTest.endTearDown(views, version, this); + } + + @Test + public void testUnselectedColumnWithExpiredLivenessInfo() throws Throwable + { + boolean flush = true; + createTable("create table %s (k int, c int, a int, b int, PRIMARY KEY(k, c))"); + + execute("USE " + keyspace()); + executeNet(version, "USE " + keyspace()); + Keyspace ks = Keyspace.open(keyspace()); + + createView("mv", + "create materialized view %s as select k,c,b from %%s where c is not null and k is not null primary key (c, k);", + version, + this, + views); + ks.getColumnFamilyStore("mv").disableAutoCompaction(); + + // sstable-1, Set initial values TS=1 + updateViewWithFlush("UPDATE %s SET a = 1 WHERE k = 1 AND c = 1;", flush, version, this); + + assertRowsIgnoringOrder(execute("SELECT * from %s WHERE k = 1 AND c = 1;"), + row(1, 1, 1, null)); + assertRowsIgnoringOrder(execute("SELECT k,c,b from mv WHERE k = 1 AND c = 1;"), + row(1, 1, null)); + + // sstable-2 + updateViewWithFlush("INSERT INTO %s(k,c) VALUES(1,1) USING TTL 5", flush, version, this); + + assertRowsIgnoringOrder(execute("SELECT * from %s WHERE k = 1 AND c = 1;"), + row(1, 1, 1, null)); + assertRowsIgnoringOrder(execute("SELECT k,c,b from mv WHERE k = 1 AND c = 1;"), + row(1, 1, null)); + + Thread.sleep(5001); + + assertRowsIgnoringOrder(execute("SELECT * from %s WHERE k = 1 AND c = 1;"), + row(1, 1, 1, null)); + assertRowsIgnoringOrder(execute("SELECT k,c,b from mv WHERE k = 1 AND c = 1;"), + row(1, 1, null)); + + // sstable-3 + updateViewWithFlush("Update %s set a = null where k = 1 AND c = 1;", flush, version, this); + + assertRowsIgnoringOrder(execute("SELECT * from %s WHERE k = 1 AND c = 1;")); + assertRowsIgnoringOrder(execute("SELECT k,c,b from mv WHERE k = 1 AND c = 1;")); + + // sstable-4 + updateViewWithFlush("Update %s USING TIMESTAMP 1 set b = 1 where k = 1 AND c = 1;", flush, version, this); + + assertRowsIgnoringOrder(execute("SELECT * from %s WHERE k = 1 AND c = 1;"), + row(1, 1, null, 1)); + assertRowsIgnoringOrder(execute("SELECT k,c,b from mv WHERE k = 1 AND c = 1;"), + row(1, 1, 1)); + } + + @Test + public void testExpiredLivenessLimitWithFlush() throws Throwable + { + // CASSANDRA-13883 + testExpiredLivenessLimit(true); + } + + @Test + public void testExpiredLivenessLimitWithoutFlush() throws Throwable + { + // CASSANDRA-13883 + testExpiredLivenessLimit(false); + } + + private void testExpiredLivenessLimit(boolean flush) throws Throwable + { + createTable("CREATE TABLE %s (k int PRIMARY KEY, a int, b int);"); + + execute("USE " + keyspace()); + executeNet(version, "USE " + keyspace()); + Keyspace ks = Keyspace.open(keyspace()); + + createView("mv1", + "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE k IS NOT NULL AND a IS NOT NULL PRIMARY KEY (k, a);", + version, + this, + views); + createView("mv2", + "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE k IS NOT NULL AND a IS NOT NULL PRIMARY KEY (a, k);", + version, + this, + views); + ks.getColumnFamilyStore("mv1").disableAutoCompaction(); + ks.getColumnFamilyStore("mv2").disableAutoCompaction(); + + for (int i = 1; i <= 100; i++) + updateView("INSERT INTO %s(k, a, b) VALUES (?, ?, ?);", version, this, i, i, i); + for (int i = 1; i <= 100; i++) + { + if (i % 50 == 0) + continue; + // create expired liveness + updateView("DELETE a FROM %s WHERE k = ?;", version, this, i); + } + if (flush) + { + ks.getColumnFamilyStore("mv1").forceBlockingFlush(); + ks.getColumnFamilyStore("mv2").forceBlockingFlush(); + } + + for (String view : Arrays.asList("mv1", "mv2")) + { + // paging + assertEquals(1, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s limit 1", view), 1).all().size()); + assertEquals(2, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s limit 2", view), 1).all().size()); + assertEquals(2, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s", view), 1).all().size()); + assertRowsNet(version, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s ", view), 1), + row(50, 50, 50), + row(100, 100, 100)); + // limit + assertEquals(1, execute(String.format("SELECT k,a,b FROM %s limit 1", view)).size()); + assertRowsIgnoringOrder(execute(String.format("SELECT k,a,b FROM %s limit 2", view)), + row(50, 50, 50), + row(100, 100, 100)); + } + } + + @Test + public void testStrictLivenessTombstone() throws Throwable + { + createTable("create table %s (p int primary key, v1 int, v2 int)"); + + execute("USE " + keyspace()); + executeNet(version, "USE " + keyspace()); + Keyspace ks = Keyspace.open(keyspace()); + + createView("mv", + "create materialized view %s as select * from %%s where p is not null and v1 is not null primary key (v1, p)" + + " with gc_grace_seconds=5;", + version, + this, + views); + ColumnFamilyStore cfs = ks.getColumnFamilyStore("mv"); + cfs.disableAutoCompaction(); + + updateView("Insert into %s (p, v1, v2) values (1, 1, 1) ;", version, this); + assertRowsIgnoringOrder(execute("SELECT p, v1, v2 from mv"), row(1, 1, 1)); + + updateView("Update %s set v1 = null WHERE p = 1", version, this); + FBUtilities.waitOnFutures(ks.flush()); + assertRowsIgnoringOrder(execute("SELECT p, v1, v2 from mv")); + + cfs.forceMajorCompaction(); // before gc grace second, strict-liveness tombstoned dead row remains + assertEquals(1, cfs.getLiveSSTables().size()); + + Thread.sleep(6000); + assertEquals(1, cfs.getLiveSSTables().size()); // no auto compaction. + + cfs.forceMajorCompaction(); // after gc grace second, no data left + assertEquals(0, cfs.getLiveSSTables().size()); + + updateView("Update %s using ttl 5 set v1 = 1 WHERE p = 1", version, this); + FBUtilities.waitOnFutures(ks.flush()); + assertRowsIgnoringOrder(execute("SELECT p, v1, v2 from mv"), row(1, 1, 1)); + + cfs.forceMajorCompaction(); // before ttl+gc_grace_second, strict-liveness ttled dead row remains + assertEquals(1, cfs.getLiveSSTables().size()); + assertRowsIgnoringOrder(execute("SELECT p, v1, v2 from mv"), row(1, 1, 1)); + + Thread.sleep(5500); // after expired, before gc_grace_second + cfs.forceMajorCompaction();// before ttl+gc_grace_second, strict-liveness ttled dead row remains + assertEquals(1, cfs.getLiveSSTables().size()); + assertRowsIgnoringOrder(execute("SELECT p, v1, v2 from mv")); + + Thread.sleep(5500); // after expired + gc_grace_second + assertEquals(1, cfs.getLiveSSTables().size()); // no auto compaction. + + cfs.forceMajorCompaction(); // after gc grace second, no data left + assertEquals(0, cfs.getLiveSSTables().size()); + } +} diff --git a/test/unit/org/apache/cassandra/cql3/ViewComplexTTLTest.java b/test/unit/org/apache/cassandra/cql3/ViewComplexTTLTest.java index 01bc33a..76a8933 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewComplexTTLTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewComplexTTLTest.java @@ -38,12 +38,13 @@ import static org.apache.cassandra.cql3.ViewComplexTest.updateView; import static org.apache.cassandra.cql3.ViewComplexTest.updateViewWithFlush; import static org.junit.Assert.assertTrue; -/* This class been split into multiple ones bc of timeout issues CASSANDRA-16670 +/* ViewComplexTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) * Any changes here check if they apply to the other classes: * - ViewComplexUpdatesTest * - ViewComplexDeletionsTest * - ViewComplexTTLTest * - ViewComplexTest + * - ViewComplexLivenessTest */ @RunWith(Parameterized.class) public class ViewComplexTTLTest extends CQLTester diff --git a/test/unit/org/apache/cassandra/cql3/ViewComplexTest.java b/test/unit/org/apache/cassandra/cql3/ViewComplexTest.java index 3d0e347..ea05eef 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewComplexTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewComplexTest.java @@ -47,15 +47,15 @@ import org.apache.cassandra.db.compaction.CompactionManager; import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.FBUtilities; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -/* This class been split into multiple ones bc of timeout issues CASSANDRA-16670 +/* ViewComplexTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) * Any changes here check if they apply to the other classes: * - ViewComplexUpdatesTest * - ViewComplexDeletionsTest * - ViewComplexTTLTest * - ViewComplexTest + * - ViewComplexLivenessTest */ @RunWith(Parameterized.class) public class ViewComplexTest extends CQLTester @@ -137,128 +137,6 @@ public class ViewComplexTest extends CQLTester } @Test - public void testUnselectedColumnWithExpiredLivenessInfo() throws Throwable - { - boolean flush = true; - createTable("create table %s (k int, c int, a int, b int, PRIMARY KEY(k, c))"); - - execute("USE " + keyspace()); - executeNet(version, "USE " + keyspace()); - Keyspace ks = Keyspace.open(keyspace()); - - createView("mv", - "create materialized view %s as select k,c,b from %%s where c is not null and k is not null primary key (c, k);", - version, - this, - views); - ks.getColumnFamilyStore("mv").disableAutoCompaction(); - - // sstable-1, Set initial values TS=1 - updateViewWithFlush("UPDATE %s SET a = 1 WHERE k = 1 AND c = 1;", flush, version, this); - - assertRowsIgnoringOrder(execute("SELECT * from %s WHERE k = 1 AND c = 1;"), - row(1, 1, 1, null)); - assertRowsIgnoringOrder(execute("SELECT k,c,b from mv WHERE k = 1 AND c = 1;"), - row(1, 1, null)); - - // sstable-2 - updateViewWithFlush("INSERT INTO %s(k,c) VALUES(1,1) USING TTL 5", flush, version, this); - - assertRowsIgnoringOrder(execute("SELECT * from %s WHERE k = 1 AND c = 1;"), - row(1, 1, 1, null)); - assertRowsIgnoringOrder(execute("SELECT k,c,b from mv WHERE k = 1 AND c = 1;"), - row(1, 1, null)); - - Thread.sleep(5001); - - assertRowsIgnoringOrder(execute("SELECT * from %s WHERE k = 1 AND c = 1;"), - row(1, 1, 1, null)); - assertRowsIgnoringOrder(execute("SELECT k,c,b from mv WHERE k = 1 AND c = 1;"), - row(1, 1, null)); - - // sstable-3 - updateViewWithFlush("Update %s set a = null where k = 1 AND c = 1;", flush, version, this); - - assertRowsIgnoringOrder(execute("SELECT * from %s WHERE k = 1 AND c = 1;")); - assertRowsIgnoringOrder(execute("SELECT k,c,b from mv WHERE k = 1 AND c = 1;")); - - // sstable-4 - updateViewWithFlush("Update %s USING TIMESTAMP 1 set b = 1 where k = 1 AND c = 1;", flush, version, this); - - assertRowsIgnoringOrder(execute("SELECT * from %s WHERE k = 1 AND c = 1;"), - row(1, 1, null, 1)); - assertRowsIgnoringOrder(execute("SELECT k,c,b from mv WHERE k = 1 AND c = 1;"), - row(1, 1, 1)); - } - - @Test - public void testExpiredLivenessLimitWithFlush() throws Throwable - { - // CASSANDRA-13883 - testExpiredLivenessLimit(true); - } - - @Test - public void testExpiredLivenessLimitWithoutFlush() throws Throwable - { - // CASSANDRA-13883 - testExpiredLivenessLimit(false); - } - - private void testExpiredLivenessLimit(boolean flush) throws Throwable - { - createTable("CREATE TABLE %s (k int PRIMARY KEY, a int, b int);"); - - execute("USE " + keyspace()); - executeNet(version, "USE " + keyspace()); - Keyspace ks = Keyspace.open(keyspace()); - - createView("mv1", - "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE k IS NOT NULL AND a IS NOT NULL PRIMARY KEY (k, a);", - version, - this, - views); - createView("mv2", - "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE k IS NOT NULL AND a IS NOT NULL PRIMARY KEY (a, k);", - version, - this, - views); - ks.getColumnFamilyStore("mv1").disableAutoCompaction(); - ks.getColumnFamilyStore("mv2").disableAutoCompaction(); - - for (int i = 1; i <= 100; i++) - updateView("INSERT INTO %s(k, a, b) VALUES (?, ?, ?);", version, this, i, i, i); - for (int i = 1; i <= 100; i++) - { - if (i % 50 == 0) - continue; - // create expired liveness - updateView("DELETE a FROM %s WHERE k = ?;", version, this, i); - } - if (flush) - { - ks.getColumnFamilyStore("mv1").forceBlockingFlush(); - ks.getColumnFamilyStore("mv2").forceBlockingFlush(); - } - - for (String view : Arrays.asList("mv1", "mv2")) - { - // paging - assertEquals(1, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s limit 1", view), 1).all().size()); - assertEquals(2, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s limit 2", view), 1).all().size()); - assertEquals(2, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s", view), 1).all().size()); - assertRowsNet(version, executeNetWithPaging(version, String.format("SELECT k,a,b FROM %s ", view), 1), - row(50, 50, 50), - row(100, 100, 100)); - // limit - assertEquals(1, execute(String.format("SELECT k,a,b FROM %s limit 1", view)).size()); - assertRowsIgnoringOrder(execute(String.format("SELECT k,a,b FROM %s limit 2", view)), - row(50, 50, 50), - row(100, 100, 100)); - } - } - - @Test public void testNonBaseColumnInViewPkWithFlush() throws Throwable { testNonBaseColumnInViewPk(true); @@ -325,60 +203,6 @@ public class ViewComplexTest extends CQLTester } @Test - public void testStrictLivenessTombstone() throws Throwable - { - createTable("create table %s (p int primary key, v1 int, v2 int)"); - - execute("USE " + keyspace()); - executeNet(version, "USE " + keyspace()); - Keyspace ks = Keyspace.open(keyspace()); - - createView("mv", - "create materialized view %s as select * from %%s where p is not null and v1 is not null primary key (v1, p)" - + " with gc_grace_seconds=5;", - version, - this, - views); - ColumnFamilyStore cfs = ks.getColumnFamilyStore("mv"); - cfs.disableAutoCompaction(); - - updateView("Insert into %s (p, v1, v2) values (1, 1, 1) ;", version, this); - assertRowsIgnoringOrder(execute("SELECT p, v1, v2 from mv"), row(1, 1, 1)); - - updateView("Update %s set v1 = null WHERE p = 1", version, this); - FBUtilities.waitOnFutures(ks.flush()); - assertRowsIgnoringOrder(execute("SELECT p, v1, v2 from mv")); - - cfs.forceMajorCompaction(); // before gc grace second, strict-liveness tombstoned dead row remains - assertEquals(1, cfs.getLiveSSTables().size()); - - Thread.sleep(6000); - assertEquals(1, cfs.getLiveSSTables().size()); // no auto compaction. - - cfs.forceMajorCompaction(); // after gc grace second, no data left - assertEquals(0, cfs.getLiveSSTables().size()); - - updateView("Update %s using ttl 5 set v1 = 1 WHERE p = 1", version, this); - FBUtilities.waitOnFutures(ks.flush()); - assertRowsIgnoringOrder(execute("SELECT p, v1, v2 from mv"), row(1, 1, 1)); - - cfs.forceMajorCompaction(); // before ttl+gc_grace_second, strict-liveness ttled dead row remains - assertEquals(1, cfs.getLiveSSTables().size()); - assertRowsIgnoringOrder(execute("SELECT p, v1, v2 from mv"), row(1, 1, 1)); - - Thread.sleep(5500); // after expired, before gc_grace_second - cfs.forceMajorCompaction();// before ttl+gc_grace_second, strict-liveness ttled dead row remains - assertEquals(1, cfs.getLiveSSTables().size()); - assertRowsIgnoringOrder(execute("SELECT p, v1, v2 from mv")); - - Thread.sleep(5500); // after expired + gc_grace_second - assertEquals(1, cfs.getLiveSSTables().size()); // no auto compaction. - - cfs.forceMajorCompaction(); // after gc grace second, no data left - assertEquals(0, cfs.getLiveSSTables().size()); - } - - @Test public void testCellTombstoneAndShadowableTombstonesWithFlush() throws Throwable { testCellTombstoneAndShadowableTombstones(true); diff --git a/test/unit/org/apache/cassandra/cql3/ViewComplexUpdatesTest.java b/test/unit/org/apache/cassandra/cql3/ViewComplexUpdatesTest.java index bcd11d1..f2a627d 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewComplexUpdatesTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewComplexUpdatesTest.java @@ -37,12 +37,13 @@ import org.apache.cassandra.utils.FBUtilities; import static org.apache.cassandra.cql3.ViewComplexTest.createView; import static org.apache.cassandra.cql3.ViewComplexTest.updateView; -/* This class been split into multiple ones bc of timeout issues CASSANDRA-16670 +/* ViewComplexTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) * Any changes here check if they apply to the other classes: * - ViewComplexUpdatesTest * - ViewComplexDeletionsTest * - ViewComplexTTLTest * - ViewComplexTest + * - ViewComplexLivenessTest */ @RunWith(Parameterized.class) public class ViewComplexUpdatesTest extends CQLTester diff --git a/test/unit/org/apache/cassandra/cql3/ViewFilteringClusteringTest.java b/test/unit/org/apache/cassandra/cql3/ViewFilteringClustering1Test.java similarity index 60% rename from test/unit/org/apache/cassandra/cql3/ViewFilteringClusteringTest.java rename to test/unit/org/apache/cassandra/cql3/ViewFilteringClustering1Test.java index ec213ea..6d4e487 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewFilteringClusteringTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewFilteringClustering1Test.java @@ -34,14 +34,15 @@ import org.junit.runners.Parameterized; import org.apache.cassandra.db.SystemKeyspace; import org.apache.cassandra.transport.ProtocolVersion; -/* This class been split into multiple ones bc of timeout issues CASSANDRA-16670 +/* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) * Any changes here check if they apply to the other classes * - ViewFilteringPKTest - * - ViewFilteringClusteringTest + * - ViewFilteringClustering1Test + * - ViewFilteringClustering2Test * - ViewFilteringTest */ @RunWith(Parameterized.class) -public class ViewFilteringClusteringTest extends CQLTester +public class ViewFilteringClustering1Test extends CQLTester { @Parameterized.Parameter public ProtocolVersion version; @@ -421,242 +422,4 @@ public class ViewFilteringClusteringTest extends CQLTester dropTable("DROP TABLE %s"); } } - - @Test - public void testClusteringKeyMultiColumnRestrictions() throws Throwable - { - List<String> mvPrimaryKeys = Arrays.asList("((a, b), c)", "((b, a), c)", "(a, b, c)", "(c, b, a)", "((c, a), b)"); - for (int i = 0; i < mvPrimaryKeys.size(); i++) - { - createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c))"); - - execute("USE " + keyspace()); - executeNet(version, "USE " + keyspace()); - - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, -1, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 0); - - logger.info("Testing MV primary key: {}", mvPrimaryKeys.get(i)); - - // only accept rows where b = 1 - createView("mv_test" + i, "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE a IS NOT NULL AND (b, c) >= (1, 0) PRIMARY KEY " + mvPrimaryKeys.get(i)); - - while (!SystemKeyspace.isViewBuilt(keyspace(), "mv_test" + i)) - Thread.sleep(10); - - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 1, 0, 0), - row(0, 1, 1, 0), - row(1, 1, 0, 0), - row(1, 1, 1, 0) - ); - - // insert new rows that do not match the filter - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, -1, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, -1, 0); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 1, 0, 0), - row(0, 1, 1, 0), - row(1, 1, 0, 0), - row(1, 1, 1, 0) - ); - - // insert new row that does match the filter - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 2, 0); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 1, 0, 0), - row(0, 1, 1, 0), - row(1, 1, 0, 0), - row(1, 1, 1, 0), - row(1, 1, 2, 0) - ); - - // update rows that don't match the filter - execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, -1, 0); - execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 2, -1, 0); - execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 2, 0, 0); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 1, 0, 0), - row(0, 1, 1, 0), - row(1, 1, 0, 0), - row(1, 1, 1, 0), - row(1, 1, 2, 0) - ); - - // update a row that does match the filter - execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, 1, 0); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 1, 0, 0), - row(0, 1, 1, 0), - row(1, 1, 0, 1), - row(1, 1, 1, 0), - row(1, 1, 2, 0) - ); - - // delete rows that don't match the filter - execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, -1); - execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, -1, 0); - execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, 0, 0); - execute("DELETE FROM %s WHERE a = ? AND b = ?", 0, 0); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 1, 0, 0), - row(0, 1, 1, 0), - row(1, 1, 0, 1), - row(1, 1, 1, 0), - row(1, 1, 2, 0) - ); - - // delete a row that does match the filter - execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, 0); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 1, 0, 0), - row(0, 1, 1, 0), - row(1, 1, 1, 0), - row(1, 1, 2, 0) - ); - - // delete a partition that matches the filter - execute("DELETE FROM %s WHERE a = ?", 1); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 1, 0, 0), - row(0, 1, 1, 0) - ); - - dropView("mv_test" + i); - dropTable("DROP TABLE %s"); - } - } - - @Test - public void testClusteringKeyFilteringRestrictions() throws Throwable - { - List<String> mvPrimaryKeys = Arrays.asList("((a, b), c)", "((b, a), c)", "(a, b, c)", "(c, b, a)", "((c, a), b)"); - for (int i = 0; i < mvPrimaryKeys.size(); i++) - { - createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c))"); - - execute("USE " + keyspace()); - executeNet(version, "USE " + keyspace()); - - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, -1, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 0); - - logger.info("Testing MV primary key: {}", mvPrimaryKeys.get(i)); - - // only accept rows where b = 1 - createView("mv_test" + i, "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE a IS NOT NULL AND b IS NOT NULL AND c = 1 PRIMARY KEY " + mvPrimaryKeys.get(i)); - - while (!SystemKeyspace.isViewBuilt(keyspace(), "mv_test" + i)) - Thread.sleep(10); - - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 0, 1, 0), - row(0, 1, 1, 0), - row(1, 0, 1, 0), - row(1, 1, 1, 0) - ); - - // insert new rows that do not match the filter - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0); - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, -1, 0); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 0, 1, 0), - row(0, 1, 1, 0), - row(1, 0, 1, 0), - row(1, 1, 1, 0) - ); - - // insert new row that does match the filter - execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 2, 1, 0); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 0, 1, 0), - row(0, 1, 1, 0), - row(1, 0, 1, 0), - row(1, 1, 1, 0), - row(1, 2, 1, 0) - ); - - // update rows that don't match the filter - execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, -1, 0); - execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 2, 0, 0); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 0, 1, 0), - row(0, 1, 1, 0), - row(1, 0, 1, 0), - row(1, 1, 1, 0), - row(1, 2, 1, 0) - ); - - // update a row that does match the filter - execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 2, 1, 1, 1); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 0, 1, 0), - row(0, 1, 1, 0), - row(1, 0, 1, 0), - row(1, 1, 1, 2), - row(1, 2, 1, 0) - ); - - // delete rows that don't match the filter - execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, -1); - execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, -1, 0); - execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, 0, 0); - execute("DELETE FROM %s WHERE a = ? AND b = ?", 0, -1); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 0, 1, 0), - row(0, 1, 1, 0), - row(1, 0, 1, 0), - row(1, 1, 1, 2), - row(1, 2, 1, 0) - ); - - // delete a row that does match the filter - execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, 1); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 0, 1, 0), - row(0, 1, 1, 0), - row(1, 0, 1, 0), - row(1, 2, 1, 0) - ); - - // delete a partition that matches the filter - execute("DELETE FROM %s WHERE a = ?", 1); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 0, 1, 0), - row(0, 1, 1, 0) - ); - - // insert a partition with one matching and one non-matching row using a batch (CASSANDRA-10614) - String tableName = KEYSPACE + "." + currentTable(); - execute("BEGIN BATCH " + - "INSERT INTO " + tableName + " (a, b, c, d) VALUES (?, ?, ?, ?); " + - "INSERT INTO " + tableName + " (a, b, c, d) VALUES (?, ?, ?, ?); " + - "APPLY BATCH", - 4, 4, 0, 0, - 4, 4, 1, 1); - assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), - row(0, 0, 1, 0), - row(0, 1, 1, 0), - row(4, 4, 1, 1) - ); - - dropView("mv_test" + i); - dropTable("DROP TABLE %s"); - } - } } diff --git a/test/unit/org/apache/cassandra/cql3/ViewFilteringClustering2Test.java b/test/unit/org/apache/cassandra/cql3/ViewFilteringClustering2Test.java new file mode 100644 index 0000000..d1ba842 --- /dev/null +++ b/test/unit/org/apache/cassandra/cql3/ViewFilteringClustering2Test.java @@ -0,0 +1,329 @@ +/* + * 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.cql3; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import org.apache.cassandra.db.SystemKeyspace; +import org.apache.cassandra.transport.ProtocolVersion; + +/* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) + * Any changes here check if they apply to the other classes + * - ViewFilteringPKTest + * - ViewFilteringClustering1Test + * - ViewFilteringClustering2Test + * - ViewFilteringTest + */ +@RunWith(Parameterized.class) +public class ViewFilteringClustering2Test extends CQLTester +{ + @Parameterized.Parameter + public ProtocolVersion version; + + @Parameterized.Parameters() + public static Collection<Object[]> versions() + { + return ViewFilteringTest.versions(); + } + + private final List<String> views = new ArrayList<>(); + + @BeforeClass + public static void startup() + { + ViewFilteringTest.startup(); + } + + @AfterClass + public static void tearDown() + { + ViewFilteringTest.tearDown(); + } + + @Before + public void begin() + { + ViewFilteringTest.beginSetup(views); + } + + @After + public void end() throws Throwable + { + ViewFilteringTest.endSetup(views, version, this); + } + + private void createView(String name, String query) throws Throwable + { + ViewFilteringTest.createView(name, query, views, version, this); + } + + private void dropView(String name) throws Throwable + { + ViewFilteringTest.dropView(name, views, version, this); + } + + @Test + public void testClusteringKeyMultiColumnRestrictions() throws Throwable + { + List<String> mvPrimaryKeys = Arrays.asList("((a, b), c)", "((b, a), c)", "(a, b, c)", "(c, b, a)", "((c, a), b)"); + for (int i = 0; i < mvPrimaryKeys.size(); i++) + { + createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c))"); + + execute("USE " + keyspace()); + executeNet(version, "USE " + keyspace()); + + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, -1, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 0); + + logger.info("Testing MV primary key: {}", mvPrimaryKeys.get(i)); + + // only accept rows where b = 1 + createView("mv_test" + i, "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE a IS NOT NULL AND (b, c) >= (1, 0) PRIMARY KEY " + mvPrimaryKeys.get(i)); + + while (!SystemKeyspace.isViewBuilt(keyspace(), "mv_test" + i)) + Thread.sleep(10); + + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 1, 0, 0), + row(0, 1, 1, 0), + row(1, 1, 0, 0), + row(1, 1, 1, 0) + ); + + // insert new rows that do not match the filter + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, -1, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, -1, 0); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 1, 0, 0), + row(0, 1, 1, 0), + row(1, 1, 0, 0), + row(1, 1, 1, 0) + ); + + // insert new row that does match the filter + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 2, 0); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 1, 0, 0), + row(0, 1, 1, 0), + row(1, 1, 0, 0), + row(1, 1, 1, 0), + row(1, 1, 2, 0) + ); + + // update rows that don't match the filter + execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, -1, 0); + execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 2, -1, 0); + execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 2, 0, 0); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 1, 0, 0), + row(0, 1, 1, 0), + row(1, 1, 0, 0), + row(1, 1, 1, 0), + row(1, 1, 2, 0) + ); + + // update a row that does match the filter + execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, 1, 0); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 1, 0, 0), + row(0, 1, 1, 0), + row(1, 1, 0, 1), + row(1, 1, 1, 0), + row(1, 1, 2, 0) + ); + + // delete rows that don't match the filter + execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, -1); + execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, -1, 0); + execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, 0, 0); + execute("DELETE FROM %s WHERE a = ? AND b = ?", 0, 0); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 1, 0, 0), + row(0, 1, 1, 0), + row(1, 1, 0, 1), + row(1, 1, 1, 0), + row(1, 1, 2, 0) + ); + + // delete a row that does match the filter + execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, 0); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 1, 0, 0), + row(0, 1, 1, 0), + row(1, 1, 1, 0), + row(1, 1, 2, 0) + ); + + // delete a partition that matches the filter + execute("DELETE FROM %s WHERE a = ?", 1); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 1, 0, 0), + row(0, 1, 1, 0) + ); + + dropView("mv_test" + i); + dropTable("DROP TABLE %s"); + } + } + + @Test + public void testClusteringKeyFilteringRestrictions() throws Throwable + { + List<String> mvPrimaryKeys = Arrays.asList("((a, b), c)", "((b, a), c)", "(a, b, c)", "(c, b, a)", "((c, a), b)"); + for (int i = 0; i < mvPrimaryKeys.size(); i++) + { + createTable("CREATE TABLE %s (a int, b int, c int, d int, PRIMARY KEY (a, b, c))"); + + execute("USE " + keyspace()); + executeNet(version, "USE " + keyspace()); + + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 0, 1, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 0, 1, 1, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 0, 1, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, -1, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 1, 1, 0); + + logger.info("Testing MV primary key: {}", mvPrimaryKeys.get(i)); + + // only accept rows where b = 1 + createView("mv_test" + i, "CREATE MATERIALIZED VIEW %s AS SELECT * FROM %%s WHERE a IS NOT NULL AND b IS NOT NULL AND c = 1 PRIMARY KEY " + mvPrimaryKeys.get(i)); + + while (!SystemKeyspace.isViewBuilt(keyspace(), "mv_test" + i)) + Thread.sleep(10); + + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 0, 1, 0), + row(0, 1, 1, 0), + row(1, 0, 1, 0), + row(1, 1, 1, 0) + ); + + // insert new rows that do not match the filter + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 0, 0, 0); + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 2, 1, -1, 0); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 0, 1, 0), + row(0, 1, 1, 0), + row(1, 0, 1, 0), + row(1, 1, 1, 0) + ); + + // insert new row that does match the filter + execute("INSERT INTO %s (a, b, c, d) VALUES (?, ?, ?, ?)", 1, 2, 1, 0); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 0, 1, 0), + row(0, 1, 1, 0), + row(1, 0, 1, 0), + row(1, 1, 1, 0), + row(1, 2, 1, 0) + ); + + // update rows that don't match the filter + execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 1, -1, 0); + execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 1, 2, 0, 0); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 0, 1, 0), + row(0, 1, 1, 0), + row(1, 0, 1, 0), + row(1, 1, 1, 0), + row(1, 2, 1, 0) + ); + + // update a row that does match the filter + execute("UPDATE %s SET d = ? WHERE a = ? AND b = ? AND c = ?", 2, 1, 1, 1); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 0, 1, 0), + row(0, 1, 1, 0), + row(1, 0, 1, 0), + row(1, 1, 1, 2), + row(1, 2, 1, 0) + ); + + // delete rows that don't match the filter + execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, -1); + execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, -1, 0); + execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 2, 0, 0); + execute("DELETE FROM %s WHERE a = ? AND b = ?", 0, -1); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 0, 1, 0), + row(0, 1, 1, 0), + row(1, 0, 1, 0), + row(1, 1, 1, 2), + row(1, 2, 1, 0) + ); + + // delete a row that does match the filter + execute("DELETE FROM %s WHERE a = ? AND b = ? AND c = ?", 1, 1, 1); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 0, 1, 0), + row(0, 1, 1, 0), + row(1, 0, 1, 0), + row(1, 2, 1, 0) + ); + + // delete a partition that matches the filter + execute("DELETE FROM %s WHERE a = ?", 1); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 0, 1, 0), + row(0, 1, 1, 0) + ); + + // insert a partition with one matching and one non-matching row using a batch (CASSANDRA-10614) + String tableName = KEYSPACE + "." + currentTable(); + execute("BEGIN BATCH " + + "INSERT INTO " + tableName + " (a, b, c, d) VALUES (?, ?, ?, ?); " + + "INSERT INTO " + tableName + " (a, b, c, d) VALUES (?, ?, ?, ?); " + + "APPLY BATCH", + 4, 4, 0, 0, + 4, 4, 1, 1); + assertRowsIgnoringOrder(execute("SELECT a, b, c, d FROM mv_test" + i), + row(0, 0, 1, 0), + row(0, 1, 1, 0), + row(4, 4, 1, 1) + ); + + dropView("mv_test" + i); + dropTable("DROP TABLE %s"); + } + } +} diff --git a/test/unit/org/apache/cassandra/cql3/ViewFilteringPKTest.java b/test/unit/org/apache/cassandra/cql3/ViewFilteringPKTest.java index 3c88dc3..09d220d 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewFilteringPKTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewFilteringPKTest.java @@ -34,10 +34,11 @@ import org.junit.runners.Parameterized; import org.apache.cassandra.db.SystemKeyspace; import org.apache.cassandra.transport.ProtocolVersion; -/* This class been split into multiple ones bc of timeout issues CASSANDRA-16670 +/* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) * Any changes here check if they apply to the other classes * - ViewFilteringPKTest - * - ViewFilteringClusteringTest + * - ViewFilteringClustering1Test + * - ViewFilteringClustering2Test * - ViewFilteringTest */ @RunWith(Parameterized.class) diff --git a/test/unit/org/apache/cassandra/cql3/ViewFilteringTest.java b/test/unit/org/apache/cassandra/cql3/ViewFilteringTest.java index 9588db0..374f79f 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewFilteringTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewFilteringTest.java @@ -41,10 +41,11 @@ import org.apache.cassandra.db.SystemKeyspace; import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.FBUtilities; -/* This class been split into multiple ones bc of timeout issues CASSANDRA-16670 +/* ViewFilteringTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) * Any changes here check if they apply to the other classes * - ViewFilteringPKTest - * - ViewFilteringClusteringTest + * - ViewFilteringClustering1Test + * - ViewFilteringClustering2Test * - ViewFilteringTest */ @RunWith(Parameterized.class) diff --git a/test/unit/org/apache/cassandra/cql3/ViewTest.java b/test/unit/org/apache/cassandra/cql3/ViewTest.java index 963a4b6..8040229 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewTest.java @@ -73,6 +73,7 @@ public class ViewTest extends CQLTester { requireNetwork(); } + @Before public void begin() { diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionCollectionsTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionCollectionsTest.java index 673c17d..7ad41e3 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionCollectionsTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionCollectionsTest.java @@ -33,7 +33,7 @@ import org.apache.cassandra.cql3.CQLTester; import org.apache.cassandra.exceptions.InvalidRequestException; import org.apache.cassandra.exceptions.SyntaxException; -/* This class been split into multiple ones bc of timeout issues CASSANDRA-16670 +/* InsertUpdateIfConditionCollectionsTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) * Any changes here check if they apply to the other classes * - InsertUpdateIfConditionStaticsTest * - InsertUpdateIfConditionCollectionsTest diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionStaticsTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionStaticsTest.java index 25ab256..45482e8 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionStaticsTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionStaticsTest.java @@ -29,7 +29,7 @@ import org.junit.runners.Parameterized; import org.apache.cassandra.cql3.CQLTester; -/* This class been split into multiple ones bc of timeout issues CASSANDRA-16670 +/* InsertUpdateIfConditionCollectionsTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) * Any changes here check if they apply to the other classes * - InsertUpdateIfConditionStaticsTest * - InsertUpdateIfConditionCollectionsTest diff --git a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java index 4213cc9..3c0e1c8 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/InsertUpdateIfConditionTest.java @@ -42,7 +42,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -/* This class been split into multiple ones bc of timeout issues CASSANDRA-16670 +/* InsertUpdateIfConditionCollectionsTest class has been split into multiple ones because of timeout issues (CASSANDRA-16670) * Any changes here check if they apply to the other classes * - InsertUpdateIfConditionStaticsTest * - InsertUpdateIfConditionCollectionsTest --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org