Skip to content

Commit e201fc2

Browse files
committed
Adjust remaining tests to account for coordinator execution, test-latest, and IndexHints access from RowFilter
1 parent 5b114b6 commit e201fc2

File tree

5 files changed

+43
-34
lines changed

5 files changed

+43
-34
lines changed

test/unit/org/apache/cassandra/cql3/CQLTester.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public abstract class CQLTester
278278
private static final Map<ClusterSettings, Cluster> clusters = new HashMap<>();
279279
private static final Map<ClusterSettings, Session> sessions = new HashMap<>();
280280

281-
private static Consumer<Cluster.Builder> clusterBuilderConfigurator;
281+
private static Consumer<Cluster.Builder> clusterBuilderConfigurator = builder -> {};
282282

283283
public static final List<ProtocolVersion> PROTOCOL_VERSIONS = new ArrayList<>(ProtocolVersion.SUPPORTED.size());
284284

test/unit/org/apache/cassandra/db/filter/IndexHintsTest.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,8 @@ private void testTransport(String query, IndexHints expectedHints)
495495
public void testLegacyIndexWithAllowFiltering() throws Throwable
496496
{
497497
createTable("CREATE TABLE %s (k int PRIMARY KEY, v1 int, v2 int, v3 int)");
498-
String idx1 = createIndex("CREATE INDEX idx1 ON %s(v1)");
499-
String idx2 = createIndex("CREATE INDEX idx2 ON %s(v2)");
498+
String idx1 = createIndex("CREATE INDEX idx1 ON %s(v1) USING 'legacy_local_table'");
499+
String idx2 = createIndex("CREATE INDEX idx2 ON %s(v2) USING 'legacy_local_table'");
500500

501501
String insert = "INSERT INTO %s (k, v1, v2, v3) VALUES (?, ?, ?, ?)";
502502
Object[] row1 = new Object[]{ 1, 0, 1, 1 };
@@ -564,8 +564,8 @@ public void testLegacyIndexWithAllowFiltering() throws Throwable
564564
public void testLegacyIndexWithoutAllowFiltering() throws Throwable
565565
{
566566
createTable("CREATE TABLE %s (k int PRIMARY KEY, v1 int, v2 int, v3 int)");
567-
String idx1 = createIndex("CREATE INDEX idx1 ON %s(v1)");
568-
String idx2 = createIndex("CREATE INDEX idx2 ON %s(v2)");
567+
String idx1 = createIndex("CREATE INDEX idx1 ON %s(v1) USING 'legacy_local_table'");
568+
String idx2 = createIndex("CREATE INDEX idx2 ON %s(v2) USING 'legacy_local_table'");
569569

570570
String insert = "INSERT INTO %s (k, v1, v2, v3) VALUES (?, ?, ?, ?)";
571571
Object[] row1 = new Object[]{ 1, 0, 1, 1 };
@@ -634,8 +634,8 @@ public void testLegacyIndexWithoutAllowFiltering() throws Throwable
634634
public void testSAIWithAllowFiltering() throws Throwable
635635
{
636636
createTable("CREATE TABLE %s (k int PRIMARY KEY, v1 int, v2 int, v3 int)");
637-
String idx1 = createIndex("CREATE CUSTOM INDEX idx1 ON %s(v1) USING 'StorageAttachedIndex'");
638-
String idx2 = createIndex("CREATE CUSTOM INDEX idx2 ON %s(v2) USING 'StorageAttachedIndex'");
637+
String idx1 = createIndex("CREATE INDEX idx1 ON %s(v1) USING 'sai'");
638+
String idx2 = createIndex("CREATE INDEX idx2 ON %s(v2) USING 'sai'");
639639

640640
String insert = "INSERT INTO %s (k, v1, v2, v3) VALUES (?, ?, ?, ?)";
641641
Object[] row1 = new Object[]{ 1, 0, 1, 1 };
@@ -707,8 +707,8 @@ public void testSAIWithAllowFiltering() throws Throwable
707707
public void testSAIWithoutAllowFiltering() throws Throwable
708708
{
709709
createTable("CREATE TABLE %s (k int PRIMARY KEY, v1 int, v2 int, v3 int)");
710-
String idx1 = createIndex("CREATE CUSTOM INDEX idx1 ON %s(v1) USING 'StorageAttachedIndex'");
711-
String idx2 = createIndex("CREATE CUSTOM INDEX idx2 ON %s(v2) USING 'StorageAttachedIndex'");
710+
String idx1 = createIndex("CREATE INDEX idx1 ON %s(v1) USING 'sai'");
711+
String idx2 = createIndex("CREATE INDEX idx2 ON %s(v2) USING 'sai'");
712712

713713
String insert = "INSERT INTO %s (k, v1, v2, v3) VALUES (?, ?, ?, ?)";
714714
Object[] row1 = new Object[]{ 1, 0, 1, 1 };
@@ -779,7 +779,7 @@ public void testSAIWithoutAllowFiltering() throws Throwable
779779
@Test
780780
public void testLegacy()
781781
{
782-
testSingletonIndex("CREATE INDEX %s ON %%s(%s)");
782+
testSingletonIndex("CREATE INDEX %s ON %%s(%s) USING 'legacy_local_table'");
783783
}
784784

785785
@Test
@@ -842,9 +842,9 @@ private void testSingletonIndex(String createIndexQuery)
842842
public void testMixedIndexImplementations()
843843
{
844844
createTable("CREATE TABLE %s (k int PRIMARY KEY, v1 int, v2 int, v3 int)");
845-
String idx1 = createIndex("CREATE CUSTOM INDEX idx1 ON %s(v1) USING 'StorageAttachedIndex'");
846-
String idx2 = createIndex("CREATE CUSTOM INDEX idx2 ON %s(v2) USING 'StorageAttachedIndex'");
847-
String idx3 = createIndex("CREATE INDEX idx3 ON %s(v3)");
845+
String idx1 = createIndex("CREATE INDEX idx1 ON %s(v1) USING 'sai'");
846+
String idx2 = createIndex("CREATE INDEX idx2 ON %s(v2) USING 'sai'");
847+
String idx3 = createIndex("CREATE INDEX idx3 ON %s(v3) USING 'legacy_local_table'");
848848

849849
String insert = "INSERT INTO %s (k, v1, v2, v3) VALUES (?, ?, ?, ?)";
850850
Object[] row1 = new Object[]{ 1, 0, 1, 1 };
@@ -964,7 +964,7 @@ public void testMultipleIndexesOnSameColumnLegacyAndSASI()
964964
{
965965
createTable("CREATE TABLE %s (k int PRIMARY KEY, v int)");
966966
String sasi = createIndex("CREATE CUSTOM INDEX sasi ON %s(v) USING 'org.apache.cassandra.index.sasi.SASIIndex'");
967-
String legacy = createIndex("CREATE INDEX legacy ON %s(v)");
967+
String legacy = createIndex("CREATE INDEX legacy ON %s(v) USING 'legacy_local_table'");
968968

969969
String insert = "INSERT INTO %s (k, v) VALUES (?, ?)";
970970
Object[] row1 = new Object[]{ 1, 1 };
@@ -1005,8 +1005,8 @@ public void testMultipleIndexesOnSameColumnLegacyAndSASI()
10051005
public void testMultipleIndexesOnSameColumnLegacyAndSAI()
10061006
{
10071007
createTable("CREATE TABLE %s (k int PRIMARY KEY, v int)");
1008-
String sai = createIndex("CREATE CUSTOM INDEX sai ON %s(v) USING 'StorageAttachedIndex'");
1009-
String legacy = createIndex("CREATE INDEX legacy ON %s(v)");
1008+
String sai = createIndex("CREATE INDEX sai ON %s(v) USING 'sai'");
1009+
String legacy = createIndex("CREATE INDEX legacy ON %s(v) USING 'legacy_local_table'");
10101010

10111011
String insert = "INSERT INTO %s (k, v) VALUES (?, ?)";
10121012
Object[] row1 = new Object[]{ 1, 0 };
@@ -1028,7 +1028,7 @@ public void testMultipleIndexesOnSameColumnLegacyAndSAI()
10281028
public void testMultipleIndexesOnSameColumnSAIAndSASI()
10291029
{
10301030
createTable("CREATE TABLE %s (k int PRIMARY KEY, v int)");
1031-
String sai = createIndex("CREATE CUSTOM INDEX sai ON %s(v) USING 'StorageAttachedIndex'");
1031+
String sai = createIndex("CREATE INDEX sai ON %s(v) USING 'sai'");
10321032
String sasi = createIndex("CREATE CUSTOM INDEX sasi ON %s(v) USING 'org.apache.cassandra.index.sasi.SASIIndex'");
10331033

10341034
String insert = "INSERT INTO %s (k, v) VALUES (?, ?)";
@@ -1051,8 +1051,8 @@ public void testMultipleIndexesOnSameColumnSAIAndSASI()
10511051
public void testDuplicatedHints()
10521052
{
10531053
createTable("CREATE TABLE %s (k int PRIMARY KEY, v1 int, v2 int, v3 int)");
1054-
String idx1 = createIndex("CREATE INDEX idx1 ON %s(v1)");
1055-
String idx2 = createIndex("CREATE CUSTOM INDEX idx2 ON %s(v2) USING 'StorageAttachedIndex'");
1054+
String idx1 = createIndex("CREATE INDEX idx1 ON %s(v1) USING 'legacy_local_table'");
1055+
String idx2 = createIndex("CREATE INDEX idx2 ON %s(v2) USING 'sai'");
10561056
String idx3 = createIndex("CREATE CUSTOM INDEX idx3 ON %s(v3) USING 'org.apache.cassandra.index.sasi.SASIIndex'");
10571057

10581058
assertThatIndexQueryPlanFor("SELECT * FROM %s WHERE v1=0 WITH included_indexes={idx1,idx1}").selects(idx1);

test/unit/org/apache/cassandra/index/sai/cql/VectorInvalidQueryTest.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.datastax.driver.core.exceptions.InvalidQueryException;
2424
import org.apache.cassandra.cql3.CQLStatement;
25+
import org.apache.cassandra.cql3.CQLTester;
2526
import org.apache.cassandra.cql3.QueryOptions;
2627
import org.apache.cassandra.cql3.QueryProcessor;
2728
import org.apache.cassandra.cql3.ResultSet;
@@ -48,9 +49,9 @@
4849
public class VectorInvalidQueryTest extends SAITester
4950
{
5051
@BeforeClass
51-
public static void setupClass()
52+
public static void disableCoordinatorExecution()
5253
{
53-
requireNetwork();
54+
CQLTester.disableCoordinatorExecution();
5455
}
5556

5657
@Test
@@ -107,7 +108,7 @@ public void cannotQueryWrongNumberOfDimensions()
107108
}
108109

109110
@Test
110-
public void testMultiVectorOrderingsNotAllowed() throws Throwable
111+
public void testMultiVectorOrderingsNotAllowed()
111112
{
112113
createTable("CREATE TABLE %s (pk int, str_val text, val1 vector<float, 3>, val2 vector<float, 3>, PRIMARY KEY(pk))");
113114
createIndex("CREATE CUSTOM INDEX ON %s(str_val) USING 'StorageAttachedIndex'");
@@ -119,7 +120,7 @@ public void testMultiVectorOrderingsNotAllowed() throws Throwable
119120
}
120121

121122
@Test
122-
public void testDescendingVectorOrderingIsNotAllowed() throws Throwable
123+
public void testDescendingVectorOrderingIsNotAllowed()
123124
{
124125
createTable("CREATE TABLE %s (pk int, val vector<float, 3>, PRIMARY KEY(pk))");
125126
createIndex("CREATE CUSTOM INDEX ON %s(val) USING 'StorageAttachedIndex'");
@@ -129,7 +130,7 @@ public void testDescendingVectorOrderingIsNotAllowed() throws Throwable
129130
}
130131

131132
@Test
132-
public void testVectorOrderingIsNotAllowedWithClusteringOrdering() throws Throwable
133+
public void testVectorOrderingIsNotAllowedWithClusteringOrdering()
133134
{
134135
createTable("CREATE TABLE %s (pk int, ck int, val vector<float, 3>, PRIMARY KEY(pk, ck))");
135136
createIndex("CREATE CUSTOM INDEX ON %s(val) USING 'StorageAttachedIndex'");
@@ -139,7 +140,7 @@ public void testVectorOrderingIsNotAllowedWithClusteringOrdering() throws Throwa
139140
}
140141

141142
@Test
142-
public void testVectorOrderingIsNotAllowedWithoutIndex() throws Throwable
143+
public void testVectorOrderingIsNotAllowedWithoutIndex()
143144
{
144145
createTable("CREATE TABLE %s (pk int, str_val text, val vector<float, 3>, PRIMARY KEY(pk))");
145146

@@ -151,15 +152,15 @@ public void testVectorOrderingIsNotAllowedWithoutIndex() throws Throwable
151152
}
152153

153154
@Test
154-
public void testInvalidColumnNameWithAnn() throws Throwable
155+
public void testInvalidColumnNameWithAnn()
155156
{
156157
String table = createTable(KEYSPACE, "CREATE TABLE %s (k int, c int, v int, primary key (k, c))");
157158
assertInvalidMessage(String.format("Undefined column name bad_col in table %s", KEYSPACE + '.' + table),
158159
"SELECT k from %s ORDER BY bad_col ANN OF [1.0] LIMIT 1");
159160
}
160161

161162
@Test
162-
public void cannotPerformNonANNQueryOnVectorIndex() throws Throwable
163+
public void cannotPerformNonANNQueryOnVectorIndex()
163164
{
164165
createTable("CREATE TABLE %s (pk int, ck int, val vector<float, 3>, PRIMARY KEY(pk, ck))");
165166
createIndex("CREATE CUSTOM INDEX ON %s(val) USING 'StorageAttachedIndex'");
@@ -169,7 +170,7 @@ public void cannotPerformNonANNQueryOnVectorIndex() throws Throwable
169170
}
170171

171172
@Test
172-
public void cannotOrderWithAnnOnNonVectorColumn() throws Throwable
173+
public void cannotOrderWithAnnOnNonVectorColumn()
173174
{
174175
createTable("CREATE TABLE %s (k int, v int, primary key(k))");
175176
createIndex("CREATE CUSTOM INDEX ON %s(v) USING 'StorageAttachedIndex'");
@@ -243,7 +244,7 @@ public void cannotHaveAggregationOnANNQuery()
243244
}
244245

245246
@Test
246-
public void multipleVectorColumnsInQueryFailCorrectlyTest() throws Throwable
247+
public void multipleVectorColumnsInQueryFailCorrectlyTest()
247248
{
248249
createTable("CREATE TABLE %s (k int PRIMARY KEY, v1 vector<float, 1>, v2 vector<float, 1>)");
249250
createIndex("CREATE CUSTOM INDEX ON %s(v1) USING 'StorageAttachedIndex' WITH OPTIONS = {'similarity_function' : 'euclidean'}");
@@ -255,7 +256,7 @@ public void multipleVectorColumnsInQueryFailCorrectlyTest() throws Throwable
255256
}
256257

257258
@Test
258-
public void annOrderingIsNotAllowedWithoutIndexWhereIndexedColumnExistsInQueryTest() throws Throwable
259+
public void annOrderingIsNotAllowedWithoutIndexWhereIndexedColumnExistsInQueryTest()
259260
{
260261
createTable("CREATE TABLE %s (k int PRIMARY KEY, v vector<float, 1>, c int)");
261262
createIndex("CREATE CUSTOM INDEX ON %s(c) USING 'StorageAttachedIndex'");
@@ -270,7 +271,7 @@ public void annOrderingIsNotAllowedWithoutIndexWhereIndexedColumnExistsInQueryTe
270271
}
271272

272273
@Test
273-
public void cannotPostFilterOnNonIndexedColumnWithAnnOrdering() throws Throwable
274+
public void cannotPostFilterOnNonIndexedColumnWithAnnOrdering()
274275
{
275276
createTable("CREATE TABLE %s (pk1 int, pk2 int, ck1 int, ck2 int, v vector<float, 1>, c int, primary key ((pk1, pk2), ck1, ck2))");
276277
createIndex("CREATE CUSTOM INDEX ON %s(v) USING 'StorageAttachedIndex' WITH OPTIONS = {'similarity_function' : 'euclidean'}");

test/unit/org/apache/cassandra/index/sai/cql/intersection/RandomIntersectionTester.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,11 @@
2929
import java.util.stream.Collectors;
3030

3131
import org.junit.Before;
32+
import org.junit.BeforeClass;
3233
import org.junit.runners.Parameterized;
3334

3435
import org.apache.cassandra.config.CassandraRelevantProperties;
36+
import org.apache.cassandra.cql3.CQLTester;
3537
import org.apache.cassandra.cql3.UntypedResultSet;
3638
import org.apache.cassandra.index.sai.utils.SAIRandomizedTester;
3739

@@ -65,6 +67,12 @@ protected enum Mode { REGULAR, STATIC, REGULAR_STATIC, TWO_REGULAR_ONE_STATIC }
6567

6668
private int numRows;
6769

70+
@BeforeClass
71+
public static void disableCoordinatorExecution()
72+
{
73+
CQLTester.disableCoordinatorExecution();
74+
}
75+
6876
@Before
6977
public void createTableAndIndexes()
7078
{

test/unit/org/apache/cassandra/index/sai/plan/OperationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ public static void loadSchema() throws ConfigurationException
111111
public void beforeTest()
112112
{
113113
ReadCommand command = PartitionRangeReadCommand.allDataRead(BACKEND.metadata(), FBUtilities.nowInSeconds());
114-
controller = new QueryController(BACKEND, command, null, contextWithUnrepairedMatches(command));
114+
controller = new QueryController(BACKEND, command, RowFilter.none(), contextWithUnrepairedMatches(command));
115115

116116
command = PartitionRangeReadCommand.allDataRead(CLUSTERING_BACKEND.metadata(), FBUtilities.nowInSeconds());
117-
controllerClustering = new QueryController(CLUSTERING_BACKEND, command, null, contextWithUnrepairedMatches(command));
117+
controllerClustering = new QueryController(CLUSTERING_BACKEND, command, RowFilter.none(), contextWithUnrepairedMatches(command));
118118

119119
command = PartitionRangeReadCommand.allDataRead(STATIC_BACKEND.metadata(), FBUtilities.nowInSeconds());
120-
controllerStatic = new QueryController(STATIC_BACKEND, command, null, contextWithUnrepairedMatches(command));
120+
controllerStatic = new QueryController(STATIC_BACKEND, command, RowFilter.none(), contextWithUnrepairedMatches(command));
121121
}
122122

123123
private static QueryContext contextWithUnrepairedMatches(ReadCommand command)

0 commit comments

Comments
 (0)