Bug: Some tests are depending on each other
Status: Triage Needed
Priority: Normal
Created: 18/Sep/23 09:36

I noticed this first when dealing with (1)

Simple bash for unit tests gives:
{code:java}
for i in $(find . -type f -name '*Test.java'); do imports=$(grep 'import org.apache.*Test;' $i | grep -v 'Abstract'); if [ x"$imports" != "x" ]; then echo $i $imports; fi; done
./org/apache/cassandra/db/ColumnFamilyStoreTest.java import org.apache.cassandra.io.sstable.ScrubTest;
./org/apache/cassandra/db/compaction/CompactionsCQLTest.java import org.apache.cassandra.io.sstable.LegacySSTableTest;
./org/apache/cassandra/db/compaction/PartialCompactionsTest.java import org.apache.cassandra.db.DirectoriesTest;
./org/apache/cassandra/locator/ReconnectableSnitchHelperTest.java import org.apache.cassandra.net.MessagingServiceTest;
./org/apache/cassandra/tools/nodetool/ScrubToolTest.java import org.apache.cassandra.io.sstable.ScrubTest;
./org/apache/cassandra/tools/StandaloneUpgraderOnSStablesTest.java import org.apache.cassandra.io.sstable.LegacySSTableTest;
./org/apache/cassandra/tools/StandaloneVerifierTest.java import org.apache.cassandra.io.sstable.VerifyTest;
./org/apache/cassandra/tools/StandaloneVerifierOnSSTablesTest.java import org.apache.cassandra.io.sstable.VerifyTest;
./org/apache/cassandra/repair/asymmetric/DifferenceHolderTest.java import org.apache.cassandra.utils.MerkleTreesTest;
./org/apache/cassandra/repair/ValidatorTest.java import org.apache.cassandra.db.compaction.CompactionsTest;
./org/apache/cassandra/fql/FullQueryLoggerTest.java import org.apache.cassandra.utils.binlog.BinLogTest;
./org/apache/cassandra/index/sai/cql/InetAddressTypeEquivalencyTest.java import org.apache.cassandra.index.sai.cql.types.InetTest;
./org/apache/cassandra/io/compress/CompressedSequentialWriterTest.java import org.apache.cassandra.io.util.SequentialWriterTest;
./org/apache/cassandra/io/sstable/LegacySSTableTest.java import org.apache.cassandra.db.SinglePartitionSliceCommandTest;
./org/apache/cassandra/audit/BinAuditLoggerTest.java import org.apache.cassandra.utils.binlog.BinLogTest;
./org/apache/cassandra/cql3/validation/operations/CompactStorageSplit1Test.java import org.apache.cassandra.cql3.validation.entities.SecondaryIndexTest; {code}
 

in-jvm-dtests:
{code:java}
for i in $(find . -type f -name '*Test.java'); do imports=$(grep 'import org.apache.*Test;' $i | grep -v 'Abstract'); if [ x"$imports" != "x" ]; then echo $i $imports; fi; done
./org/apache/cassandra/distributed/test/ring/BootstrapTest.java import org.apache.cassandra.distributed.test.DecommissionTest; {code}
 

If one goes one by one, there are some cases when one test is truly depending on another. I do not think this is a good practice at all.  Each test should be self-contained or at least all common parts which are reused should be extracted to some helper classes. As it is done right now, if one changes the implementation of some helper methods in one test, it might fail others. If it is extracted, it is more probable that a developer would check where that method is used additionally to the place a developer is focused on. Right now if a developer changes a method in a test that method is specified in, she does not have a clue that it might be used somewhere else.

(1) https://issues.apache.org/jira/browse/CASSANDRA-18824?focusedCommentId=17763155&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17763155