Skip to content

Commit

Permalink
[grid] Doing .countDown() when the right event has been listened to
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Jun 4, 2021
1 parent b2cf065 commit 29f46d0
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,20 @@ public void shouldStartHeartBeatOnNodeRegistration() {
CountDownLatch latch = new CountDownLatch(1);

bus.addListener(NodeHeartBeatEvent.listener(nodeStatus -> {
latch.countDown();
if (node.getId().equals(nodeStatus.getId())) {
latch.countDown();
heartbeatStarted.set(true);
}
}));
waitToHaveCapacity(distributor);
boolean eventFired = false;
boolean eventFiredAndListenedTo = false;
try {
eventFired = latch.await(30, TimeUnit.SECONDS);
eventFiredAndListenedTo = latch.await(30, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Assert.fail("Thread Interrupted");
}

assertThat(eventFired).isTrue();
assertThat(eventFiredAndListenedTo).isTrue();
assertThat(heartbeatStarted.get()).isTrue();
}

Expand Down

0 comments on commit 29f46d0

Please sign in to comment.