Skip to content

Commit

Permalink
Fixed flaky test: ResourceAwareTasksTests.testTaskIdPersistsInThreadC…
Browse files Browse the repository at this point in the history
…ontext

Signed-off-by: Ketan Verma <[email protected]>
  • Loading branch information
ketanv3 committed Sep 12, 2022
1 parent 54364a5 commit 63dfae0
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -616,6 +617,10 @@ public void onFailure(Exception e) {

taskTestContext.requestCompleteLatch.await();

// It is possible for the MockTaskManagerListener to be called after the response is sent already.
// Wait enough time for taskId to be added to taskIdsRemovedFromThreadContext before performing validations.
waitUntil(() -> taskIdsAddedToThreadContext.size() == taskIdsRemovedFromThreadContext.size(), 5, TimeUnit.SECONDS);

assertEquals(expectedTaskIdInThreadContext.get(), actualTaskIdInThreadContext.get());
assertThat(taskIdsAddedToThreadContext, containsInAnyOrder(taskIdsRemovedFromThreadContext.toArray()));
}
Expand Down

0 comments on commit 63dfae0

Please sign in to comment.