Skip to content

Commit

Permalink
Merge pull request #1797 from MenschNestor/master
Browse files Browse the repository at this point in the history
Stabilize yet another test
  • Loading branch information
Tim Bozarth authored May 4, 2018
2 parents 7184bdc + 86eb945 commit 7f5a0af
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2440,6 +2440,7 @@ public void testSynchronousExecutionTimeoutValueViaExecute() {

System.out.println(">>>>> Begin: " + System.currentTimeMillis());

final AtomicBoolean startedExecution = new AtomicBoolean();
HystrixObservableCommand<String> command = new HystrixObservableCommand<String>(properties) {
@Override
protected Observable<String> construct() {
Expand All @@ -2449,6 +2450,7 @@ protected Observable<String> construct() {
@Override
public void call(Subscriber<? super String> t1) {
try {
startedExecution.set(true);
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
Expand Down Expand Up @@ -2477,7 +2479,7 @@ protected Observable<String> resumeWithFallback() {
assertEquals("expected fallback value", "timed-out", value);

// Thread isolated
assertTrue(command.isExecutedInThread());
assertTrue(!startedExecution.get() || command.isExecutedInThread());
assertNotNull(command.getExecutionException());

assertEquals(0, command.metrics.getCurrentConcurrentExecutionCount());
Expand All @@ -2493,13 +2495,15 @@ public void testSynchronousExecutionUsingThreadIsolationTimeoutValueViaObserve()
.withExecutionIsolationStrategy(ExecutionIsolationStrategy.THREAD)
.withExecutionTimeoutInMilliseconds(50));

final AtomicBoolean startedExecution = new AtomicBoolean();
HystrixObservableCommand<String> command = new HystrixObservableCommand<String>(properties) {
@Override
protected Observable<String> construct() {
return Observable.create(new OnSubscribe<String>() {

@Override
public void call(Subscriber<? super String> t1) {
startedExecution.set(true);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
Expand Down Expand Up @@ -2527,7 +2531,7 @@ protected Observable<String> resumeWithFallback() {
assertEquals("expected fallback value", "timed-out", value);

// Thread isolated
assertTrue(command.isExecutedInThread());
assertTrue(!startedExecution.get() || command.isExecutedInThread());
assertNotNull(command.getExecutionException());

assertEquals(0, command.metrics.getCurrentConcurrentExecutionCount());
Expand Down

0 comments on commit 7f5a0af

Please sign in to comment.