From f9d7e76928123cf1979fea6bb53bbc5a39e64cfa Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 28 Nov 2014 15:10:55 +0100 Subject: [PATCH] [TEST] Relax constraints of breaker tests even more They were very stringent, and add values in worst-case situations. The new values are acceptable while still testing the functionality of the breaker. --- .../common/breaker/MemoryCircuitBreakerTests.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java b/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java index 698858e70f8..029365be22c 100644 --- a/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java +++ b/src/test/java/org/elasticsearch/common/breaker/MemoryCircuitBreakerTests.java @@ -78,8 +78,8 @@ public class MemoryCircuitBreakerTests extends ElasticsearchTestCase { } assertThat("no other exceptions were thrown", lastException.get(), equalTo(null)); - assertThat("breaker was tripped exactly once", tripped.get(), equalTo(true)); - assertThat("breaker was tripped exactly once", breaker.getTrippedCount(), equalTo(1L)); + assertThat("breaker was tripped", tripped.get(), equalTo(true)); + assertThat("breaker was tripped at least once", breaker.getTrippedCount(), greaterThanOrEqualTo(1L)); } @Test @@ -136,8 +136,8 @@ public class MemoryCircuitBreakerTests extends ElasticsearchTestCase { } assertThat("no other exceptions were thrown", lastException.get(), equalTo(null)); - assertThat("breaker was tripped exactly once", tripped.get(), equalTo(true)); - assertThat("breaker was tripped exactly once", breaker.getTrippedCount(), equalTo(1L)); + assertThat("breaker was tripped", tripped.get(), equalTo(true)); + assertThat("breaker was tripped at least once", breaker.getTrippedCount(), greaterThanOrEqualTo(1L)); } @Test @@ -204,12 +204,12 @@ public class MemoryCircuitBreakerTests extends ElasticsearchTestCase { } logger.info("--> child breaker: used: {}, limit: {}", breaker.getUsed(), breaker.getLimit()); - logger.info("--> parent tripped: {}, total trip count: {} (expecting 2 for each)", parentTripped.get(), tripped.get()); + 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)); - assertThat("parent breaker was tripped at least twice", parentTripped.get(), greaterThanOrEqualTo(2)); - assertThat("total breaker was tripped at least twice", tripped.get(), greaterThanOrEqualTo(2)); + 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)); }