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

brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new d421e82  Modernize temp dir creation, wrap truncation with flakyTest
d421e82 is described below

commit d421e82ee0ffd66d3f382bfbe0b69b7b275edce3
Author: Brandon Williams <[email protected]>
AuthorDate: Thu Mar 18 11:23:47 2021 -0500

    Modernize temp dir creation, wrap truncation with flakyTest
    
    Patch by brandonwilliams, reviewed by ycai for CASSANDRA-16526
---
 .../apache/cassandra/utils/binlog/BinLogTest.java  | 50 ++++++++++++++--------
 1 file changed, 31 insertions(+), 19 deletions(-)

diff --git a/test/unit/org/apache/cassandra/utils/binlog/BinLogTest.java 
b/test/unit/org/apache/cassandra/utils/binlog/BinLogTest.java
index 9ca24b0..311b924 100644
--- a/test/unit/org/apache/cassandra/utils/binlog/BinLogTest.java
+++ b/test/unit/org/apache/cassandra/utils/binlog/BinLogTest.java
@@ -20,7 +20,7 @@ package org.apache.cassandra.utils.binlog;
 
 import java.io.File;
 import java.nio.file.Path;
-import java.nio.file.Paths;
+import java.nio.file.Files;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
@@ -39,7 +39,6 @@ import net.openhft.chronicle.queue.ExcerptTailer;
 import net.openhft.chronicle.queue.RollCycles;
 import net.openhft.chronicle.wire.WireOut;
 import org.apache.cassandra.Util;
-import org.apache.cassandra.io.util.FileUtils;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -51,10 +50,7 @@ public class BinLogTest
 {
     public static Path tempDir() throws Exception
     {
-        File f = FileUtils.createTempFile("foo", "bar");
-        f.delete();
-        f.mkdir();
-        return Paths.get(f.getPath());
+        return Files.createTempDirectory("binlogtest" + System.nanoTime());
     }
 
     private static final String testString = "ry@nlikestheyankees";
@@ -417,28 +413,44 @@ public class BinLogTest
     /**
      * Test for a bug where files were deleted but the space was not reclaimed 
when tracking so
      * all log segemnts were incorrectly deleted when rolled.
+     *
+     * Due to some internal state in ChronicleQueue this test is occasionally
+     * flaky when run in the suite with testPut or testOffer.
      */
     @Test
-    public void testTrucationReleasesLogSpace() throws Exception
+    public void testTruncationReleasesLogSpace() throws Exception
+    {
+        Util.flakyTest(this::flakyTestTruncationReleasesLogSpace, 2, "Fails 
occasionally due to Chronicle internal state, see CASSANDRA-16526");
+    }
+
+
+    private void flakyTestTruncationReleasesLogSpace()
     {
         StringBuilder sb = new StringBuilder();
-        for (int ii = 0; ii < 1024 * 1024 * 2; ii++)
+        try
         {
-            sb.append('a');
-        }
+            for (int ii = 0; ii < 1024 * 1024 * 2; ii++)
+            {
+                sb.append('a');
+            }
 
-        String queryString = sb.toString();
+            String queryString = sb.toString();
 
-        //This should fill up the log so when it rolls in the future it will 
always delete the rolled segment;
-        for (int ii = 0; ii < 129; ii++)
-        {
-            binLog.put(record(queryString));
-        }
+            //This should fill up the log so when it rolls in the future it 
will always delete the rolled segment;
+            for (int ii = 0; ii < 129; ii++)
+            {
+                binLog.put(record(queryString));
+            }
 
-        for (int ii = 0; ii < 2; ii++)
+            for (int ii = 0; ii < 2; ii++)
+            {
+                Thread.sleep(2000);
+                binLog.put(record(queryString));
+            }
+        }
+        catch (InterruptedException e)
         {
-            Thread.sleep(2000);
-            binLog.put(record(queryString));
+            throw new RuntimeException(e);
         }
 
         Util.spinAssertEquals(2, () -> readBinLogRecords(path).size(), 60);

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

Reply via email to