Skip to content

Commit

Permalink
Merge pull request #676 from mattrjacobs/add-test-to-confirm-bad-requ…
Browse files Browse the repository at this point in the history
…ests-do-not-affect-healthiness-of-circuit-breaker

Add test to confirm that bad requests do not affect circuit breaker's computed error percentage
  • Loading branch information
mattrjacobs committed Feb 13, 2015
2 parents 50859ff + ca4c04b commit 4352de6
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ public void testGetErrorPercentage() {

}

@Test
public void testBadRequestsDoNotAffectErrorPercentage() {
HystrixCommandProperties.Setter properties = HystrixCommandPropertiesTest.getUnitTestPropertiesSetter();
HystrixCommandMetrics metrics = getMetrics(properties);

metrics.markSuccess(100);
assertEquals(0, metrics.getHealthCounts().getErrorPercentage());

metrics.markFailure(1000);
assertEquals(50, metrics.getHealthCounts().getErrorPercentage());

metrics.markBadRequest(1);
metrics.markBadRequest(2);
assertEquals(50, metrics.getHealthCounts().getErrorPercentage());

metrics.markFailure(45);
metrics.markFailure(55);
assertEquals(75, metrics.getHealthCounts().getErrorPercentage());
}

/**
* Utility method for creating {@link HystrixCommandMetrics} for unit tests.
*/
Expand Down

0 comments on commit 4352de6

Please sign in to comment.