This is an automated email from the ASF dual-hosted git repository.

samt pushed a commit to branch cassandra-3.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-3.0 by this push:
     new c81d7dc  Use result size for built index test
c81d7dc is described below

commit c81d7dcc09fa1c35f190f0baad764fbe8a024679
Author: Jorge Bay Gondra <[email protected]>
AuthorDate: Wed Mar 11 10:19:28 2020 +0000

    Use result size for built index test
    
    Patch by Jorge Bay Gondra; reviewed by Sam Tunnicliffe for CASSANDRA-15565
---
 .../index/internal/CassandraIndexTest.java         | 23 ++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git 
a/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java 
b/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
index 286c418..7cea9da 100644
--- a/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
+++ b/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
@@ -488,21 +488,36 @@ public class CassandraIndexTest extends CQLTester
     @Test
     public void indexCorrectlyMarkedAsBuildAndRemoved() throws Throwable
     {
+        String selectBuiltIndexesQuery = String.format("SELECT * FROM 
%s.\"%s\"",
+                                                       SystemKeyspace.NAME,
+                                                       
SystemKeyspace.BUILT_INDEXES);
+        UntypedResultSet rs = execute(selectBuiltIndexesQuery);
+        int initialSize = rs.size();
+
         String indexName = "build_remove_test_idx";
         String tableName = createTable("CREATE TABLE %s (a int, b int, c int, 
PRIMARY KEY (a, b))");
         createIndex(String.format("CREATE INDEX %s ON %%s(c)", indexName));
         waitForIndex(KEYSPACE, tableName, indexName);
         // check that there are no other rows in the built indexes table
-        assertRows(execute(String.format("SELECT * FROM %s.\"%s\"", 
SystemKeyspace.NAME, SystemKeyspace.BUILT_INDEXES)),
-                   row(KEYSPACE, indexName));
+        rs = execute(selectBuiltIndexesQuery);
+        int sizeAfterBuild = rs.size();
+        assertRowsIgnoringOrderAndExtra(rs, row(KEYSPACE, indexName));
 
         // rebuild the index and verify the built status table
         getCurrentColumnFamilyStore().rebuildSecondaryIndex(indexName);
         waitForIndex(KEYSPACE, tableName, indexName);
 
         // check that there are no other rows in the built indexes table
-        assertRows(execute(String.format("SELECT * FROM %s.\"%s\"", 
SystemKeyspace.NAME, SystemKeyspace.BUILT_INDEXES)),
-                   row(KEYSPACE, indexName));
+        rs = execute(selectBuiltIndexesQuery);
+        assertEquals(sizeAfterBuild, rs.size());
+        assertRowsIgnoringOrderAndExtra(rs, row(KEYSPACE, indexName));
+
+        // check that dropping the index removes it from the built indexes 
table
+        dropIndex("DROP INDEX %s." + indexName);
+        rs = execute(selectBuiltIndexesQuery);
+        assertEquals(initialSize, rs.size());
+        rs.forEach(row -> 
assertFalse(row.getString("table_name").equals(KEYSPACE)  // table_name is 
actually keyspace
+                                      && 
row.getString("index_name").equals(indexName)));
     }
 
     // this is slightly annoying, but we cannot read rows from the methods in 
Util as


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

Reply via email to