accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ctubb...@apache.org
Subject [accumulo] branch main updated: Stabilize NamespaceIdTest and TableIdTest (#1779)
Date Mon, 16 Nov 2020 17:24:33 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/main by this push:
     new 9c8bb33  Stabilize NamespaceIdTest and TableIdTest (#1779)
9c8bb33 is described below

commit 9c8bb334c00637514c41f04c6abeca1ec6e20711
Author: Christopher Tubbs <ctubbsii@apache.org>
AuthorDate: Mon Nov 16 12:23:44 2020 -0500

    Stabilize NamespaceIdTest and TableIdTest (#1779)
    
    TableId and NamespaceId have tests to ensure their caches work
    correctly. Previously, the tests would only *attempt* to increase the
    cache before checking that it decreased again. However, a garbage
    collection could have reduced the size of the cache before we checked
    its size. This change *guarantees* the cache will reach a specific size
    before proceeding.
---
 .../test/java/org/apache/accumulo/core/data/NamespaceIdTest.java | 9 +++++----
 .../src/test/java/org/apache/accumulo/core/data/TableIdTest.java | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/core/src/test/java/org/apache/accumulo/core/data/NamespaceIdTest.java b/core/src/test/java/org/apache/accumulo/core/data/NamespaceIdTest.java
index 3a803ae..5f6b9bf 100644
--- a/core/src/test/java/org/apache/accumulo/core/data/NamespaceIdTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/data/NamespaceIdTest.java
@@ -79,12 +79,13 @@ public class NamespaceIdTest {
     assertEquals(namespaceString, nsId.canonical());
 
     // create a bunch more and throw them away
-    for (int i = 0; i < 999; i++) {
-      NamespaceId.of(new String("namespace" + i));
+    long preGCSize = 0;
+    int i = 0;
+    while ((preGCSize = NamespaceId.cache.asMap().entrySet().stream().count()) < 100)
{
+      NamespaceId.of(new String("namespace" + i++));
     }
-    long preGCSize = NamespaceId.cache.asMap().entrySet().stream().count();
     LOG.info("Entries before System.gc(): {}", preGCSize);
-    assertTrue(preGCSize > 500); // verify amount increased significantly
+    assertEquals(100, preGCSize);
     long postGCSize = preGCSize;
     while (postGCSize >= preGCSize) {
       TableIdTest.tryToGc();
diff --git a/core/src/test/java/org/apache/accumulo/core/data/TableIdTest.java b/core/src/test/java/org/apache/accumulo/core/data/TableIdTest.java
index cfd8ca1..119e5ff 100644
--- a/core/src/test/java/org/apache/accumulo/core/data/TableIdTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/data/TableIdTest.java
@@ -88,12 +88,13 @@ public class TableIdTest {
     assertEquals(tableString, table1.canonical());
 
     // create a bunch more and throw them away
-    for (int i = 0; i < 999; i++) {
-      TableId.of(new String("table" + i));
+    long preGCSize = 0;
+    int i = 0;
+    while ((preGCSize = TableId.cache.asMap().entrySet().stream().count()) < 100) {
+      TableId.of(new String("table" + i++));
     }
-    long preGCSize = TableId.cache.asMap().entrySet().stream().count();
     LOG.info("Entries before System.gc(): {}", preGCSize);
-    assertTrue(preGCSize > 500); // verify amount increased significantly
+    assertEquals(100, preGCSize);
     long postGCSize = preGCSize;
     while (postGCSize >= preGCSize) {
       tryToGc();


Mime
View raw message