Skip to content

Commit 1f096c0

Browse files
committed
CNDB-13524 Adds a timeout to Future.get calls in PendingAntiCompactionTest (#1664)
### What is the issue `PendingAntiCompactionTest.testRetriesTimeout` is flaky on `main` failing with a timeout reported in the junit test task. riptano/cndb#13524 ### What does this PR fix and why was it fixed `PendingAntiCompactionTest.testRetriesTimeout`, and a couple other tests, are calling `Future.get` without any timeout. This change adds a 30 seconds timeout to prevent an indefinite wait for the future and a log in the failing test rather than in the junit test task.
1 parent 568e72c commit 1f096c0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/unit/org/apache/cassandra/db/repair/PendingAntiCompactionTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public void successCase() throws Exception
154154
try
155155
{
156156
pac = new PendingAntiCompaction(sessionID, tables, atEndpoint(ranges, NO_RANGES), executor, () -> false);
157-
pac.run().get();
157+
pac.run().get(30, TimeUnit.SECONDS);
158158
}
159159
finally
160160
{
@@ -640,7 +640,7 @@ public boolean isGlobal()
640640
}
641641

642642
@Test
643-
public void testRetries() throws InterruptedException, ExecutionException
643+
public void testRetries() throws InterruptedException, ExecutionException, TimeoutException
644644
{
645645
ColumnFamilyStore cfs = MockSchema.newCFS();
646646
cfs.addSSTable(MockSchema.sstable(1, true, cfs));
@@ -683,7 +683,7 @@ protected PendingAntiCompaction.AcquireResult acquireSSTables()
683683
};
684684
Future f = es.submit(acquisitionCallable);
685685
cdl.await();
686-
assertNotNull(f.get());
686+
assertNotNull(f.get(30, TimeUnit.SECONDS));
687687
}
688688
finally
689689
{
@@ -692,7 +692,7 @@ protected PendingAntiCompaction.AcquireResult acquireSSTables()
692692
}
693693

694694
@Test
695-
public void testRetriesTimeout() throws InterruptedException, ExecutionException, IOException
695+
public void testRetriesTimeout() throws InterruptedException, ExecutionException, IOException, TimeoutException
696696
{
697697
ColumnFamilyStore cfs = MockSchema.newCFS();
698698
cfs.addSSTable(MockSchema.sstable(1, true, cfs));
@@ -721,7 +721,7 @@ public boolean apply(SSTableReader sstable)
721721
};
722722
PendingAntiCompaction.AcquisitionCallable acquisitionCallable = new PendingAntiCompaction.AcquisitionCallable(cfs, nextTimeUUID(), 2, 1000, acp);
723723
Future fut = es.submit(acquisitionCallable);
724-
assertNull(fut.get());
724+
assertNull(fut.get(30, TimeUnit.SECONDS));
725725
}
726726
finally
727727
{
@@ -730,7 +730,7 @@ public boolean apply(SSTableReader sstable)
730730
}
731731

732732
@Test
733-
public void testWith2i() throws ExecutionException, InterruptedException
733+
public void testWith2i() throws ExecutionException, InterruptedException, TimeoutException
734734
{
735735
cfs2.disableAutoCompaction();
736736
makeSSTables(2, cfs2, 100);
@@ -746,7 +746,7 @@ public void testWith2i() throws ExecutionException, InterruptedException
746746
try (LifecycleTransaction txn = idx.getTracker().tryModify(idx.getLiveSSTables(), OperationType.COMPACTION))
747747
{
748748
PendingAntiCompaction pac = new PendingAntiCompaction(prsid, Collections.singleton(cfs2), atEndpoint(FULL_RANGE, NO_RANGES), es, () -> false);
749-
pac.run().get();
749+
pac.run().get(30, TimeUnit.SECONDS);
750750
}
751751
// and make sure it succeeded;
752752
for (SSTableReader sstable : cfs2.getLiveSSTables())

0 commit comments

Comments
 (0)