maedhroz commented on code in PR #4249:
URL: https://github.com/apache/cassandra/pull/4249#discussion_r2246396165


##########
test/distributed/org/apache/cassandra/distributed/test/sai/IndexHintsDistributedTest.java:
##########
@@ -0,0 +1,148 @@
+/*
+ * 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.sai;
+
+import org.assertj.core.api.Assertions;
+import org.junit.Test;
+
+import net.bytebuddy.ByteBuddy;
+import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
+import net.bytebuddy.implementation.MethodDelegation;
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.ConsistencyLevel;
+import org.apache.cassandra.distributed.api.ICoordinator;
+import org.apache.cassandra.distributed.test.TestBaseImpl;
+import org.apache.cassandra.net.MessagingService;
+import org.apache.cassandra.net.MessagingService.Version;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+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.assertRows;
+import static org.apache.cassandra.distributed.shared.AssertUtils.row;
+
+/**
+ * Distributed tests for {@link org.apache.cassandra.db.filter.IndexHints}.
+ */
+public class IndexHintsDistributedTest extends TestBaseImpl
+{
+    private static final int NUM_REPLICAS = 2;
+    private static final int RF = 2;
+
+    @Test
+    public void testIndexHintsWithCurrentVersion() throws Throwable
+    {
+        try (Cluster cluster = init(Cluster.build(NUM_REPLICAS)
+                                           .withConfig(config -> 
config.with(GOSSIP).with(NETWORK).set("storage_compatibility_mode", "NONE"))
+                                           .start(), RF))
+        {
+            // null indicates that the query should succeed
+            testSelectWithIndexHints(cluster, null);
+        }
+    }
+
+    @Test
+    public void testIndexHintsWithAllOldVersion() throws Throwable
+    {
+        try (Cluster cluster = init(Cluster.build(NUM_REPLICAS)
+                                           .withConfig(config -> 
config.with(GOSSIP).with(NETWORK).set("storage_compatibility_mode", 
"CASSANDRA_4"))
+                                           .start(), RF))
+        {
+            testSelectWithIndexHints(cluster, "Index hints are not supported 
in clusters below 14.");
+        }
+    }
+
+    @Test
+    public void testIndexHintsWithMixedVersions() throws Throwable
+    {
+        try (Cluster cluster = init(Cluster.build(NUM_REPLICAS)
+                                           
.withInstanceInitializer(BB::install)
+                                           .withConfig(config -> 
config.with(GOSSIP).with(NETWORK).with(NATIVE_PROTOCOL).set("storage_compatibility_mode",
 "NONE"))
+                                           .start(), RF))
+        {
+            testSelectWithIndexHints(cluster, "Index hints are not supported 
in clusters below 14.");
+        }
+    }
+
+    private static void testSelectWithIndexHints(Cluster cluster, String 
expectedErrorMessage) throws Throwable
+    {
+        // create a schema with various indexes in the same column, so we can 
provide hints to select between them
+        cluster.schemaChange(withKeyspace("CREATE TABLE %s.t (k int PRIMARY 
KEY, v text)"));
+        cluster.schemaChange(withKeyspace("CREATE INDEX legacy_idx ON 
%s.t(v)"));
+        cluster.schemaChange(withKeyspace("CREATE CUSTOM INDEX 
non_analyzed_sai_idx ON %s.t(v) USING 'StorageAttachedIndex'"));

Review Comment:
   Yeah, I'm leaning toward leaving the name to be explicit, although I'm also 
noticing that I should probably also be explicit about using a legacy index in 
the statement above. If we switch to SAI-as-default, the index above will 
become an SAI index, not a legacy 2i.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to