Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deflaked HystrixObservableCommandTest.testRejectedViaSemaphoreIsolation #642

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5025,13 +5025,21 @@ public void testRejectedViaSemaphoreIsolation() {

final AtomicBoolean exceptionReceived = new AtomicBoolean();

final TryableSemaphoreActual semaphore = new TryableSemaphoreActual(HystrixProperty.Factory.asProperty(1));

// used to wait until all commands have started
final CountDownLatch startLatch = new CountDownLatch(2);

// used to signal that all command can finish
final CountDownLatch sharedLatch = new CountDownLatch(1);

Runnable r = new HystrixContextRunnable(HystrixPlugins.getInstance().getConcurrencyStrategy(), new Runnable() {

@Override
public void run() {
try {
executionThreads.add(Thread.currentThread());
results.add(new TestSemaphoreCommand(circuitBreaker, 1, 200, TestSemaphoreCommand.RESULT_SUCCESS, TestSemaphoreCommand.FALLBACK_NOT_IMPLEMENTED).toObservable().map(new Func1<Boolean, Boolean>() {
results.add(new LatchedSemaphoreCommand(circuitBreaker, semaphore, startLatch, sharedLatch).toObservable().map(new Func1<Boolean, Boolean>() {

@Override
public Boolean call(Boolean b) {
Expand All @@ -5042,6 +5050,7 @@ public Boolean call(Boolean b) {
}).toBlocking().single());
} catch (Exception e) {
e.printStackTrace();
startLatch.countDown();
exceptionReceived.set(true);
}
}
Expand All @@ -5054,6 +5063,15 @@ public Boolean call(Boolean b) {

t1.start();
t2.start();

try {
startLatch.await();
} catch (InterruptedException ie) {
fail("Got interrupted while waiting for commands to start");
}

sharedLatch.countDown();

try {
t1.join();
t2.join();
Expand Down Expand Up @@ -5081,8 +5099,6 @@ public Boolean call(Boolean b) {
assertEquals(0, circuitBreaker.metrics.getRollingCount(HystrixRollingNumberEvent.TIMEOUT));
assertEquals(0, circuitBreaker.metrics.getRollingCount(HystrixRollingNumberEvent.RESPONSE_FROM_CACHE));

System.out.println("**** DONE");

assertEquals(2, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
}

Expand Down