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

ddanielr 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 e34b439e7d Fixes flaky IT test (#3917)
e34b439e7d is described below

commit e34b439e7d5cb0fe0183870b1659f88795cd1ef5
Author: Daniel Roberts <ddani...@gmail.com>
AuthorDate: Thu Nov 2 00:19:52 2023 -0400

    Fixes flaky IT test (#3917)
    
    Deletes candidates if they are found prior to test.
    Replaces instances of assertTrue with assertEquals.
    Cleans up comments.
---
 .../test/functional/GarbageCollectorIT.java        | 34 +++++++++++++---------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git 
a/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
 
b/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
index c35238dd41..b1372ac3ad 100644
--- 
a/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
+++ 
b/test/src/main/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java
@@ -34,7 +34,6 @@ import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map.Entry;
-import java.util.Objects;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -309,7 +308,6 @@ public class GarbageCollectorIT extends ConfigurableMacBase 
{
     killMacGc();
     TableId tableId = DataLevel.METADATA.tableId();
     log.info("Root GcCandidate Deletion test");
-    // Behavior for 2.1. INUSE candidates deletion support will be added in 3.x
     log.info("GcCandidates will be added but not removed from Zookeeper");
 
     Ample ample = cluster.getServerContext().getAmple();
@@ -321,10 +319,20 @@ public class GarbageCollectorIT extends 
ConfigurableMacBase {
     ArrayList<GcCandidate> tempCandidates = new ArrayList<>();
     while (cIter.hasNext()) {
       GcCandidate cTemp = cIter.next();
-      log.debug("PreExisting Candidate Found: {}", cTemp);
       tempCandidates.add(cTemp);
     }
-    assertTrue(tempCandidates.size() == 0);
+    if (tempCandidates.size() != 0) {
+      ample.deleteGcCandidates(datalevel, tempCandidates, 
Ample.GcCandidateType.VALID);
+      tempCandidates.clear();
+
+      cIter = ample.getGcCandidates(datalevel);
+      while (cIter.hasNext()) {
+        GcCandidate cTemp = cIter.next();
+        log.debug("PreExisting Candidate Found: {}", cTemp);
+        tempCandidates.add(cTemp);
+      }
+      assertEquals(0, tempCandidates.size());
+    }
 
     // Create multiple candidate entries
     List<GcCandidate> candidates =
@@ -347,11 +355,11 @@ public class GarbageCollectorIT extends 
ConfigurableMacBase {
       counter++;
     }
     // Ensure Zookeeper collapsed the entries and did not support duplicates.
-    assertTrue(counter == 2);
+    assertEquals(2, counter);
 
     cIter = ample.getGcCandidates(datalevel);
     while (cIter.hasNext()) {
-      // This should be a noop call. Root inUse candidate deletions are not 
supported in 2.1.x
+      // This should be a noop call. Root inUse candidate deletions are not 
supported.
       ample.deleteGcCandidates(datalevel, List.of(cIter.next()), 
Ample.GcCandidateType.INUSE);
     }
 
@@ -365,13 +373,13 @@ public class GarbageCollectorIT extends 
ConfigurableMacBase {
       for (GcCandidate cand : candidates) {
         if (gcC.getPath().equals(cand.getPath())) {
           // Candidate uid's will never match as they are randomly generated 
in 2.1.x
-          assertTrue(!Objects.equals(gcC.getUid(), cand.getUid()));
+          assertNotEquals(gcC.getUid(), cand.getUid());
           counter--;
         }
       }
     }
     // Ensure that we haven't seen more candidates than we expected.
-    assertTrue(counter == 0);
+    assertEquals(0, counter);
 
     // Delete the candidates as VALID GcCandidates
     cIter = ample.getGcCandidates(datalevel);
@@ -389,7 +397,7 @@ public class GarbageCollectorIT extends ConfigurableMacBase 
{
         counter++;
       }
     }
-    assertEquals(counter, 0);
+    assertEquals(0, counter);
   }
 
   @Test
@@ -471,7 +479,7 @@ public class GarbageCollectorIT extends ConfigurableMacBase 
{
       log.debug("PreExisting Candidate Found: {}", cTemp);
       candidates.add(cTemp);
     }
-    assertTrue(candidates.size() == 0);
+    assertEquals(0, candidates.size());
 
     // Create multiple candidate entries
     List<StoredTabletFile> stfs = Stream
@@ -489,7 +497,7 @@ public class GarbageCollectorIT extends ConfigurableMacBase 
{
       log.debug("Candidate Found: {}", cTemp);
       candidates.add(cTemp);
     }
-    assertTrue(candidates.size() == 2);
+    assertEquals(2, candidates.size());
 
     GcCandidate deleteCandidate = candidates.get(0);
     assertNotNull(deleteCandidate);
@@ -506,12 +514,12 @@ public class GarbageCollectorIT extends 
ConfigurableMacBase {
       GcCandidate gcC = candidate.next();
       log.debug("Candidate Found: {}", gcC);
       if (gcC.getPath().equals(deleteCandidate.getPath())) {
-        assertTrue(!Objects.equals(gcC.getUid(), deleteCandidate.getUid()));
+        assertNotEquals(gcC.getUid(), deleteCandidate.getUid());
         foundNewCandidate = true;
       }
       counter++;
     }
-    assertTrue(counter == 2);
+    assertEquals(2, counter);
     assertTrue(foundNewCandidate);
   }
 }

Reply via email to