Skip to content

Commit

Permalink
Merge pull request Netflix#643 from mattrjacobs/deflake-hystrix-obser…
Browse files Browse the repository at this point in the history
…vable-collapser-test

Stress-test HystrixObservableCollapser
  • Loading branch information
mattrjacobs committed Feb 6, 2015
2 parents 5ab3d91 + 519b6ad commit 277265b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private static void _reset() {
// clear metrics
HystrixCommandMetrics.reset();
HystrixThreadPoolMetrics.reset();
HystrixCollapserMetrics.reset();
// clear collapsers
HystrixCollapser.reset();
// clear circuit breakers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class HystrixObservableCollapserTest {
public void init() {
// since we're going to modify properties of the same class between tests, wipe the cache each time
HystrixCollapser.reset();
Hystrix.reset();
/* we must call this to simulate a new request lifecycle running and clearing caches */
HystrixRequestContext.initializeContext();
}
Expand Down Expand Up @@ -80,6 +81,15 @@ public void testTwoRequests() throws Exception {
assertEquals(0L, metrics.getRollingCount(HystrixRollingNumberEvent.RESPONSE_FROM_CACHE));
}

@Test
public void stressTestRequestCollapser() throws Exception {
for(int i = 0; i < 1000; i++) {
init();
testTwoRequests();
cleanup();
}
}

private static class TestRequestCollapser extends HystrixObservableCollapser<String, String, String, String> {

private final String value;
Expand Down

0 comments on commit 277265b

Please sign in to comment.