[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.
This commit is contained in:
Lee Hinman 2014-12-15 16:50:35 +01:00
parent 01fc84dbb3
commit 8fbf45ef2b
1 changed files with 1 additions and 3 deletions

View File

@ -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