Skip to content

Commit

Permalink
Fix new race condition in DecommissionControllerTests (opensearch-pro…
Browse files Browse the repository at this point in the history
…ject#4688)

My previous fix introduced a new race condition by making the assertions
before waiting on the latch.

Signed-off-by: Andrew Ross <[email protected]>

Signed-off-by: Andrew Ross <[email protected]>
  • Loading branch information
andrross authored and ashking94 committed Nov 7, 2022
1 parent 7820be5 commit 4f124ef
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Bug]: Alias filter lost after rollover ([#4499](https://github.com/opensearch-project/OpenSearch/pull/4499))
- Attempt to fix Github workflow for Gradle Check job ([#4679](https://github.com/opensearch-project/OpenSearch/pull/4679))
- Fix flaky DecommissionControllerTests.testTimesOut ([4683](https://github.com/opensearch-project/OpenSearch/pull/4683))
- Fix new race condition in DecommissionControllerTests ([4688](https://github.com/opensearch-project/OpenSearch/pull/4688))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ public void testTimesOut() throws InterruptedException {
TimeValue.timeValueMillis(0),
new ActionListener<>() {
@Override
public void onResponse(Void unused) {}
public void onResponse(Void unused) {
countDownLatch.countDown();
}

@Override
public void onFailure(Exception e) {
Expand All @@ -232,10 +234,10 @@ public void onFailure(Exception e) {
}
}
);
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
MatcherAssert.assertThat("Expected onFailure to be called", exceptionReference.get(), notNullValue());
MatcherAssert.assertThat(exceptionReference.get(), instanceOf(OpenSearchTimeoutException.class));
MatcherAssert.assertThat(exceptionReference.get().getMessage(), containsString("waiting for removal of decommissioned nodes"));
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
}

public void testSuccessfulDecommissionStatusMetadataUpdate() throws InterruptedException {
Expand Down

0 comments on commit 4f124ef

Please sign in to comment.