This is an automated email from the ASF dual-hosted git repository. bereng pushed a commit to branch cassandra-3.11 in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/cassandra-3.11 by this push: new 4bfe687 Flaky CassandraIndexTest 4bfe687 is described below commit 4bfe68717d9a419ab6a0b3a681478b39117dee80 Author: Bereng <berenguerbl...@gmail.com> AuthorDate: Wed Apr 21 08:39:15 2021 +0200 Flaky CassandraIndexTest patch by Berenguer Blasi; reviewed by Andrés de la Peña for CASSANDRA-16601 --- .../index/internal/CassandraIndexTest.java | 31 +++++++++++++--------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java b/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java index a5c1f60..4ad93b4 100644 --- a/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java +++ b/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java @@ -18,7 +18,6 @@ package org.apache.cassandra.index.internal; -import java.nio.ByteBuffer; import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; @@ -27,6 +26,7 @@ import com.google.common.base.Joiner; import com.google.common.collect.*; import org.junit.Test; +import org.apache.cassandra.Util; import org.apache.cassandra.config.CFMetaData; import org.apache.cassandra.config.ColumnDefinition; import org.apache.cassandra.config.SchemaConstants; @@ -570,33 +570,38 @@ public class CassandraIndexTest extends CQLTester String selectBuiltIndexesQuery = String.format("SELECT * FROM %s.\"%s\"", SchemaConstants.SYSTEM_KEYSPACE_NAME, SystemKeyspace.BUILT_INDEXES); - UntypedResultSet rs = execute(selectBuiltIndexesQuery); - int initialSize = rs.size(); + + // Wait for any background index clearing tasks to complete. Warn: When we used to run tests in parallel there + // could also be cross test class talk and have other indices pop up here. + Util.spinAssertEquals(0, () -> { + try + { + return execute(selectBuiltIndexesQuery).size(); + } + catch (Throwable e) + { + throw new AssertionError(e); + } + }, 60); 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 - rs = execute(selectBuiltIndexesQuery); - int sizeAfterBuild = rs.size(); - assertRowsIgnoringOrderAndExtra(rs, row(KEYSPACE, indexName)); + assertRows(execute(selectBuiltIndexesQuery), 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 - rs = execute(selectBuiltIndexesQuery); - assertEquals(sizeAfterBuild, rs.size()); - assertRowsIgnoringOrderAndExtra(rs, row(KEYSPACE, indexName)); + assertRows(execute(selectBuiltIndexesQuery), 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))); + assertRows(execute(selectBuiltIndexesQuery)); } // this is slightly annoying, but we cannot read rows from the methods in Util as --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org