From fb343de84f9ab08fe43955a7e1216490e42d798b Mon Sep 17 00:00:00 2001 From: Branimir Lambov Date: Wed, 5 Jul 2023 10:55:27 +0300 Subject: [PATCH] Tweak flaky test for more information --- .../compaction/CorruptedSSTablesCompactionsTest.java | 11 ++++++----- .../cassandra/io/compress/CQLCompressionTest.java | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/unit/org/apache/cassandra/db/compaction/CorruptedSSTablesCompactionsTest.java b/test/unit/org/apache/cassandra/db/compaction/CorruptedSSTablesCompactionsTest.java index 774055bdd402..26adfb108ca8 100644 --- a/test/unit/org/apache/cassandra/db/compaction/CorruptedSSTablesCompactionsTest.java +++ b/test/unit/org/apache/cassandra/db/compaction/CorruptedSSTablesCompactionsTest.java @@ -44,10 +44,12 @@ import org.apache.cassandra.db.*; import org.apache.cassandra.db.marshal.LongType; import org.apache.cassandra.exceptions.ConfigurationException; +import org.apache.cassandra.io.sstable.CorruptSSTableException; import org.apache.cassandra.io.sstable.format.SSTableReader; import org.apache.cassandra.io.util.File; import org.apache.cassandra.io.util.FileUtils; import org.apache.cassandra.schema.*; +import org.apache.cassandra.utils.Throwables; import static org.junit.Assert.assertTrue; @@ -223,16 +225,15 @@ public void testCorruptedSSTables(String tableName) throws Exception try { cfs.forceMajorCompaction(); + break; } catch (Exception e) { - // kind of a hack since we're not specifying just CorruptSSTableExceptions, or (what we actually expect) - // an ExecutionException wrapping a CSSTE. This is probably Good Enough though, since if there are - // other errors in compaction presumably the other tests would bring that to light. + // This is the expected path. The SSTable should be marked corrupted, and retrying the compaction + // should move on to the next corruption. + Throwables.assertAnyCause(e, CorruptSSTableException.class); failures++; - continue; } - break; } cfs.truncateBlocking(); diff --git a/test/unit/org/apache/cassandra/io/compress/CQLCompressionTest.java b/test/unit/org/apache/cassandra/io/compress/CQLCompressionTest.java index f011f8a3b418..517edeb8a8b4 100644 --- a/test/unit/org/apache/cassandra/io/compress/CQLCompressionTest.java +++ b/test/unit/org/apache/cassandra/io/compress/CQLCompressionTest.java @@ -24,7 +24,6 @@ import org.junit.BeforeClass; import org.junit.Test; -import org.apache.cassandra.Util; import org.apache.cassandra.config.Config; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.cql3.CQLTester;