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

dlmarion pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new fc3018d0a4 Fixed compression test (#5932)
fc3018d0a4 is described below

commit fc3018d0a42c80ba14c6749482e717099d576cf3
Author: Dave Marion <[email protected]>
AuthorDate: Fri Sep 26 07:47:11 2025 -0400

    Fixed compression test (#5932)
    
    Closes #5869
---
 .../core/file/rfile/bcfile/CompressionTest.java    | 43 +++++++++++++++-------
 1 file changed, 29 insertions(+), 14 deletions(-)

diff --git 
a/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java
 
b/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java
index 8f38b1b30e..c89a8dc1bb 100644
--- 
a/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java
+++ 
b/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java
@@ -49,7 +49,7 @@ import org.junit.jupiter.api.Timeout;
 
 public class CompressionTest {
 
-  HashMap<CompressionAlgorithm,Boolean> isSupported = new HashMap<>();
+  private final HashMap<String,CompressionAlgorithm> isSupported = new 
HashMap<>();
 
   @BeforeEach
   public void testSupport() throws ClassNotFoundException {
@@ -62,7 +62,7 @@ public class CompressionTest {
         (CompressionCodec) ReflectionUtils.newInstance(Class.forName(clazz), 
myConf);
 
     assertNotNull(codec);
-    isSupported.put(new CompressionAlgorithm(gz, myConf), true);
+    isSupported.put(gz.getName(), new CompressionAlgorithm(gz, myConf));
 
     Lzo lzo = new Lzo();
     extClazz = lzo.getCodecClassNameProperty();
@@ -71,7 +71,7 @@ public class CompressionTest {
       codec = (CompressionCodec) 
ReflectionUtils.newInstance(Class.forName(clazz), myConf);
 
       assertNotNull(codec);
-      isSupported.put(new CompressionAlgorithm(lzo, myConf), true);
+      isSupported.put(lzo.getName(), new CompressionAlgorithm(lzo, myConf));
 
     } catch (ClassNotFoundException e) {
       // that is okay
@@ -85,7 +85,7 @@ public class CompressionTest {
 
       assertNotNull(codec);
 
-      isSupported.put(new CompressionAlgorithm(lz4, myConf), true);
+      isSupported.put(lz4.getName(), new CompressionAlgorithm(lz4, myConf));
 
     } catch (ClassNotFoundException e) {
       // that is okay
@@ -99,7 +99,7 @@ public class CompressionTest {
 
       assertNotNull(codec);
 
-      isSupported.put(new CompressionAlgorithm(bzip, myConf), true);
+      isSupported.put(bzip.getName(), new CompressionAlgorithm(bzip, myConf));
 
     } catch (ClassNotFoundException e) {
       // that is okay
@@ -113,7 +113,7 @@ public class CompressionTest {
 
       assertNotNull(codec);
 
-      isSupported.put(new CompressionAlgorithm(snappy, myConf), true);
+      isSupported.put(snappy.getName(), new CompressionAlgorithm(snappy, 
myConf));
 
     } catch (ClassNotFoundException e) {
       // that is okay
@@ -127,20 +127,21 @@ public class CompressionTest {
 
       assertNotNull(codec);
 
-      isSupported.put(new CompressionAlgorithm(zstd, myConf), true);
+      isSupported.put(zstd.getName(), new CompressionAlgorithm(zstd, myConf));
 
     } catch (ClassNotFoundException e) {
       // that is okay
     }
-
+    assertTrue(!isSupported.isEmpty(), "No supported codecs found");
   }
 
   @Test
   public void testSingle() {
 
+    boolean somethingGotTested = false;
     for (final String name : Compression.getSupportedAlgorithms()) {
       CompressionAlgorithm al = 
Compression.getCompressionAlgorithmByName(name);
-      if (isSupported.get(al) != null && isSupported.get(al)) {
+      if (isSupported.get(name) != null) {
 
         // first call to isSupported should be true
         assertTrue(al.isSupported(), al + " is not supported, but should be");
@@ -148,16 +149,20 @@ public class CompressionTest {
         assertNotNull(al.getCodec(), al + " should have a non-null codec");
 
         assertNotNull(al.getCodec(), al + " should have a non-null codec");
+
+        somethingGotTested = true;
       }
     }
+    assertTrue(somethingGotTested, "No Hadoop codecs were tested");
   }
 
   @Test
   public void testSingleNoSideEffect() {
 
+    boolean somethingGotTested = false;
     for (final String name : Compression.getSupportedAlgorithms()) {
       CompressionAlgorithm al = 
Compression.getCompressionAlgorithmByName(name);
-      if (isSupported.get(al) != null && isSupported.get(al)) {
+      if (isSupported.get(name) != null) {
 
         assertTrue(al.isSupported(), al + " is not supported, but should be");
 
@@ -168,17 +173,20 @@ public class CompressionTest {
 
         assertNotEquals(System.identityHashCode(al.getCodec()), 
al.createNewCodec(88 * 1024),
             al + " should have created a new codec, but did not");
+        somethingGotTested = true;
       }
     }
+    assertTrue(somethingGotTested, "No Hadoop codecs were tested");
   }
 
   @Test
   @Timeout(60)
   public void testManyStartNotNull() throws InterruptedException, 
ExecutionException {
 
+    boolean somethingGotTested = false;
     for (final String name : Compression.getSupportedAlgorithms()) {
       CompressionAlgorithm al = 
Compression.getCompressionAlgorithmByName(name);
-      if (isSupported.get(al) != null && isSupported.get(al)) {
+      if (isSupported.get(name) != null) {
 
         // first call to isSupported should be true
         assertTrue(al.isSupported(), al + " is not supported, but should be");
@@ -210,9 +218,10 @@ public class CompressionTest {
           assertTrue(result.get(),
               al + " resulted in a failed call to getcodec within the thread 
pool");
         }
+        somethingGotTested = true;
       }
     }
-
+    assertTrue(somethingGotTested, "No Hadoop codecs were tested");
   }
 
   // don't start until we have created the codec
@@ -220,9 +229,10 @@ public class CompressionTest {
   @Timeout(60)
   public void testManyDontStartUntilThread() throws InterruptedException, 
ExecutionException {
 
+    boolean somethingGotTested = false;
     for (final String name : Compression.getSupportedAlgorithms()) {
       CompressionAlgorithm al = 
Compression.getCompressionAlgorithmByName(name);
-      if (isSupported.get(al) != null && isSupported.get(al)) {
+      if (isSupported.get(name) != null) {
 
         // first call to isSupported should be true
         assertTrue(al.isSupported(), al + " is not supported, but should be");
@@ -249,8 +259,10 @@ public class CompressionTest {
           assertTrue(result.get(),
               al + " resulted in a failed call to getcodec within the thread 
pool");
         }
+        somethingGotTested = true;
       }
     }
+    assertTrue(somethingGotTested, "No Hadoop codecs were tested");
 
   }
 
@@ -258,9 +270,10 @@ public class CompressionTest {
   @Timeout(60)
   public void testThereCanBeOnlyOne() throws InterruptedException, 
ExecutionException {
 
+    boolean somethingGotTested = false;
     for (final String name : Compression.getSupportedAlgorithms()) {
       CompressionAlgorithm al = 
Compression.getCompressionAlgorithmByName(name);
-      if (isSupported.get(al) != null && isSupported.get(al)) {
+      if (isSupported.get(name) != null) {
 
         // first call to isSupported should be true
         assertTrue(al.isSupported(), al + " is not supported, but should be");
@@ -299,8 +312,10 @@ public class CompressionTest {
           assertTrue(result.get(),
               al + " resulted in a failed call to getcodec within the thread 
pool");
         }
+        somethingGotTested = true;
       }
     }
+    assertTrue(somethingGotTested, "No Hadoop codecs were tested");
   }
 
   @Test

Reply via email to