You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ad...@apache.org on 2017/11/23 18:53:20 UTC

cassandra git commit: Fix flaky unit tests SecondaryIndexManagerTest.assert[Not]MarkedAsBuilt

Repository: cassandra
Updated Branches:
  refs/heads/trunk 7eb915097 -> 2d2879db7


Fix flaky unit tests SecondaryIndexManagerTest.assert[Not]MarkedAsBuilt

patch by Andres de la Peña; reviewed by Robert Stupp for CASSANDRA-13965


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2d2879db
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2d2879db
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2d2879db

Branch: refs/heads/trunk
Commit: 2d2879db7a2fe8b0c25d08f67c81c88454e1527c
Parents: 7eb9150
Author: Andrés de la Peña <a....@gmail.com>
Authored: Wed Oct 18 16:28:12 2017 +0100
Committer: Andrés de la Peña <a....@gmail.com>
Committed: Thu Nov 23 18:49:26 2017 +0000

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../index/SecondaryIndexManagerTest.java        | 33 ++++++++++----------
 2 files changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d2879db/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6da2712..81b3a6e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0
+ * Fix flaky SecondaryIndexManagerTest.assert[Not]MarkedAsBuilt (CASSANDRA-13965)
  * Make LWTs send resultset metadata on every request (CASSANDRA-13992)
  * Fix flaky indexWithFailedInitializationIsNotQueryableAfterPartialRebuild (CASSANDRA-13963)
  * Introduce leaf-only iterator (CASSANDRA-9988)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d2879db/test/unit/org/apache/cassandra/index/SecondaryIndexManagerTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/index/SecondaryIndexManagerTest.java b/test/unit/org/apache/cassandra/index/SecondaryIndexManagerTest.java
index def96a4..2207f48 100644
--- a/test/unit/org/apache/cassandra/index/SecondaryIndexManagerTest.java
+++ b/test/unit/org/apache/cassandra/index/SecondaryIndexManagerTest.java
@@ -21,6 +21,7 @@ import java.io.FileNotFoundException;
 import java.net.SocketException;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.List;
 import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
@@ -37,7 +38,6 @@ import org.apache.cassandra.db.lifecycle.SSTableSet;
 import org.apache.cassandra.io.sstable.format.SSTableReader;
 import org.apache.cassandra.notifications.SSTableAddedNotification;
 import org.apache.cassandra.schema.IndexMetadata;
-import org.apache.cassandra.schema.SchemaConstants;
 import org.apache.cassandra.utils.JVMStabilityInspector;
 import org.apache.cassandra.utils.KillerForTests;
 import org.apache.cassandra.utils.concurrent.Refs;
@@ -50,10 +50,6 @@ import static org.junit.Assert.fail;
 public class SecondaryIndexManagerTest extends CQLTester
 {
 
-    private static final String builtIndexesQuery = String.format("SELECT * FROM %s.\"%s\"",
-                                                                  SchemaConstants.SYSTEM_KEYSPACE_NAME,
-                                                                  SystemKeyspace.BUILT_INDEXES);
-
     @After
     public void after()
     {
@@ -94,7 +90,7 @@ public class SecondaryIndexManagerTest extends CQLTester
 
         // drop the index and verify that it has been removed from the built indexes table
         dropIndex("DROP INDEX %s." + indexName);
-        assertNotMarkedAsBuilt();
+        assertNotMarkedAsBuilt(indexName);
 
         // create the index again and verify that it's added to the built indexes table
         createIndex(String.format("CREATE INDEX %s ON %%s(c)", indexName));
@@ -113,7 +109,7 @@ public class SecondaryIndexManagerTest extends CQLTester
 
         ColumnFamilyStore cfs = getCurrentColumnFamilyStore();
         cfs.indexManager.markAllIndexesRemoved();
-        assertNotMarkedAsBuilt();
+        assertNotMarkedAsBuilt(indexName);
 
         try (Refs<SSTableReader> sstables = Refs.ref(cfs.getSSTables(SSTableSet.CANONICAL)))
         {
@@ -132,7 +128,7 @@ public class SecondaryIndexManagerTest extends CQLTester
 
         // try to rebuild the index before the index creation task has finished
         assertFalse(tryRebuild(indexName, false));
-        assertNotMarkedAsBuilt();
+        assertNotMarkedAsBuilt(indexName);
 
         // check that the index is marked as built when the creation finishes
         TestingIndex.unblockCreate();
@@ -183,7 +179,7 @@ public class SecondaryIndexManagerTest extends CQLTester
 
         // verify rebuilding the index before the previous index build task has finished fails
         assertFalse(tryRebuild(indexName, false));
-        assertNotMarkedAsBuilt();
+        assertNotMarkedAsBuilt(indexName);
 
         // check that the index is marked as built when the build finishes
         TestingIndex.unblockBuild();
@@ -235,7 +231,7 @@ public class SecondaryIndexManagerTest extends CQLTester
 
         // verify rebuilding the index before the previous index build task has finished fails
         assertFalse(tryRebuild(indexName, false));
-        assertNotMarkedAsBuilt();
+        assertNotMarkedAsBuilt(indexName);
 
         // check that the index is marked as built when the build finishes
         TestingIndex.unblockBuild();
@@ -289,7 +285,7 @@ public class SecondaryIndexManagerTest extends CQLTester
         try (Refs<SSTableReader> sstables = Refs.ref(cfs.getSSTables(SSTableSet.CANONICAL)))
         {
             cfs.indexManager.handleNotification(new SSTableAddedNotification(sstables, null), cfs.getTracker());
-            assertNotMarkedAsBuilt();
+            assertNotMarkedAsBuilt(indexName);
         }
 
         // unblock the pending build:
@@ -359,7 +355,7 @@ public class SecondaryIndexManagerTest extends CQLTester
         asyncBuild.join();
 
         // verify the index is *not* built due to the failing sstable build:
-        assertNotMarkedAsBuilt();
+        assertNotMarkedAsBuilt(indexName);
         assertFalse(error.get());
     }
 
@@ -382,7 +378,7 @@ public class SecondaryIndexManagerTest extends CQLTester
         {
             assertTrue(ex.getMessage().contains("configured to fail"));
         }
-        assertNotMarkedAsBuilt();
+        assertNotMarkedAsBuilt(indexName);
     }
 
     @Test
@@ -553,14 +549,17 @@ public class SecondaryIndexManagerTest extends CQLTester
         }
     }
 
-    private void assertMarkedAsBuilt(String indexName) throws Throwable
+    private static void assertMarkedAsBuilt(String indexName)
     {
-        assertRows(execute(builtIndexesQuery), row(KEYSPACE, indexName, null));
+        List<String> indexes = SystemKeyspace.getBuiltIndexes(KEYSPACE, Collections.singleton(indexName));
+        assertEquals(1, indexes.size());
+        assertEquals(indexName, indexes.get(0));
     }
 
-    private void assertNotMarkedAsBuilt() throws Throwable
+    private static void assertNotMarkedAsBuilt(String indexName)
     {
-        assertEmpty(execute(builtIndexesQuery));
+        List<String> indexes = SystemKeyspace.getBuiltIndexes(KEYSPACE, Collections.singleton(indexName));
+        assertTrue(indexes.isEmpty());
     }
 
     private boolean tryRebuild(String indexName, boolean wait) throws Throwable


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org