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


##########
test/distributed/org/apache/cassandra/distributed/test/sai/ImportIndexedSSTablesTest.java:
##########
@@ -0,0 +1,145 @@
+/*
+ * 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 net.bytebuddy.ByteBuddy;
+import net.bytebuddy.dynamic.loading.ClassLoadingStrategy;
+import net.bytebuddy.implementation.MethodDelegation;
+import org.junit.Test;
+
+import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.db.Keyspace;
+import org.apache.cassandra.db.compaction.CompactionInterruptedException;
+import org.apache.cassandra.distributed.Cluster;
+import org.apache.cassandra.distributed.api.IInvokableInstance;
+import org.apache.cassandra.distributed.test.TestBaseImpl;
+import org.apache.cassandra.index.sai.StorageAttachedIndexBuilder;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import static org.apache.cassandra.distributed.api.Feature.GOSSIP;
+import static org.apache.cassandra.distributed.api.Feature.NETWORK;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+public class ImportIndexedSSTablesTest extends TestBaseImpl
+{
+    @Test
+    public void testIndexBuildingFailureDuringImport() throws Exception
+    {
+        try (Cluster cluster = init(Cluster.build(1)
+                                           .withConfig(c -> c.with(NETWORK, 
GOSSIP))
+                                           
.withInstanceInitializer(ByteBuddyHelper::install)
+                                           .start()))
+        {
+            cluster.disableAutoCompaction(KEYSPACE);
+            cluster.schemaChange(withKeyspace("CREATE TABLE %s.test (pk int 
PRIMARY KEY, v text)"));
+            
+            IInvokableInstance first = cluster.get(1);
+
+            first.executeInternal(withKeyspace("INSERT INTO %s.test(pk, v) 
VALUES (?, ?)"), 1, "v1");
+            first.flush(KEYSPACE);
+
+            Object[][] rs = first.executeInternal(withKeyspace("select pk from 
%s.test where pk = ?"), 1);
+            assertThat(rs.length).isEqualTo(1);
+
+            first.runOnInstance(() -> {
+                ColumnFamilyStore cfs = 
Keyspace.open(KEYSPACE).getColumnFamilyStore("test");
+                cfs.clearUnsafe();
+            });
+
+            cluster.schemaChange(withKeyspace("CREATE CUSTOM INDEX 
test_v_index ON %s.test(v) USING 'StorageAttachedIndex'"));

Review Comment:
   There's a failure in 
https://app.circleci.com/pipelines/github/maedhroz/cassandra/738/workflows/58e74f88-40d3-4776-9c20-9020a982966e/jobs/9901/tests#failed-test-0
 that might be related to not waiting for the index to be ready here...



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to