فهرست منبع

[TEST] Make parent breaker check less strict

In cases of heavy contention, it's possible for more than 2 threads
to race to a circuit breaking exception.

Essentially this means that if we have 3 threads all trying to add 3 and
simultaneously cause a circuit breaking exception (due to retry), when
adjusting after circuit breaking we can "rewind" past what this test
expects the child breaker to be at.

This adds leeway into the check, where it's okay to be within
NUM_THREADS from the parentLimit, because each thread should only add 1
to the breaker at a time.
Lee Hinman 11 سال پیش
والد
کامیت
8fbf45ef2b
1فایلهای تغییر یافته به همراه1 افزوده شده و 3 حذف شده
  1. 1 3
      src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java

+ 1 - 3
src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java

@@ -207,11 +207,9 @@ public class MemoryCircuitBreakerTests extends ElasticsearchTestCase {
         logger.info("--> parent tripped: {}, total trip count: {} (expecting 1-2 for each)", parentTripped.get(), tripped.get());
         assertThat("no other exceptions were thrown", lastException.get(), equalTo(null));
         assertThat("breaker should be reset back to the parent limit after parent breaker trips",
-                breaker.getUsed(), equalTo((long)parentLimit));
+                breaker.getUsed(), greaterThanOrEqualTo((long)parentLimit - NUM_THREADS));
         assertThat("parent breaker was tripped at least once", parentTripped.get(), greaterThanOrEqualTo(1));
         assertThat("total breaker was tripped at least once", tripped.get(), greaterThanOrEqualTo(1));
-        assertThat("breaker total is expected value: " + parentLimit, breaker.getUsed(), equalTo((long)
-                parentLimit));
     }
 
     @Test